⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 vb 的例子
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "面积法求积分"
   ClientHeight    =   2130
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3780
   LinkTopic       =   "Form1"
   ScaleHeight     =   2130
   ScaleWidth      =   3780
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdCalc 
      Caption         =   "计算"
      Height          =   495
      Left            =   2160
      TabIndex        =   2
      Top             =   1440
      Width           =   1095
   End
   Begin VB.TextBox Text2 
      Alignment       =   2  'Center
      Height          =   375
      Left            =   1200
      MultiLine       =   -1  'True
      TabIndex        =   1
      Top             =   840
      Width           =   2055
   End
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Height          =   375
      Left            =   1200
      MultiLine       =   -1  'True
      TabIndex        =   0
      Top             =   360
      Width           =   2055
   End
   Begin VB.Label Label2 
      Caption         =   "积分结果"
      Height          =   255
      Left            =   360
      TabIndex        =   4
      Top             =   960
      Width           =   855
   End
   Begin VB.Label Label1 
      Caption         =   "梯形个数"
      Height          =   255
      Left            =   360
      TabIndex        =   3
      Top             =   480
      Width           =   855
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

    Private Sub cmdcalc_Click()
        Dim h As Single
        Dim L1 As Single, L2 As Single
        Dim s As Single
        Dim int1 As Integer, n As Integer
        Dim a As Single, b As Single
        s = 0
        a = 0: b = 2
        n = CInt(Text1.Text)
        h = (b - a) / n '梯形的高
        For int1 = 1 To n
            L1 = (Abs(4 - (a + (int1 - 1) * h) * (a + (int1 - 1) * h))) ^ 0.5
            L2 = (Abs(4 - (a + int1 * h) * (a + int1 * h))) ^ 0.5
            s = s + (L1 + L2) * h / 2 '梯形的面积
        Next
        Text2.Text = s
    End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -