For next loops - question
For next loops - question
(OP)
Some of you familiar with C may know the "continue" command, for example:
for (i=0; i<5; i++) // equivalent to For i = 0 To 5 in VB
{
if (some condition)
cpntinue;
some statement;
} // In VB this would say Next i
In this case, if "some condition" is satisfied, then instead of execting "some statement", the program moves on immediately to the next "go-round" in the loop.
I have been looking for a similar function on VB on the internet, but without success. Could anybody confirm whether this functionality is available in VB or not?
Many thanks.
for (i=0; i<5; i++) // equivalent to For i = 0 To 5 in VB
{
if (some condition)
cpntinue;
some statement;
} // In VB this would say Next i
In this case, if "some condition" is satisfied, then instead of execting "some statement", the program moves on immediately to the next "go-round" in the loop.
I have been looking for a similar function on VB on the internet, but without success. Could anybody confirm whether this functionality is available in VB or not?
Many thanks.





RE: For next loops - question
That being said, 'Exit For' is the VB command that you're looking for.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: For next loops - question
For i = 1 to 5
statements
IF condition = true then goto SkipToNext
statements
SkipToNext:
Next
or
For i = 1 to 5
statements
IF condition = false then
statements
EndIf
Next
RE: For next loops - question
Perhaps the simplest answer would be
For i = 1 to 10
If (Not (SomeCondition)) Then
<execute body of loop>
End If
Next i
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein