VBScript Tutorials - Herong's Tutorial Examples - v6.03, by Herong Yang
"Do ... Loop" Statements
This section describes how 'Do ... Loop' statements work in VBScript. A block of statements is repeated based on the specified condition.
Personally, I think that two types of loops, "For ... Next" and "While", are enough for any loop programming situations. But the designers of VBScript decided to give us an extra type of loops, "Do ... Loop" statements, with the following different flavors:
1. "Do While ... Loop" Statements
Do While condition
statement_block
Loop
They are identical logically to:
While condition
statement_block
Wend
2. "Do Until ... Loop" Statements
Do Until condition
statement_block
Loop
They are identical logically to:
While Not condition
statement_block
Wend
3. "Do ... Loop While" Statements
Do
statement_block
Loop While condition
They are identical logically to:
statement_block
While condition
same_statement_block
Wend
4. "Do ... Loop Until" Statements
Do
statement_block
Loop Until condition
They are identical logically to:
statement_block
While Not condition
same_statement_block
Wend
I will leave it to you to write some sample scripts for "Do ... Loop" statements as exercises.
Note that VBScript offers "Exit Do" statements to allow you to terminate "Do ... Loop" statements 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