VBScript Tutorials - Herong's Tutorial Examples - v6.01, by Dr. Herong Yang
This section describes how 'While' statements work in VBScript. A block of statements is repeated as long as the specified condition is true.
Another type of loop statements is called "While" statement, which has the following syntax:
While condition statement_block (multiple statements) Wend
where "condition" is a Boolean value.
A "While" statement is executed like this:
Step 1: Check Boolean value of "condition".
Step 2: If the current value of "condition" is "True", continue with Step 4.
Step 3: If the current value of "condition" is "False", terminate the loop.
Step 4: Execute "statement_block" enclosed in the "While ... Wend" loop.
Step 5: Continue with Step 1.
The logic of a "While" statement is simpler than a "For ... Next" statement. But you have to manage the condition carefully, so that its value will become "False" at some point to terminate the loop.
Notice that there seem to be no "Exit" statement to break "While" loop early.
Table of Contents