关于用自定义函数(function),求1!+2!+3!+…+10!并用print显示结果?一定要在VB里求:
用自定义函数(function),求1!+2!+3!+…+10!并用print显示结果?
Private Sub Command1_click()
End Sub
function fact(x as integer) as long
end function
的问题
Private Sub Command1_click()
Dim i As Integer
Dim Result As Long
For i = 1 To 10
Result = Result + fact(i)
Next
Print Result
End Sub
Function fact(x As Integer) As Long
Dim i As Integer
Dim Result As Long
Result = 1
For i = 1 To x
Result = Result * i
Next i
fact = Result
End Function