Skip to main content
Version: v6.5.0

For...To...Next

Command Description

First, set the counting variable to its initial value, then loop through the following block of statements until the counting variable is greater than the end value. After each execution of the statement block, increment the counting variable by the step value (default is 1).

Command Prototype

For index = beginValue To endValue step stepValue

Next

Parameter Description

ParameterRequiredTypeDefaultDescription
indexTrueidiStep index
beginValueTruenumber0Initial value
endValueTruenumber10End value
stepValueTruenumber1Step in

Demo

TracePrint("------------------------------------------------Counting loops------- -----------------------------------") 
//-------------------------------------------------------------------------------
//[Remarks] Substitute the index into the loop, execute the statement block between for and next , the value of the index is from start to end times, step is the step, and each loop can increase the index by step corresponds to the quantity, not 1 anymore.
TracePrint("Let i be 0, step size is 1, increment to 10, print the value of i, the result is: ")
For i = 0 To 10 Step 1
TracePrint i
Next