Loop | starting | from | 1 | to | 10 | |
Dim icount As Integer For icount = 1 To 10 Next icount | | | | | | |
Increment | by | 1 | | | | |
Dim icount As Integer For icount = 1 To 10 Step 1 Next icount | | | | | | |
Decrement | by | -1 | | | | |
Dim iyear As Integer For iyear = 2006 To 2000 Step -1 iyear = iyear - 1 Next | | | | | | |
Start | from | 2 | and | stop | at | 4 |
For inner = 2 To 4 ''do something Next inner | | | | | | |
combine | Next | statements | onto | one | line | |
For iouter = 1 To 5 For inner = 2 To 4 ''do something Next iinner, iouter | | | | | | |
For-Each | | id="For_Each"> | | | | |
This gives you access to all the elements in a collection object without knowing exactly how many elements are in the collection. All elements in a Collection | | | | | | |
For Each .. Next | | | | | | |
All elements in an Array
| | | | | | |
Dim aNumbers(6) As Integer For Each item In aNumbers Next
| | | | | | |