basic language question

zeroGrav

Member
Joined
Jan 1, 2003
Messages
8
In a do loop how do I skip to the next iteration?

In java, theres the continue keyword...

If theres no continue for a do loop what about while loops or for loops?

My book really doesnt tell me anything related to this...

Thanks.
 
I suppose the best way would be to use a Boolean.

Code:
Do While MyCondition = True
  Dim continue As Boolean

  In C#, this would look like [b]if (This == "That") continue;[/b]
  If This = "That" Then continue = True

  This part skips all the code after the continue line, if necessary
  If Not continue Then You did not choose to go to the next iteration
    Nested continues should work as well.
    C#: if (Equation = (4+3/5)^4) continue;
    If Equation = (4+3/5)^4 Then continue = True
    If Not continue Then
      Once again, you didnt choose to go to the next iteration
    End If
  End If
Loop
I dont know if this is a total reproduction of the behaviour of
continue, nor have I tested it, but it should work. :-\ Best you can
do is give it a shot.
 
That or use a goto statement to jump to the end, just before the loop statement. And before you say it, what do you think a continue statement does? :)
 
Heh, this is about coding standards, not the way it eventually turns
out after its compiled. :p
 
fact is, guys, that vb .NET _lacks_ a continue statement. Thats a shame ,though, because it vb.net is a great language overall. Some may say nothing is perfect...
 
I cant remember thinking that I needed a continue statement since my quickbasic days. I guess you just to not using them. I dont think any MS BASIC language has ever had one. Theyre not very structured anyway :)
 
They are useful in some situations, but I havent had the need for one in years. When I did (in VB6), I used an "If...Then" as VolteFace showed in his first example.

Youre right, its a shame they didnt include something seemingly so simple in VB.NET. But then, C# and VB.NET are different languages...

-Nerseus
 
Back
Top