PC Review


Reply
Thread Tools Rate Thread

"continue" key word equivalent in VB

 
 
Daniel Bass
Guest
Posts: n/a
 
      11th Aug 2003
is there an equivalent key word for C++'s "continue" in VB (.net) in this
context?


CString szLine;
szLine = myReader.ReadLine();
while ( !szLine.IsEmpty() )
{
if ( szLine(0) == '-' )
{
szLine = myReader.ReadLine();
continue; // <-- HERE, so if szLine starts with "-" then
// the rest of this loop is not executed this
time round...
}

szLine = myReader.ReadLine();

//
// rest of the loop code
//

}


thanks!
Daniel.


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      11th Aug 2003
Hello,

"Daniel Bass" <(E-Mail Removed)> schrieb:
> is there an equivalent key word for C++'s "continue"
> in VB (.net) in this context?


No.

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      11th Aug 2003
Herfried,
Are you sure is it in that equivalent not something as exit while loop
But when you say so .................................................
Cor


 
Reply With Quote
 
Brian Henry
Guest
Posts: n/a
 
      11th Aug 2003
try useing break to drop out of the loop


"Daniel Bass" <(E-Mail Removed)> wrote in message
news:uuOj2%(E-Mail Removed)...
> is there an equivalent key word for C++'s "continue" in VB (.net) in this
> context?
>
>
> CString szLine;
> szLine = myReader.ReadLine();
> while ( !szLine.IsEmpty() )
> {
> if ( szLine(0) == '-' )
> {
> szLine = myReader.ReadLine();
> continue; // <-- HERE, so if szLine starts with "-" then
> // the rest of this loop is not executed this
> time round...
> }
>
> szLine = myReader.ReadLine();
>
> //
> // rest of the loop code
> //
>
> }
>
>
> thanks!
> Daniel.
>
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      11th Aug 2003
Hello,

"Brian Henry" <(E-Mail Removed)> schrieb:
> try useing break to drop out of the loop


In VB .NET?!

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      12th Aug 2003
Daniel,
The closest you will come to a Continue in VB.NET is to use the Goto
keyword.

Something like:
szLine = myReader.ReadLine()
Do Until szLine Is Nothing
If szLine.Chars(0) = "-"c Then
szLine = myReader.ReadLine()
GoTo continue
End If
szLine = myReader.ReadLine()
If szLine is Nothing Then Exit Do
'
' rest of the loop code
'
continue:
Loop

Personally I would put a single ReadLine after the Continue, avoiding the
third ReadLine. Also I would consider having the 'rest of the loop code' in
the Else block of the If comment block. Or change the If comment to If Not
comment rest of loop code.

Hope this helps
Jay

"Daniel Bass" <(E-Mail Removed)> wrote in message
news:uuOj2%(E-Mail Removed)...
> is there an equivalent key word for C++'s "continue" in VB (.net) in this
> context?
>
>
> CString szLine;
> szLine = myReader.ReadLine();
> while ( !szLine.IsEmpty() )
> {
> if ( szLine(0) == '-' )
> {
> szLine = myReader.ReadLine();
> continue; // <-- HERE, so if szLine starts with "-" then
> // the rest of this loop is not executed this
> time round...
> }
>
> szLine = myReader.ReadLine();
>
> //
> // rest of the loop code
> //
>
> }
>
>
> thanks!
> Daniel.
>
>



 
Reply With Quote
 
Adam Hart
Guest
Posts: n/a
 
      12th Aug 2003
> is there an equivalent key word for C++'s "continue" in VB (.net) in this
> context?


There's always another way of writing it - how about instead of trying to =
'-', you test not equals to '-'

eg
while(not empty)
{
if(last char != '-')
{
rest of code in here
}
}

reads better too i think


 
Reply With Quote
 
Daniel Bass
Guest
Posts: n/a
 
      12th Aug 2003
> There's always another way of writing it - how about instead of trying to
=
> '-', you test not equals to '-'
>
> eg
> while(not empty)
> {
> if(last char != '-')
> {
> rest of code in here
> }
> }
>
> reads better too i think


I'm afraid I have to disagree, nested parenthesis (or begin/end's in a VB
case) isn't that pleasing to the eye...

if your reading through the code, seeing a continue near the start signifies
a conditional loop, but seeing two sets of begin/end's can get confusing
when you're looking at something like

function ...()
{
while m_bWhatever
{
if ( my condition is true )
{
... code here ...
}
}
}

the last }'s can get confusing, especially in large multilevel functions.

it's all about preference I guess! ;o)

Thanks for your comment.


 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      12th Aug 2003
Jay,
Sorry, but this is terrible, all the work of Dijkstra (he died last year) is
done with what you wrote (while your examples are normaly so good).
szLine = myReader.ReadLine()
Do Until szLine Is Nothing
If szLine.Chars(0) = "-"c Then
szLine = myReader.ReadLine()
' GoTo continue /// removed
' End If /// removed
Else ' that is all Cor inserted
szLine = myReader.ReadLine()
If szLine is Nothing Then Exit Do
'
' rest of the loop code
'
' continue: ////removed
Loop
In C you have to keep track of the {} of course therefore escaping is very
easy.
That is exactly the same without using low level coding.
Cor


 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      12th Aug 2003
Adam,
Sorry, I Did not see so fast your messag that was the same as mine
Cor



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I open the Word equivalent of WordPerfect's "reveal codes" KevinCSullivan Microsoft Word New Users 2 30th Nov 2009 01:58 PM
Is there an Excel 2003 equivalent to Word's "versions" function? =?Utf-8?B?U3RldmU=?= Microsoft Excel Misc 0 4th Mar 2007 02:01 AM
Change default in input box from "20" to "000000"? Have macro continue on to name sheet tab? StargateFanFromWork Microsoft Excel Programming 8 30th Oct 2006 07:26 PM
Deleted documents continue to appear in Word "Open" menu. =?Utf-8?B?U2huZXVy?= Microsoft Word New Users 4 20th Mar 2005 10:37 AM
"continue" key word equivalent in VB Daniel Bass Microsoft VC .NET 14 13th Aug 2003 03:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:18 AM.