Loop based on an expression.
For <variable> = <start> To <stop> [Step <stepval>]
statements
...
Next
variable | The variable used for the count. |
start | The initial numeric value of the variable. |
stop | The final numeric value of the variable. |
stepval | [optional] The numeric value (possibly fractional) that the count is increased by each loop. Default is 1. |
The variable will be created automatically with Local scope, even when MustDeclareVars is on.
For...Next statements may be nested. The For loop terminates when the value of variable exceeds the stop threshold. If stepVal or stop is a variable, its value is only read the first time the loop executes.
A For loop will execute zero times if:
start > stop and step > 0, or
start < stop and step is negative