VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   1080
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   1080
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   375
      Left            =   1440
      TabIndex        =   0
      Top             =   600
      Width           =   1695
   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 = 0
  For i = 1 To n
    x = a + i * h
    sum = sum + f(x)
  Next i
  trapez = sum * h
End Function
Private Sub Command1_Click()
  Print trapez(2, 3, 30)
End Sub
Public Function f(ByVal x!)
  f = (x + 1) / (Log(x) + 1)       ' 对不同的被积函数在此作对应的改动
End Function

