Loop continue

  • Thread starter Thread starter David Dvali
  • Start date Start date
D

David Dvali

What is loop continue in VB?
Loke in C#:
for (int i=0; i<10; i++)
{
if (i==7)
continue;
...
}
 
VB 2005 has "Continue For", but the following (produced with our Instant VB
C# to VB.NET converter) is the equivalent in VB 2002/2003 - not very pretty
with the goto but it is the equivalent:

For i As Integer = 0 To 9
If i=7 Then
GoTo Continue1
End If
...
Continue1:
Next i

--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
 
David Dvali said:
What is loop continue in VB?
Loke in C#:
for (int i=0; i<10; i++)
{
if (i==7)
continue;
...
}

Could be something like the following (w/o goto's involved), other than that
(and w/o goto's) there isn't much of an equivalent to C's continue.

for (int i = 0; i < 10; i++) {
if (i != 7) {
... code to run when not continuing.
}
}

Basically, instead of continue, you'd have to rewrite your logic to just not
run the code if the condition is not met...

Mythran
 
Hi David

There is no equivalent. Continue is unstructured, so you need to alter the
logic to be structured, for example

For i As Integer = 0 To 9
If i <>7 Then
...
End If
Next i

HTH

Charles
 
Continue is considered structured. It has a very specific meaning - jump to
the end of the loop and follow the instruction there. If there is a "GO" in
the middle, do not pass it and do not collect $200.

Mike Ober.
 
Back
Top