Private Sub Command1_Click()
Dim sum As Double
Dim i As Long
Dim n As Doublen = ((1 / (10 ^ -5)) + 1) / 2 '正好等于10 ^ -5时候n的值
n = Round(n + 0.5, 0) '对n+0.5进行四舍五入处理,保证n只要有小数点后面有数就进,不舍.For i = 1 To n '计算n项的和
sum = sum + 1 / (2 * i - 1)
Next i
Print "项数n为:" & n
Print "n项和为:" & sum
End Sub调试如下图: