注意:步长可以为负
Option Explicit
Dim i
For i=1 to 10 step 2
Msgbox i
Next
For i=10to 5 step -1
Msgbox i
Next
二、Exit For语句
用于在计数器达到终止值之前退出For…next 语句。因为通常只有在某些特殊情况下(例如发生错误时)要退出循环,
所以可以在If Then….Else语句的True语句块中使用Exit For语句;如果条件为False,循环将照常运行。
Option Explicit
Dim i
For i=1 to 10 step 2
Msgbox i
If i>2 then
Exit for
end If
Next