Private Sub Command1_Click()
Dim n As Integer, m As Long
n = InputBox("请输入不大于12的数")
m = fact(n)
MsgBox (Str(m))
End Sub
Function fact(n As Integer) As Long
fact = 1
For i = 1 To n - 1
fact = fact * (i + 1)
Next
End Function
Private Sub Command1_Click()
MsgBox Str(fact(5))
End Sub
Function fact(n As Integer) As Integer
fact = 1
For i = 1 To n - 1
fact = fact * (i + 1)
Next
End Function
Function fact(n AS Integer) AS Long
fact=1
for i=1 to n
fact*=i
Next i
End Function