Previous Topic

Next Topic

Do...Loop statement

Repeats a block of statements while a condition is True or until a condition becomes True.

Syntax

Do [{While | Until} condition]
  [statements]
  [Exit Do]
  [statements]
Loop

Alternative Syntax

Do
  [statements]
  [Exit Do]
  [statements]
Loop [{While | Until} condition]

The Do...Loop statement syntax has these parts:

Part

Description

Condition

An optional boolean expression that is True or False.

Statements

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

Notes

A number of Exit Do statements can be placed anywhere in the Do...Loop as an alternate way to exit a Do...Loop. Exit Do is often used after evaluating some condition, for example, If...Then, in which case the Exit Do statement transfers control to the statement immediately following the Loop. When used in nested Do...Loop statements, Exit Do transfers control to the loop that is one nested level above the loop where Exit Do occurs.

See Also

MaxBasic Statements

Book Contents

Book Index