Private Sub Command1_Click()
n = Text1.Text
t = 1
For i = 1 To n
t = t * i
s = s + 1 / t
Next i
Text2.Text = s
End Sub
一定有限定条件,不然会出错
比如:n<1000或 1/n!-1<=0.0000001等等
Private Sub Command1_Click()
Dim n As Integer, tmp As Double, sum As Double
Dim i As Integer, j As Integer
n = 4
tmp = 1
For i = 1 To n
For j = 2 To i
tmp = tmp * j
Next
sum = sum + 1 / tmp
tmp = 1
Next
MsgBox sum
End Sub