📄 例9.frm
字号:
VERSION 5.00
Begin VB.Form frm8_7_4
Caption = "例9:单击窗体,求n的阶乘"
ClientHeight = 2190
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 2190
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text2
Height = 495
Left = 1920
TabIndex = 3
Top = 1200
Width = 1815
End
Begin VB.TextBox Text1
Height = 495
Left = 1920
TabIndex = 0
Top = 360
Width = 1815
End
Begin VB.Label Label2
Caption = "阶乘="
Height = 255
Left = 1200
TabIndex = 2
Top = 1320
Width = 735
End
Begin VB.Label Label1
Caption = "n="
Height = 375
Left = 1560
TabIndex = 1
Top = 480
Width = 375
End
End
Attribute VB_Name = "frm8_7_4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Function Fac(n As Integer) As Double '求n!的函数
Dim i As Integer, Temp As Double
Temp = 1
For i = 1 To n
Temp = Temp * i
Next i
Fac = Temp '把n !的值赋给函数名Fac
End Function
Private Sub Form_Click()
Dim k As Integer, nj As Double
k = Text1
nj = Fac(k) '求5的阶乘
Text2 = nj
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -