Export (0) Print
Expand All

Visual Basic for Applications Reference

Visual Studio 6.0

Do...Loop Statement

See Also    Example    Specifics

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

Or, you can use this syntax:

Do
[statements]
[Exit Do]
[statements]

Loop [{While | Until} condition]

The Do Loop statement syntax has these parts:

Part Description
condition Optional. Numeric expression or string expression that is True or False. If condition is Null, condition is treated as False.
statements One or more statements that are repeated while, or until, condition is True.

Remarks

Any number of Exit Do statements may be placed anywhere in the DoLoop as an alternate way to exit a DoLoop. Exit Do is often used after evaluating some condition, for example, IfThen, in which case the Exit Do statement transfers control to the statement immediately following the Loop.

When used within nested DoLoop statements, Exit Do transfers control to the loop that is one nested level above the loop where Exit Do occurs.

Show:
© 2015 Microsoft