概述
Sub testDoWhile()
Dim a As Integer
Dim sum As Integer
sum = 0
a = 1
Do While a <= 100
sum = sum + a
a = a + 1
Loop
MsgBox "1 + 2 + 3 + …… +100 = " & sum, vbOKOnly, "calculate the sum"
End Sub
Sub testDoWhile2()
Dim a As Integer
Dim sum As Integer
a = 1
sum = 0
Do
sum = sum + a
a = a + 1
Loop While a <= 100
MsgBox "1 + 2 + 3 + …… +100 = " & sum, vbOKOnly, "calculate the sum"
End Sub
Sub testDoUntil()
Dim a As Integer
Dim sum As Integer
a = 1
sum = 0
Do Until a > 100
sum = sum + a
a = a + 1
Loop
MsgBox "1 + 2 + 3 + …… +100 = " & sum, vbOKOnly, "calculate the sum"
End Sub
Sub testDoUntil2()
Dim a As Integer
Dim sum As Integer
sum = 0
a = 1
Do
sum = sum + a
a = a + 1
Loop Until a > 100
MsgBox "1 + 2 + 3 + …… +100 = " & sum, vbOKOnly, "calculate the sum"
End Sub
最后
以上就是傻傻八宝粥为你收集整理的vba学习笔记 do while和 do until的使用的全部内容,希望文章能够帮你解决vba学习笔记 do while和 do until的使用所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复