Private Sub Command1_Click()
Dim i As Integer, s As Double
For i = 1 To 99
s = s + fact(i)
Next i
Print "s=" & s
End Sub
Private Function fact(n As Integer) As Double
fact = 1
For i = 1 To n
fact = fact * i
Next i
End Function
Function factor(n As Integer) As Double
If n = 1 Then
factor = 1
Else
factor = n * factor(n - 1)
End If
End Function
Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 99
s = s + factor(i)
Next
Print s;
End Sub
我也在学VB。书上个给你找的,希望对你有帮忙呀
Private Sub Command1_Click()
Dim S As Double, jc As Double
jc = 1
For i = 1 To 99
jc = jc * i
S = S + jc
Next
Print "S="; S
End Sub