473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

"continue" key word equivalent in VB

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.
Nov 16 '05 #1
14 3601
Hello,

"Daniel Bass" <da********@NOSPAMpostmaster.co.uk> 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
Nov 16 '05 #2
Cor
Herfried,
Are you sure is it in that equivalent not something as exit while loop
But when you say so .................................................
Cor
Nov 16 '05 #3
try useing break to drop out of the loop
"Daniel Bass" <da********@NOSPAMpostmaster.co.uk> wrote in message
news:uu****************@TK2MSFTNGP12.phx.gbl...
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.

Nov 16 '05 #4
Hello,

"Brian Henry" <br******@adelphia.net> 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
Nov 16 '05 #5
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" <da********@NOSPAMpostmaster.co.uk> wrote in message
news:uu****************@TK2MSFTNGP12.phx.gbl...
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.

Nov 16 '05 #6
> 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
Nov 16 '05 #7
> 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.
Nov 16 '05 #8
Cor
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
Nov 16 '05 #9
Cor
Adam,
Sorry, I Did not see so fast your messag that was the same as mine
Cor

Nov 16 '05 #10
Hello Daniel,

"Daniel Bass" <da********@NOSPAMpostmaster.co.uk> schrieb:
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.


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

;-)))

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 16 '05 #11
Hello Cor,

"Cor" <no*@non.com> schrieb:
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.


Mhmmm. I love GoTo.

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 16 '05 #12
Cor,
I was only demonstrating the continue.

The obscure last paragraph stated what I would actually do.
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.
As having the 'rest of the loop code in the else block' would avoid the
goto altogether. I should have added "And avoid the goto altogether".

However there are some loops used for parsing where you need the Goto, no
clean way around it. This example is simply to simple to demonstrate it.
There are ways to avoid these Goto/Continue statements however then you
start introducing intricate control variables with strange nested ifs, whose
only purpose is to avoid the goto. Where a single goto would avoid it.

Thanks for clarifying.

Jay
"Cor" <no*@non.com> wrote in message
news:3f***********************@reader21.wxs.nl... 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

Nov 16 '05 #13
Cor wrote:

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).


Dijkstra had a point but his generalization was about as valuable as
most (which is, often but not universally). I believe there have been
studies which have shown that flow control in loops is a valuable use
of goto -- it can produce cleaner and more maintainable code.

And let's be honest -- there are language features (most notably the
various "exit" statements) that are thinly disguised gotos.

--
Craig Powers
MVP - Visual C++
Nov 16 '05 #14
Daniel Bass wrote:

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
//

}


I think this loop can probably be better cast.

My thought...

CString szLine;

do {
szLine = myReader.ReadLine();

while (!szLine.IsEmpty() && szLine(0) == '-')
szLine = myReader.ReadLine();

if (szLine.IsEmpty()) break;

// etc.
} while (! szLine.IsEmpty() );

Except that this isn't exactly the same -- do you really intend to
unconditionally discard the first line you read? That looks suspicious,
but it can be easily remedied with an initial ReadLine call outside
the loop.

--
Craig Powers
MVP - Visual C++
Nov 16 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harman Sahni | last post by:
As per this URL http://msdn.microsoft.com/library/en-us/vjref98/html/14_14.asp?frame=true conitnue works on for, while, do... I know it works for foreach as well as I'm using it somewhere. My...
2
by: Paul Johnston | last post by:
I'm using VB.Net. I've tried using Console.Read() but it requires a line-terminator before it finishes (doesn't that mean it's functionally equivalent to ReadLine() -- why have it then?). I've...
14
by: Daniel Bass | last post by:
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) == '-' ) {
13
by: xz | last post by:
What if I want the following: vector<intv; // v is loaded by push_back() switch( v.size() ) { case 2: //do something
36
by: mdh | last post by:
May I ask the group this somewhat non-focused question....having now seen "continue" used in some of the solutions I have worked on. ( Ex 7-4 solution by Tondo and Gimpel comes to mind) Is there a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.