Function fact(ByVal n As Integer) As Long
Dim i As Integer
Dim s As Long
s = 1
For i = 1 To n
s = s i
Next
fact = s
End Function
Private Function jiecheng(n As Integer) As Integer
If n = 1 Then
jiecheng = 1
Else
jiecheng = n jiecheng(n - 1)
End If
End Function
我在习惯上做一个块,供事件方法调用。
它灵活在,你可以传递参数,可以是其它数的阶乘!!
Private Sub Command1_Click()
MsgBox "100!= " & Total(100) ’从此入口,调用下面的函数,并返回值
End Sub
Function Total (num as Double)
Dim i As Iinteger
num = 1
For i = 1 To 100
num = num i
Next
return Total
End Function
========================================
您的问题==我的课题 奉献知识==辉煌生命
黑龙江省 张志晨
========================================
Public Function Fac(ByVal n As integer) As Long
Dim i As Integer
For i=1 to n
Fac=Faci
Next i
End Function
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)