Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Basic Question (but still, I can't find the answer)


Reply
 
Thread Tools Display Modes
  #1  
Old 05-23-2005, 07:58 AM
Riceman's Avatar
Riceman Riceman is offline
Centurion
 
Join Date: Mar 2005
Posts: 183
Question Basic Question (but still, I can't find the answer)


I'd like to know if there is an equivalent in VB for the "Continue" C function.

Like "Break" in C could be Exit For. For those who don't know C, Continue is a function I can call inside a For statement and it will force to the next count in the loop (and not break out of it).

Can't do "count = count +1", it has to restart the loop in the next count.

EDIT: Looking for a solution without using GoTo.

Last edited by Riceman; 05-23-2005 at 08:10 AM.
Reply With Quote
  #2  
Old 05-23-2005, 08:17 AM
Diurnal Diurnal is offline
Enthusiast

Retired Leader
* Expert *
 
Join Date: Apr 2002
Location: Bellevue, WA.
Posts: 3,233
Default

Can't you just place a conditional check inside your loop? If the condition is not met then just go on, etc... Maybe I am not understanding and making this too simple?
Code:
Dim i As Long Dim bDoSomething As Boolean For i = 0 To 99 If bDoSomething Then 'Do something here.. Else 'Just continue the loop... End If Next i
Reply With Quote
  #3  
Old 05-23-2005, 09:30 AM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

There is no continue in VB... you'll have to do as Diurnal suggests.
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #4  
Old 05-23-2005, 05:58 PM
snarfblam's Avatar
snarfblam snarfblam is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Apr 2005
Location: USA
Posts: 866
Default

Sometimes it might not be obvious, but there is usually a "kosher structured programming" equivalent to any other control flow mechanism. Gotos, continues, breaks, exit fors, things like these can almost always be avoided (not that this is necessarily the easiest or best way to do it, but if you find yourself in a language that does not have the program flow elements you need, it can be useful).

Why not use GoTo? If you can't then Diurnal's solution will probably have to suffice.
Reply With Quote
  #5  
Old 05-23-2005, 06:49 PM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss

* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
Default

Sounds to me like a job for GoTo.. usualy a GoTo in a loop forces the compiler to optimize a little more poorly, however.
Reply With Quote
  #6  
Old 05-23-2005, 08:17 PM
Cyroxis's Avatar
Cyroxis Cyroxis is offline
Junior Contributor
 
Join Date: Dec 2003
Location: USA in New Mexico
Posts: 374
Default

GoTo's are not in themsleves evil. Many people make them out to be evil and poor coding practice because many people use them sloppally. However they are a very powerfull tool when used in the right place.
__________________
For those who count in knots, 2 + 2 = 5
Reply With Quote
  #7  
Old 05-25-2005, 01:19 AM
Riceman's Avatar
Riceman Riceman is offline
Centurion
 
Join Date: Mar 2005
Posts: 183
Thumbs up

Diurnal's one was my first solution just before I posted the question. But I always want to learn more. So I posted this just for discussing the matter and raising different solutions. I always want to improve myself, and one does not do that all alone, but by exchanging experience with other people. That's what, in my opinion, a forum is about.

Thanks for the suggestions, I can already see that I won't be able to escape from some GoTo's in VB.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->