vb.NET Missing a 'continue' statement in while loop?

P

PagCal

Is this language missing the functionality of a C/C++ 'continue' statement?

For example:

While NOT isEof()
If condition
' a C or C++ continue would work here
' but we are forced to use a GoTo
GoTo nxt
End If
... more statements here ...
nxt:
End While

You CAN rewrite the code to get rid of the GoTo by adding an 'else' to
the If, but code complexity increases as you're nesting more code in
conditionals.
 
H

Herfried K. Wagner [MVP]

* PagCal said:
Is this language missing the functionality of a C/C++ 'continue' statement?

Up to version 2003, yes. In 2005, we will have 'Continue' and 'Continue
<type of loop>' too.
 
J

Jeff Johnson [MVP: VB]

statement?

Up to version 2003, yes. In 2005, we will have 'Continue' and 'Continue
<type of loop>' too.

Really? I hadn't noticed that. So if you're in a For...Next loop nested
inside a Do While loop you can use Continue Do to completely exit the For
and iterate the Do?
 
H

Herfried K. Wagner [MVP]

Jeff,

* "Jeff Johnson said:
Really? I hadn't noticed that. So if you're in a For...Next loop nested
inside a Do While loop you can use Continue Do to completely exit the For
and iterate the Do?

Yes :).
 
T

Tom Spink

It appears so... which gives us the 'edge'

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
 
T

The Grim Reaper

Having managed to completely avoid C and C++ (and C#) for nearly 11 years of
programming now.... can someone explain a bit more about the Continue
statement?? From this thread I just gathered it did the same as Exit
For??!!
____________________________
The Grim Reaper
 
T

Tom Spink

Ever read Reaper Man? Fantastic story....

The Continue statement does not exit the for loop, it moves directly to the
next statement:

For I As Integer = 1 To 10
If I < 5 Then Continue For
MsgBox(I.ToString())
Next I

While the value of I is less than 5, the execution will jump to 'Next I'
bypassing all after it. When I is greater than or equal to 5, Continue For
will not be called, so execution will occurr as normal.

This also applies to a For Each statement:

For Each strString As String In SomeStringArray
If strString = "SomeValue" Then Continue For
MsgBox(strString)
Next


--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
 
C

Cor Ligthert

Hi Grim, have you ever used the Cobol Alter statement, for me it is
something like that.

I read that we can be glad to get that kind of behaviour back.

:-(

Cor
 
H

Herfried K. Wagner [MVP]

* "Tom Spink said:
The Continue statement does not exit the for loop, it moves directly to the
next statement:

For I As Integer = 1 To 10
If I < 5 Then Continue For
MsgBox(I.ToString())
Next I

ACK. As mentioned before, you can jump to the next outer loop too:

\\\
Do While...
For...To...
If...Then Continue Do
Next...
Loop
///
 
S

Stephany Young

Noooooooooooooooooooooooooooooooooooooo

Not the dreaded ALTER GOTO

Had to use that once to save 8 bytes of core memory :)
 
C

Chris Dunaway

Noooooooooooooooooooooooooooooooooooooo

Not the dreaded ALTER GOTO

Had to use that once to save 8 bytes of core memory :)

I remember learning COBOL in college, but I have never looked at it since.
(Thank Goodness!)

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
T

Tom Spink

I remember learning Prolog in College :: shudder ::

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
Chris Dunaway said:
Noooooooooooooooooooooooooooooooooooooo

Not the dreaded ALTER GOTO

Had to use that once to save 8 bytes of core memory :)

I remember learning COBOL in college, but I have never looked at it since.
(Thank Goodness!)

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
T

The Grim Reaper

Ahhh..... gotcha!! Sounds very useful.

I prefer Mort and Pyramids personally - but then I think they're all
fantastic :D
_______________________________
The Grimy Reaper
 
T

The Grim Reaper

My history.... (hold your breath....)

Commodore 64 Basic (can't even remember what it was called!!)
BBC Basic (again.. vague recollection...)
QBasic
AmigaBasic
BlitzBasic
Back to QBasic
VB6
VB.NET

I'm somehow managed to completely avoid C, C++ and C#, while learning god
knows how many ladder logic languages, Spanish and the Speak Of Woman.
Although still not fluent in that one.
_______________________________
The Grim Reaper

Tom Spink said:
I remember learning Prolog in College :: shudder ::

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
Chris Dunaway said:
Noooooooooooooooooooooooooooooooooooooo

Not the dreaded ALTER GOTO

Had to use that once to save 8 bytes of core memory :)


Hi Grim, have you ever used the Cobol Alter statement, for me it is
something like that.

I remember learning COBOL in college, but I have never looked at it since.
(Thank Goodness!)

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
C

Cablewizard

lol. My history is very similar.
Only replace BlitzBasic with Assembly, ANSI C, then insert VB3, 4, and 5
(although not sure it officially made it out of Beta).
VIC 20 Basic
PET Basic / CPM
Commodore 64/128 Basic
QBasic
AmigaBasic
Assembly
ANSI C
Fortran
MDL (MicroStation Development Language "C" like)
VB3, VB4, VB5, VB6 (Although I think VB5 barely made it out of Beta)
MBE MicroStation Basic
VB.Net + C# only when VB won't do something I need.

Somehow I have managed to get by without ever having to learn C++, or Java.

Gerald

The Grim Reaper said:
My history.... (hold your breath....)

Commodore 64 Basic (can't even remember what it was called!!)
BBC Basic (again.. vague recollection...)
QBasic
AmigaBasic
BlitzBasic
Back to QBasic
VB6
VB.NET

I'm somehow managed to completely avoid C, C++ and C#, while learning god
knows how many ladder logic languages, Spanish and the Speak Of Woman.
Although still not fluent in that one.
_______________________________
The Grim Reaper

Tom Spink said:
I remember learning Prolog in College :: shudder ::

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
Chris Dunaway said:
On Sat, 10 Jul 2004 00:09:44 +1200, Stephany Young wrote:

Noooooooooooooooooooooooooooooooooooooo

Not the dreaded ALTER GOTO

Had to use that once to save 8 bytes of core memory :)


Hi Grim, have you ever used the Cobol Alter statement, for me it is
something like that.


I remember learning COBOL in college, but I have never looked at it since.
(Thank Goodness!)

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top