Do ... Loop, Do While..., Do Until...
Repeat a block of statements.
Syntax
Do [While condition]
[Statements]
[Exit Do]
[Statements]
Loop
or:
Do [Until condition]
[Statements]
[Exit Do]
[Statements]
Loop
or:
Do
[Statements]
[Exit Do]
[Statements]
Loop [While condition]
or:
Do
[Statements]
[Exit Do]
[Statements]
Loop [Until condition]
Key
condition A boolean expression that evaluates to True or False
Statements VBScript statements to be repeated until condition is True
The keyword While will continue the loop as long as condition is True.
The keyword Until will continue the loop as long as condition is False.
If no condition is specified, the loop will repeat indefinitely or until an Exit Do is encountered.
Examples
'Count to 50
Option Explicit
Dim counter
counter = 0
Do
counter = counter + 1
WScript.Echo counter
Loop Until counter = 50
WScript.Echo "Final total" & counter
' Count to 100
Option Explicit
Dim i
i = 0
Do While i < 100
i = i + 1
WScript.Echo i
Loop
WScript.Echo "Final total" & i