VB中e的近似值怎么编程 求高手指点

2024-11-22 21:21:33
推荐回答(3个)
回答(1):

这就是do loop while a啊
Private Sub Form_Click()
Dim tal As Double, lin As Double, i%
i = 0: lin = 1
Do
'e≈1+(1/1!)+(1/2!)+(1/3!)+…+(1/n!)
tal = 1
i = i + 1
For j = 2 To i
tal = tal * j
Next j
lin = lin + 1 / tal
Loop while 1 / tal >= 0.0001
Print lin
End Sub

回答(2):

Private Sub Form_Click()
Dim e#, i!, t#
e = 1
i = 1
t = 1
Do While (1 / t) >= (10 ^ -4)
t = t * i
e = e + 1 / t
i = i + 1
Loop
Print e
End Sub

回答(3):

假定窗体form1上有一个label1控件用来显示结果,那么,只需要在form1_load()中加入以下语句即可:
label1.caption
=
round(
exp(
1
)
,
5
)