For <identifier> = <LowerBoundExpression > To <UpperBoundExpression> [Step expression] [statements] Next [identifier]
The identifier specifies the loop control variable, and must be declared prior to the For statement, either as type Integer or Number. Nested For...Next statements must each use their own loop control variable.
At the beginning of the loop, the lower bound expression is assigned to the loop control value. An optional Step value sets the amount by which the loop control variable will change with each iteration. If no Step value is provided, a default value of 1 is used. At the Next statement, the value of the loop control value increases or decreases by the amount of the step value.
At the beginning of each iteration, the loop control variable is compared to see if it is greater or less than the upper bound expression (depending on a positive or negative Step value). If the control variable exceeds the upper bound, the loop terminates; otherwise the statement block is executed..
Rule total As Integer Dim counter As Integer = 0 For counter = 0 To 10 Step 2 total = total + counter printValue("Total = " + stringValue(total) + _ " Counter = " + stringValue(counter)) Next End Rule Output: "Total = 0 Counter = 0" "Total = 2 Counter = 2" "Total = 6 Counter = 4" "Total = 12 Counter = 6" "Total = 20 Counter = 8" "Total = 30 Counter = 10"