VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.PictureBox Picture1 
      Height          =   2175
      Left            =   1440
      ScaleHeight     =   2115
      ScaleWidth      =   2835
      TabIndex        =   1
      Top             =   120
      Width           =   2895
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   1800
      TabIndex        =   0
      Top             =   2400
      Width           =   2055
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Function trapez(ByVal a!, ByVal b!, ByVal n%) As Single
 Dim sum!, h!, x!
 h = (b - a) / n
 sum = (f(a) + f(b)) / 2
 For i = 1 To n - 1
  x = a + i * h
  sum = sum + f(x)
 Next i
trapez = sum * h
End Function
Private Sub Command1_Click()
  Print trapez(1, 3, 30)
End Sub
Public Function f(ByVal x!)
  f = x * x * x + 2 * x + 5   ' 对不同的被积函数在此作对应的改动
End Function

Private Sub Picture1_Click()
  Picture1.Scale (0, 40)-(4, 0)
  For x = 1 To 3 Step 0.01
    y = x * x * x + 2 * x + 5
    Picture1.Line (x, y)-(x, 0)
  Next x
End Sub
