新建From1(窗体),新建Command1(按钮CommandButton),代码:
Function Factorial(ByVal N As Double) As Double
If N <= 1 Then
Factorial = 1
Else
Factorial = Factorial(N - 1) * N
End If
End Function
Private Sub Command1_Click()
Dim N As Double
N = Val(Me.Text1.Text)
MsgBox Str(N) + "!=" + Str(Factorial(N))
End Sub