Using for in nested loops

  • Thread starter Thread starter Oded Kovach
  • Start date Start date
O

Oded Kovach

Hello there

I have For on vb.

When i want to leave it before i'm using Exit for

Now i have nasted loops:
For i = 1 to 10
For j = 1 to 10

If i'm inside the j for what i need to do to go out from the j for and what
should i do for exiting the I for?

any help would be useful
 
Set a flag:

Dim bFound as Boolean
Dim i As Integer, j As Integer

For i = 1 to 10
For j = 1 to 10
bFound = True
Exit For
Next j

If bFound Then
Exit For
End If
Next i
 
Back
Top