Do / Loop
Syntax Variations
- Pre‑test loop
Do While <condition>
' body
Loop
2. Pre‑test with Until Do Until <condition>
' body
Loop
3. Post‑test loop Do
' body
Loop While <condition>
4. Post‑test with Until Do
' body
Loop Until <condition>
Description
- Do While and Do Until check the condition before the first iteration.
- Loop While and Loop Until check after running the body at least once.
- Use
Loop Until to exit when a condition becomes True, or Loop While to continue while True.
Example
' Read input until a blank line is entered
Dim line As String
Do
line = Input("Enter text (blank to quit):")
If line <> "" Then Print("You entered: " + line)
Loop Until line = ""