N
Nathan Sokalski
I have several nested For loops, as follows:
For a As Integer = 0 To 255
For b As Integer = 0 To 255
For c As Integer = 0 To 255
If <Boolean Expression> Then <My Code> Else Exit For
Next
If Not <Boolean Expression> Then Exit For
Next
If Not <Boolean Expression> Then Exit For
Next
As you can see, I need to test the condition in each For, which in my case
is probably more costly than necessary. If I could simply say exit all For
loops or exit 3 For loops or something, not only would it be less costly,
but simpler code. Is there any way to do this (or maybe a nice workaround)?
Thanks.
For a As Integer = 0 To 255
For b As Integer = 0 To 255
For c As Integer = 0 To 255
If <Boolean Expression> Then <My Code> Else Exit For
Next
If Not <Boolean Expression> Then Exit For
Next
If Not <Boolean Expression> Then Exit For
Next
As you can see, I need to test the condition in each For, which in my case
is probably more costly than necessary. If I could simply say exit all For
loops or exit 3 For loops or something, not only would it be less costly,
but simpler code. Is there any way to do this (or maybe a nice workaround)?
Thanks.