The VBScript Network and Systems Administrator's Cafe

Jun 28 2008   11:20PM GMT

VBScript Statements: Explanation of the For … Next Statement

Jerry Lees Jerry Lees Profile: 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

For x=1 to 20 step 2
    wscript.echo x


 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: