VBS TUTORIAL: VBScript statement-for ... Next Statement _vbs

Source: Internet
Author: User

For ..... Next statement

Repeats a set of statements at a specified number of times.

For counter = start To end [Step step]
[statements]
[Exit For]
[statements]
Next

Parameters

Counter

A numeric variable used as a loop counter. This variable cannot be an element of an array element or a user-defined type.

Start

The initial value of the counter.

End

The end value of the counter.

Step

The step size of the counter . If not specified, the default value for step is 1.

Statements

One or more statements between for and next will be executed a specified number of times.

Description

The step parameter can be positive or negative. The Step parameter value determines the execution of the loop, as follows:

value If ... The loop executes
Positive or 0 Counter <= End
Negative Counter >= End

When the loop starts and all the statements in the loop are executed , the step value is added to the counter . At this point, or the statement in the loop executes again (the same test based on the loop beginning execution), or exits the loop and continues execution from the statement following the next statement.

note that changing the value of counter in the loop will make it more difficult to read and debug the program code.

Exit for can only be used for each ... Next or for ... NEXT structure, provides another way to exit the loop. You can place any Exit for statement anywhere in the statement. Exit for often is used with conditional judgment statements (for example, If ...). Then), and immediately transfers control to the statement after next .

You can put a for ... Next Loop is placed in another for ... Next Loop, which makes up a nested loop. The counter in each loop will use a different variable name. The following structure is correct:

    for  I = 1   to  ten   for  J = 1   to  ten   for  K = 1   to  ten  ...    Next    next  Next         

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.