求教一道简单的VB题,直到最后一项的绝对值小于10-5为止.1-1/(1*2)+1/(2*3)-
问题描述:
求教一道简单的VB题,直到最后一项的绝对值小于10-5为止.1-1/(1*2)+1/(2*3)-
不知道哪里错了Private Sub Command1_Click()
Dim a As Double,i As Integer,s As Single
f = -1
i = 1
Do
a = 1 / (i * (i + 1))
s = 1 + f * a
i = i + 1
f = -f
Loop Until Abs(a) Print s
End Sub
求教
答
Private Sub Command1_Click()Dim a As Double,i As Long,s As Singlef = -1i = 1Doa = 1 / (i * (i + 1))s = 1 + f * ai = i + 1f = -fLoop Until Abs(a)