March 2018
Beginner to intermediate
514 pages
13h 11m
English
The For... Next control statement is used when we know in advance the number of iterations we would like to perform. As with the Do... Loop control statement, For... Next also allows us to exit the loop at any point when using Exit Next. The syntax of this control statement is as follows:
For counter = expr1 to expr2 [ step expr3 ] [statements] [exit for [ ( when | unless ) condition ] [statements] Next [counter]
The expressions in the For statement are evaluated before the loop starts and only once. The Step statement will make the counter skip step expr3 (see syntax) number of positions. If step is a negative number, it will reverse the incremental iteration.
The following example shows how to use a For... Next control statement ...
Read now
Unlock full access