PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
I miss loop
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
I miss loop
![]() |
I miss loop |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
When I'm inside a do while loop sometimes it's necessary to jump out of
the loop using exit do. I'm also used to being able to jump back and begin the loop again. Not sure which language my memories are of but I think I just said loop somewhere inside the loop and it immediately jumped back to the start of the loop and began again. I can't seem to do that in .net. I this functionality available? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
"cj" <cj@nospam.nospam> wrote in message news:ex3Rt36RGHA.1572@tk2msftngp13.phx.gbl... > When I'm inside a do while loop sometimes it's necessary to jump out of > the loop using exit do. I'm also used to being able to jump back and > begin the loop again. Not sure which language my memories are of but I > think I just said loop somewhere inside the loop and it immediately jumped > back to the start of the loop and began again. I can't seem to do that in > .net. I this functionality available? I think in VB.Net 2005, you have the Continue statement, but I'm not sure. In C#, it's continue (if my memory serves correctly). HTH, Mythran |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Unfortunately I'm using VB.Net 2003 right now and continue doesn't
appear to do that in 2003. I believe continue does have that functionality in some language. Mythran wrote: > > "cj" <cj@nospam.nospam> wrote in message > news:ex3Rt36RGHA.1572@tk2msftngp13.phx.gbl... >> When I'm inside a do while loop sometimes it's necessary to jump out >> of the loop using exit do. I'm also used to being able to jump back >> and begin the loop again. Not sure which language my memories are of >> but I think I just said loop somewhere inside the loop and it >> immediately jumped back to the start of the loop and began again. I >> can't seem to do that in .net. I this functionality available? > > I think in VB.Net 2005, you have the Continue statement, but I'm not > sure. In C#, it's continue (if my memory serves correctly). > > HTH, > Mythran > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
"cj" <cj@nospam.nospam> schrieb:
> Unfortunately I'm using VB.Net 2003 right now and continue doesn't appear > to do that in 2003. I believe continue does have that functionality in > some language. You can still mimick the behavior of 'continue' using a named label and 'GoTo'... -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Whowa! Your sure to get blasted for that idea. I hope you aren't using
your real name. I just might do that though.Herfried K. Wagner [MVP] wrote: > "cj" <cj@nospam.nospam> schrieb: >> Unfortunately I'm using VB.Net 2003 right now and continue doesn't >> appear to do that in 2003. I believe continue does have that >> functionality in some language. > > You can still mimick the behavior of 'continue' using a named label and > 'GoTo'... > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
cj wrote:
> When I'm inside a do while loop sometimes it's necessary to jump out > of the loop using exit do. I'm also used to being able to jump back > and begin the loop again. Not sure which language my memories are of > but I think I just said loop somewhere inside the loop and it > immediately jumped back to the start of the loop and began again. I > can't seem to do that in .net. I this functionality available? The meaning of "continue" is to start the *next* iteration immediately and bypass any further code in the loop body. If you want to continue the current operation then you'd either have an inner loop or use a goto. If you want to completely restart the loop then you'd be best enclosing it in an outer loop. You mustn't use the goto idea for that one. Jumping out of the loop to before the loop - that should get you those frowns. ;o) |
|
|
|
#7 |
|
Guest
Posts: n/a
|
I understand the functionality of continue. I also understand it
doesn't work in VB.Net 2003, right? It does in 2005, right? I understand why goto is not generally a good thing but just because a command has been frequently misused in the past doesn't make it bad. I admire Herfried for suggesting goto. It seems like a perfect use. Still I'm having a hard time using it because other say it's wrong. It's a real conundrum. There has to be a way that socially acceptable and personally feels right. An outer loop is what I have started with because goto has been out of my vocabulary since 87. Still I just don't like seeing one loop inserted inside another just for this functionality. It looks funny and just seems wrong. I'll come up with a better way. Something in the nature subroutines and flags etc. I'll get something that feels better when I get back to work tomorrow. dotNuttah wrote: > cj wrote: >> When I'm inside a do while loop sometimes it's necessary to jump out >> of the loop using exit do. I'm also used to being able to jump back >> and begin the loop again. Not sure which language my memories are of >> but I think I just said loop somewhere inside the loop and it >> immediately jumped back to the start of the loop and began again. I >> can't seem to do that in .net. I this functionality available? > > The meaning of "continue" is to start the *next* iteration immediately and > bypass any further code in the loop body. If you want to continue the > current operation then you'd either have an inner loop or use a goto. If you > want to completely restart the loop then you'd be best enclosing it in an > outer loop. You mustn't use the goto idea for that one. Jumping out of the > loop to before the loop - that should get you those frowns. ;o) > > > |
|
|
|
#8 |
|
Guest
Posts: n/a
|
VB 6 doesn't have it either. What you see in VB 6 program is:
do if somecondition then ... ... end if loop In VB 2005 this would be do if not somecondition then continue ... ... loop It's awkward but it works. Also, it's interesting to note that the VB 2005 continue doesn't actually jump back to the start of the loop. It actually jumps to the end of the loop and lets the loop control jump back. Watch it in the debugger. Mike Ober. "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:%23ncLnG7RGHA.4956@TK2MSFTNGP09.phx.gbl... > "cj" <cj@nospam.nospam> schrieb: > > Unfortunately I'm using VB.Net 2003 right now and continue doesn't appear > > to do that in 2003. I believe continue does have that functionality in > > some language. > > You can still mimick the behavior of 'continue' using a named label and > 'GoTo'... > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > > |
|
|
|
#9 |
|
Guest
Posts: n/a
|
cj,
I don't agree with you and there is in my opinion enough written in this newsgroup about that. Can't you not use a Select Case. Probably makes that your program again much readable then. Cor "cj" <cj@nospam.nospam> schreef in bericht news:eiDGYQ9RGHA.1688@TK2MSFTNGP11.phx.gbl... >I understand the functionality of continue. I also understand it doesn't >work in VB.Net 2003, right? It does in 2005, right? > > I understand why goto is not generally a good thing but just because a > command has been frequently misused in the past doesn't make it bad. I > admire Herfried for suggesting goto. It seems like a perfect use. Still > I'm having a hard time using it because other say it's wrong. It's a real > conundrum. There has to be a way that socially acceptable and personally > feels right. > > An outer loop is what I have started with because goto has been out of my > vocabulary since 87. Still I just don't like seeing one loop inserted > inside another just for this functionality. It looks funny and just seems > wrong. I'll come up with a better way. Something in the nature > subroutines and flags etc. I'll get something that feels better when I > get back to work tomorrow. > > > dotNuttah wrote: >> cj wrote: >>> When I'm inside a do while loop sometimes it's necessary to jump out >>> of the loop using exit do. I'm also used to being able to jump back >>> and begin the loop again. Not sure which language my memories are of >>> but I think I just said loop somewhere inside the loop and it >>> immediately jumped back to the start of the loop and began again. I >>> can't seem to do that in .net. I this functionality available? >> >> The meaning of "continue" is to start the *next* iteration immediately >> and >> bypass any further code in the loop body. If you want to continue the >> current operation then you'd either have an inner loop or use a goto. If >> you >> want to completely restart the loop then you'd be best enclosing it in an >> outer loop. You mustn't use the goto idea for that one. Jumping out of >> the >> loop to before the loop - that should get you those frowns. ;o) >> >> |
|
|
|
#10 |
|
Guest
Posts: n/a
|
cj wrote:
> When I'm inside a do while loop sometimes it's necessary to jump out of > the loop using exit do. I'm also used to being able to jump back and > begin the loop again. Not sure which language my memories are of but I > think I just said loop somewhere inside the loop and it immediately > jumped back to the start of the loop and began again. I can't seem to > do that in .net. I this functionality available? Did you use Clipper(xBase) by any chance? There a loop contruction there like you describe it. I'm missing it too in VB. When porting some routines over from xBase++ I've run into this problem and had to rethink the logic.. too bad ![]() -- Rinze van Huizen C-Services Holland b.v |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

I just might do that though.
