VBA/Excel/Access/Word/Language Basics/Do Until
Содержание
Do Loop Until
<source lang="vb">
Sub cmdDoUntil()
Dim intValue As Integer intValue = 10 Do Until intValue = 35 intValue = intValue + 1 Loop
End Sub
</source>
Exit Do Until Loop
<source lang="vb"> 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 </source>
Use Do Until with if statement
<source lang="vb">
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
</source>
Using the Do...Until Loop
<source lang="vb"> Sub AskForPassword3() Dim pWord As String pWord = "" Do Until pWord = "DADA" pWord = InputBox("What is the Report password?") Loop End Sub </source>
Using the Do...Until Loop with a Condition at the Bottom of the Loop
<source lang="vb"> Sub PrintNumbers() Dim num As Integer num = 0 Do num = num + 1 Debug.Print num Loop Until num = 27 End Sub </source>