| While...Wend Statement |
Named Arguments
No
Syntax
While condition [statements] Wend
condition
Use: Required
Data Type: Numeric or String
An expression evaluating to True or False.
statements
Use: Optional
Program statements to execute while condition remains True.
Description
Repeatedly executes program code while a given condition remains True.
Rules at a Glance
A Null condition is evaluated as False.
If condition evaluates to True, the program code between the While and Wend statements is executed. After the Wend statement is executed, control is passed back up to the While statement, where condition is evaluated again. When condition evaluates to False, program execution skips to the first statement following the Wend statement.
You can nest While...Wend loops within each other.
Programming Tips and Gotchas
The While...Wend statement remains in Visual Basic for backward compatibility only. It has been superseded by the much more flexible Do...Loop statement.
See Also
- Do...Loop Statement
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access