![]() ![]() When X reaches the end of the range in the range (100 in the example above), the loop will cease to execute, and the program will continue to the code beyond the next statement. For instance, for X = 100 to 1 step -1 would decrease the value of X from 100 to 99 to 98, etc.) (Note that the step can be a negative value. When the step is not explicitly stated, 1 is used by default. For example, if you use a step 3, X will increase from 1 to 4, then to 7, 10, 13, and so on. To change the amount by which the counter variable increases on each iteration, simply change the value of the step. In this instance, X will be increased to 3 on the second iteration, 5 on the third, etc. Upon reaching the next statement, the program returns to the for statement and increases the value of the counter by the step. The program then executes any code between the for and next statements normally. When a For.Next loop is initialized, the counter is set to the first number in the range in this case, X is set to 1. There is no ambiguity in doing this if code is correctly indented. The variable reference in the Next part of the statement is optional and it is common practice to leave this out. In this example, X is the counter, "1 to 100" is the range, and "2" is ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |