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
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
index | True | id | i | Step index |
beginValue | True | number | 0 | Initial value |
endValue | True | number | 10 | End value |
stepValue | True | number | 1 | Step 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