www.rtmj.net > vB DowhilE循环语句格式

vB DowhilE循环语句格式

Do <循环体语句> Loop While <条件判断>特点:因为一开始,直接进入循环,运行<循环体语句>后,才会去执行<条件判断>,所以这种循环语句,至少会执行一次循环.如果<布尔表达式>的值为True,就从Do开始,继续执行循环;如果<布

Dim a As Integer Dim b As Longb do Longb = 1Dob = b * aa = a + 1 while a <= 4 Print b

private sub command1_click() i = 0 do while x -1 x = val(inputbox("输入数据,输入-1结束")) if x mod 2 = 0 then i = i + 1 loop print "偶数有" & i & "个" end sub

Dim a, b, s, i As Integer '定义变量 a = Val(Text1.Text) '把Text1由字符串转成数值后赋值给变量a b = Val(Text2.Text) '同上 s = 0 's的值归零 i = a '把a的值赋值给变量i Do While i <= b '当i<=b的时候做循环 s = s + i '把i的值累加到s上 i = i + 1 'i增加1 Loop '循环结尾 MsgBox "计算结果为:" & s '用对话框输出计算结果s End Sub '结束

Private Sub Command1_Click()i = 0Do While x <> -1x = Val(InputBox("输入数据,输入-1结束"))If x Mod 2 = 0 Then i = i + 1LoopPrint "偶数有" & i & "个"End Sub

do while 条件语句块loop

do loop while 特点:因为一开始,直接进入循环,运行后,才会去执行,所以这种循环语句,至少会执行一次循环.如果的值为true,就从do开始,继续执行循环;如果的值为false,就循环结束,执行loop while 下面的语句.例如:i = 1do print i i = i + 1 loop while i 就是i 评论0 0 0

规定要用Do While吗..Dim i As Long, Str As Stringi = 12Do While (i * 79 * 111) < 1000000 If ((i * 79 * 111) \ 100) Mod 100 = 36 Then Str = Str & CStr(i * 79 * 111) & " " End If i = i + 1LoopMsgbox Str 答案只有一个 543678

Do While Loop 就是 While,一模一样.While 缺陷在于必须是退出循环前提条件成立,而不能是继续循环前提条件成立.后者用 Do Loop While 可以达到

Private Sub Command1_Click() Dim i As Long, s As Long, t As Long 'i统计输入的个数,s乘积,t存储输入的数字 s = 1 t = 1 i = -1 Do s = s * t t = InputBox("请输入一个数,如果输入为0则结束") i = i + 1 Loop While t Print "共输入了" & i & "个数,乘积为:" & sEnd Sub

网站地图

All rights reserved Powered by www.rtmj.net

copyright ©right 2010-2021。
www.rtmj.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com