【VB开源代码栏目提醒】:网学会员,鉴于大家对VB开源代码十分关注,论文会员在此为大家搜集整理了“frmL3_9.frm”一文,供大家参考学习!
VERSION 5.00
Begin VB.Form frmL3_9
Caption = "计算阶乘"
ClientHeight = 1620
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form3"
ScaleHeight = 1620
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdJcjs
Caption = "计算"
Height = 375
Left = 3240
TabIndex = 4
Top = 360
Width = 1095
End
Begin VB.TextBox txtJs
Height = 375
Left = 1080
TabIndex = 2
Top = 240
Width = 1575
End
Begin VB.Label lblJcjg
BorderStyle = 1 'Fixed Single
Height = 375
Left = 1080
TabIndex = 3
Top = 840
Width = 1575
End
Begin
VB.Label Label2
AutoSize = -1 'True
Caption = "阶乘:"
Height = 180
Left = 240
TabIndex = 1
Top = 840
Width = 540
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "阶数:"
Height = 180
Left = 240
TabIndex = 0
Top = 240
Width = 540
End
End
Attribute VB_Name = "frmL3_9"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub JieCheng(n As Integer)
If n < 0 Then
MsgBox "无效阶数!"
Exit Sub
End If
If n = 0 Then
lblJcjg.Caption = 1
Exit Sub
End If
Dim i As Integer, j As Long
j = 1
For i = 1 To n
j = j * i
Next
lblJcjg.Caption = j
End Sub
Private Sub cmdJcjs_Click()
Dim n As Integer
n = Val(txtJs.Text)
Call JieCheng(n)
End Sub