A Do
loop statement loops based on a boolean expression.
An expression may be placed after the Do
keyword or after the Loop
keyword, but not after both. It is also legal to specify no expression at all; in that case, the loop will never exit. If the expression is placed after the Do
, then it will be evaluated before the loop block is executed on each iteration. If the expression is placed after the Loop
, then it will be evaluated after the loop block has executed on each iteration. The conditional expression must be prefixed with either a While
keyword or an Until
keyword. The former breaks the loop if the condition evaluates to False
, the latter when the condition evaluates to True
.
Do
[ WhileOrUntil BooleanExpression ] StatementTerminatorLoop
[ WhileOrUntil BooleanExpression ] StatementTerminatorWhile
| Until