Visualizing Nested For Loops
v
We can show this graphically by drawing a box
around the inner loop:
Result:
1
1
1
2
2
1
2
2
3
1
3
2
Dim i As Integer, j As Integer
For i = 1 To 3
For j = 1 To 2
Print i, j
Next j
Next i