argument can be either positive or negative. The value of the step
argument determines loop processing as follows:
step >= 0: loop executes if counter <= end.
step < 0: loop executes if counter >= end.
Once the loop starts and all statements in the loop have executed, step is added to counter. At this point, either the statements in the loop execute again (based on the same test that caused the loop to execute initially), or the loop is exited and execution continues with the statement following the Next statement.
: Changing the value of counter while inside a loop can make it more difficult to read and debug your code.
can only be used within a For Each...Next
control structure to provide an alternate way to exit. Any number of Exit For
statements may be placed anywhere in the loop. Exit For
is often used with the evaluation of some condition (e.g. If...Then...Else
), and transfers control to the statement immediately following Next
is used the statement for