函数的
Function Jc(x As Integer)
s = 1
For i = 1 To x
s = s * i
Next i
Jc = s
End Function
Private Sub Command1_Click()
Text2.Text = Jc(Val(Text1.Text))
End Sub
过程的
Sub Jc()
s = 1
For i = 1 To Val(Text1.Text)
s = s * i
Next i
Text2.Text = s
End Sub
Private Sub Command1_Click()
Call Jc
End Sub
Private Function fact(ByVal x As Integer) As Long
Dim i As Integer
Dim r As Longr = 1
For i = 1 To x
r = r * i
Next
fact = r
End Function