Name
While...End While Statement
Syntax
Whilecondition
[statements]
End While
-
condition
Use: Required
Data Type: Numeric or String
An expression evaluating to
True
orFalse
-
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 asFalse
.If
condition
evaluates toTrue
, the program code between theWhile
andEnd
While
statements is executed. After theEnd
While
statement is executed, control is passed back up to theWhile
statement wherecondition
is evaluated again. Whencondition
evaluates toFalse
, program execution skips to the first statement following theEnd
While
statement.You can nest
While...End
While
loops within each other.
Programming Tips and Gotchas
The While...End
While
statement
remains in Visual Basic for backward compatibility only. In our
opinion, it has been superceded by the much more flexible
Do...Loop
statement.
VB .NET/VB 6 Differences
In VB 6, the ending statement that accompanies the
While
construct is Wend
; in VB
.NET, it is End
While
.
See Also
Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.