private sub Form_Click()
dim i as long
dim s as currency
s=1
for i=2 to 100
s=s+(1/i)
next i
msgbox s
end sub
'这个程序会弹出精确到4位小数的结果,如果需要更高精度的,可以试着把currency换成double。
Private Sub Command1_click()
Dim n As Integer
n = 100
Print f(n)
End Sub
Function f(n)
For i = 1 To n
f = f + 1 / i
Next i
End Function
s=0
for i=1 to 100
s=s+1/i
next
msgbox s