vb高手请进!!编写一个求n!的函数过程,并在命令按钮的单击...4
发布网友
发布时间:2024-03-04 23:42
我来回答
共2个回答
热心网友
时间:2024-08-03 05:17
Function Fac(intN)
Fac = 1
For i = 1 To intN
Fac = Fac * i
Next i
End Function
Private Sub Command1_Click()
m = Val(InputBox("输入M值", "输入", "1"))
n = Val(InputBox("输入N值", "输入", "1"))
MsgBox Fac(n) / (Fac(m) * Fac(n - m))
End Sub
热心网友
时间:2024-08-03 05:16
Public Function Factorial(ByVal x As Integer) As Integer
If x = 0 Or x = 1
Return 1
End If
Return x * Factorial(x-1)
End Function