VBScript Statements: Explanation of the For … Next Statement
Posted by: Jerry Lees
The For Next statement is very useful for situations where you need to loop through a piece of code a specific number of times.
You can use Exit For statements to exit out of a For loop, if you need to check for a condition inside the loop. Additionally, The Step keyword at the end of the line that has the for statement will allow you to loop through a For statement in any size of increment.
Here is an example of a for statement, followed by one with a Step key word:
For x = 1 to 10
wscript.echo x
next
For x=1 to 20 step 2
wscript.echo x
next


