While wend
While...Wend
Repeats a block of statements as long as a condition remains True. The condition is evaluated at the top of the loop before each iteration.
Syntax
While condition
[statements]
Wend
Parameters
- condition: A Boolean expression evaluated before each iteration. The loop exits when it becomes
False. - statements: One or more statements to execute inside the loop.
Remarks
- If
conditionisFalseon the first evaluation, the body never executes. While...Wenddoes not support early exit. UseDo...LoopwithExit Dowhen you need to break out of the loop before the condition changes.
Example
Dim n As Integer
n = 1
While n <= 5
Print n
n = n + 1
Wend
' Output: 1 2 3 4 5