注册 登录
编程论坛 VB6论坛

请高手帮忙解释下

zhenzhen2012 发布于 2012-12-27 23:33, 381 次点击
Private Sub Command1_Click()
Dim a As Double, b As Integer, r As Single, n As Integer
n = 0
r = 0.01
a = 12
Do While a >= 20
a = a * (1 + r)
n = n + 1
Loop
Print n
End Sub

这是个很简单的例子,计算N,为什么我的N老为0
7 回复
#2
Artless2012-12-28 22:56
看看do...loop的帮助吧。
#3
nick1182012-12-30 16:55
因为你的a = 12啊
#4
wp2319572012-12-30 22:16
循环条件不成立  无法进入循环
#5
zhujianlin2012-12-31 15:16
你这个东西我实在没能理解,你自己写的吗?
#6
SKYYYF2012-12-31 21:35
因为 a =12 ,不满足循环条件,所以跳过循环语句,直接输出结果。
#7
小东0052012-12-31 21:49
回复 楼主 zhenzhen2012
Private Sub Command1_Click()
Dim a As Double, b As Integer, r As Single, n As Integer
n = 0
r = 0.01
a = 12
Do While a 〈 20
a = a * (1 + r)
n = n + 1
Loop
Print n
End Sub
改成这样就可以执行了!!
#8
wangyuzg2013-01-25 09:41
跟我一样,确实是菜鸟。还要继续努力呀。
1