VBScript Tutorials - Herong's Tutorial Examples - v6.02, by Herong Yang
"While" Statements
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
Introduction of VBScript - Visual Basic Scripting Edition
Variant Data Type, Subtypes, and Literals
Numeric Comparison Operations and Logical Operations
String Operations - Concatenation and Comparison
Variable Declaration and Assignment Statement
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Array Data Type and Related Statements
Array References and Array Assignment Statements
Conditional Statements - "If ... Then" and "Select Case"
►Loop Statements - "For", "While", and "Do"
"For ... Next" Statement Example Examples
"Function" and "Sub" Procedures
Inspecting Variables Received in Procedures
Error Handling Flag and the "Err" Object
Regular Expression Pattern Match and Replacement
scrrun.dll - Scripting Runtime DLL Library
IE Web Browser Supporting VBScript