Skip to content

While / Wend

Syntax

While <condition>
  ' loop body
Wend

Description

  • Evaluates <condition> before each iteration.
  • If True, executes loop body and repeats.
  • Terminates when <condition> becomes False.

Example

Dim n As Integer = 1

While n <= 5
  Print("Count: " + n.ToString)
  n += 1
Wend
' Outputs Count: 1 … Count: 5

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 = ""