VBA/Excel/Access/Word/Language Basics/Do Until
Версия от 16:33, 26 мая 2010; (обсуждение)
Содержание
Do Loop Until
Sub cmdDoUntil()
Dim intValue As Integer
intValue = 10
Do Until intValue = 35
intValue = intValue + 1
Loop
End Sub
Exit Do Until Loop
Sub AskForPassword4()
Dim pWord As String
pWord = ""
Do Until pWord = "DADA"
pWord = InputBox("What is the Report password?")
If pWord = "" Then Exit Do
Loop
End Sub
Use Do Until with if statement
Sub doTest1()
Dim intCounter As Integer
Dim intTest As Integer
intTest = 1
intCounter = 1
Do Until intTest <> 1
Debug.Print "This is loop number " & intCounter
If intCounter >= 5 Then
intTest = 0
End If
intCounter = intCounter + 1
Loop
End Sub
Using the Do...Until Loop
Sub AskForPassword3()
Dim pWord As String
pWord = ""
Do Until pWord = "DADA"
pWord = InputBox("What is the Report password?")
Loop
End Sub
Using the Do...Until Loop with a Condition at the Bottom of the Loop
Sub PrintNumbers()
Dim num As Integer
num = 0
Do
num = num + 1
Debug.Print num
Loop Until num = 27
End Sub