Option Explicit
Private Sub Form_Load()
'窗体自动刷新,以便Print语句显示结果
Me.AutoRedraw = True
Dim e As Double
Dim n As Integer
e = 2#
n = 2
Do While n <= 100
e = e + 1# / Factorial(n)
n = n + 1
Loop
Print e
End Sub
Private Function Factorial(ByVal n As Integer) As Double
Dim f As Double
Dim k As Integer
f = 1
For k = 1 To n
f = f * k
Next
Factorial = f
End Function