Private Sub Command1_Click()
Dim n,pi,i
pi = 2
n = Val(InputBox("请输入一个数"))
For i = 1 To n
pi = pi * ((2 * i) ^ 2 / ((2 * i - 1) * (2 * i + 1)))
Next i
MsgBox "π的近似值为" & pi
End Su
Private Sub Command1_Click()
Dim n,pi,i
pi = 2
n = Val(InputBox("请输入一个数"))
For i = 1 To n
pi = pi * ((2 * i) ^ 2 / ((2 * i - 1) * (2 * i + 1)))
Next i
MsgBox "π的近似值为" & pi
End Su