zeroGrav Posted January 2, 2003 Posted January 2, 2003 In a do loop how do I skip to the next iteration? In java, there's the 'continue' keyword... If there's no 'continue' for a do loop what about while loops or for loops? My book really doesn't tell me anything related to this... Thanks. Quote
*Experts* Volte Posted January 2, 2003 *Experts* Posted January 2, 2003 I suppose the best way would be to use a Boolean. 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 didn't choose to go to the next iteration End If End If LoopI don't 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. Quote
*Gurus* divil Posted January 2, 2003 *Gurus* Posted January 2, 2003 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? :) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Experts* Volte Posted January 2, 2003 *Experts* Posted January 2, 2003 So theoretically, my way is better than continue. ;) ;) Quote
*Gurus* divil Posted January 2, 2003 *Gurus* Posted January 2, 2003 Why, you think yours doesn't use one? ;) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Experts* Volte Posted January 2, 2003 *Experts* Posted January 2, 2003 Heh, this is about coding standards, not the way it eventually turns out after it's compiled. :p Quote
zeroGrav Posted January 3, 2003 Author Posted January 3, 2003 fact is, guys, that vb .NET _lacks_ a continue statement. That's a shame ,though, because it vb.net is a great language overall. Some may say nothing is perfect... Quote
*Gurus* divil Posted January 3, 2003 *Gurus* Posted January 3, 2003 I can't remember thinking that I needed a continue statement since my quickbasic days. I guess you just to not using them. I don't think any MS BASIC language has ever had one. They're not very structured anyway :) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Experts* Nerseus Posted January 3, 2003 *Experts* Posted January 3, 2003 They are useful in some situations, but I haven't had the need for one in years. When I did (in VB6), I used an "If...Then" as VolteFace showed in his first example. You're right, it's a shame they didn't include something seemingly so simple in VB.NET. But then, C# and VB.NET are different languages... -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.