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

📄 form0604.frm

📁 VB实验教程源码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "计算"
   ClientHeight    =   3360
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3360
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text2 
      Height          =   855
      Left            =   720
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   3
      Top             =   1560
      Width           =   3255
   End
   Begin VB.CommandButton Command1 
      Caption         =   "计算"
      Height          =   495
      Left            =   1680
      TabIndex        =   2
      Top             =   2640
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   615
      Left            =   2280
      TabIndex        =   0
      Top             =   240
      Width           =   1455
   End
   Begin VB.Label Label2 
      Caption         =   "计算结果:"
      Height          =   375
      Left            =   720
      TabIndex        =   4
      Top             =   1200
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "计算的项数"
      Height          =   375
      Left            =   840
      TabIndex        =   1
      Top             =   360
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Function Multiply(n As Integer) As Integer
'计算阶乘
    Multiply = 1
    Do While n > 0
        Multiply = Multiply * n
        n = n - 1
    Loop
End Function

Private Sub Command1_Click()
'单击计算按钮
    Dim Sum As Integer, i As Integer, n As Integer
    n = Val(Text1.Text)
    For i = n To 1 Step -1
        Sum = Sum + Multiply((i))
        If i <> 1 Then
            Text2.Text = Text2.Text & i & "! + "
        Else
            Text2.Text = Text2.Text & i & "! =" & Chr(13) + Chr(10)
        End If
    Next
    Text2.Text = Text2.Text & Sum
End Sub

⌨️ 快捷键说明

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