Here we have two loops—the first iterates with the variable "i," and the second is nested within that loop. When the two loop indexes are certain values, we use a GoTo.
Module Module1
Sub Main()
' Two nested loops.
' ... On a certain condition, exit both loops with a GoTo.
For i As Integer = 0 To 5
For x As Integer = 0 To 5
' Display our indexes.
Console.WriteLine(
"{0}, {1}", i, x)
If x = 1 And i = 3 Then
' Use GoTo to exit two loops.
GoTo AFTER
End If
Next
Next
AFTER:
' Print a message.
Console.WriteLine(
"Finished")
End Sub
End Module
0, 0
0, 1
0, 2
0, 3
0, 4
0, 5
1, 0
1, 1
1, 2
1, 3
1, 4
1, 5
2, 0
2, 1
2, 2
2, 3
2, 4
2, 5
3, 0
3, 1
Finished