Previous Topic

Next Topic

While...Wend statement

Repeats a block of statements while a condition is True.

Syntax

While condition
  [statements]
Wend

The While...Wend statement syntax has these parts:

Part

Description

Condition

A boolean expression that is True or False.

Statements

One or more statements that are repeated while condition is True.

Notes

While...Wend runs the same way as Do While...Loop. The condition is checked before each pass, so the statements do not run if the condition is False at the start.

Exit Do ends the loop early, as in a Do...Loop.

Example

Dim n As Number = 3

While n > 0

  n = n - 1

Wend

When VB compatibility is not selected

When MaxBasic VB compatibility is not selected on System Settings - General tab, and the script has no Option VBCompatibility statement, While gives an error. Use Do While...Loop instead. Wend is not a reserved word, so it can be used as a name.

See Also

MaxBasic Statements

Book Contents

Book Index