 |
 |

05-23-2005, 07:58 AM
|
 |
Centurion
|
|
Join Date: Mar 2005
Posts: 183
|
|
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.
|

05-23-2005, 08:17 AM
|
|
Enthusiast
Retired Leader * Expert *
|
|
Join Date: Apr 2002
Location: Bellevue, WA.
Posts: 3,233
|
|
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
|
|

05-23-2005, 09:30 AM
|
 |
Keeper of foo
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
|
|
|
There is no continue in VB... you'll have to do as Diurnal suggests.
|
__________________
~ Quod non mortiferum, fortiorem me facit ~
Avatar by lebb
|

05-23-2005, 05:58 PM
|
 |
Senior Contributor
Forum Leader * Expert *
|
|
Join Date: Apr 2005
Location: USA
Posts: 866
|
|
|
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.
|
|

05-23-2005, 06:49 PM
|
 |
Joseph Koss
* Guru *
|
|
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
|
|
|
Sounds to me like a job for GoTo.. usualy a GoTo in a loop forces the compiler to optimize a little more poorly, however.
|
|

05-23-2005, 08:17 PM
|
 |
Junior Contributor
|
|
Join Date: Dec 2003
Location: USA in New Mexico
Posts: 374
|
|
|
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
|

05-25-2005, 01:19 AM
|
 |
Centurion
|
|
Join Date: Mar 2005
Posts: 183
|
|
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. 
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|