473,815 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

For Next iterations

Hi all,

Is there any 'trick' anyone knows to control a For Next to pass to the next
iteration in ASP VBScript? ..Similar to the 'continue' keyword of C and
C++?

Thanks in advance..

-BB
Jul 19 '05 #1
10 8321
Ah cool. That points me in the right direction...

Kinda makes me feel stupid .. but it works .. :-P

thanks

-BB
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.29...
Brian Burgess wrote on 29 jul 2003 in
microsoft.publi c.inetserver.as p.general:
Is there any 'trick' anyone knows to control a For Next to pass to the
next iteration in ASP VBScript? ..Similar to the 'continue' keyword
of C and C++?


For i=1 to 100
continue=false
' do things
if i=17 then continue=true
if not continue then
' do things
end if
Next

can be done simpler.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #2
Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript
group...

For Count = 1 to 5
Do
If Count = 3 Then Exit Do
MsgBox Count
Exit Do:Loop
Next

Cool eh? a Do Loop wrapper ..

-BB
"Brian Burgess" <bb********@hot mail.com> wrote in message
news:uj******** ******@tk2msftn gp13.phx.gbl...
Ah cool. That points me in the right direction...

Kinda makes me feel stupid .. but it works .. :-P

thanks

-BB
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.29...
Brian Burgess wrote on 29 jul 2003 in
microsoft.publi c.inetserver.as p.general:
Is there any 'trick' anyone knows to control a For Next to pass to the
next iteration in ASP VBScript? ..Similar to the 'continue' keyword
of C and C++?


For i=1 to 100
continue=false
' do things
if i=17 then continue=true
if not continue then
' do things
end if
Next

can be done simpler.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Jul 19 '05 #3
I'm sure I don't see the point. The following does exactly the same thing,
is easier to read and understand by others and is logical.

For Count = 1 to 5
If count <> 3 then
'blah blah blah -- can't use a Msgbox in ASP/VBScript
end if
Next
"Brian Burgess" <bb********@hot mail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript
group...

For Count = 1 to 5
Do
If Count = 3 Then Exit Do
MsgBox Count
Exit Do:Loop
Next

Cool eh? a Do Loop wrapper ..

-BB
"Brian Burgess" <bb********@hot mail.com> wrote in message
news:uj******** ******@tk2msftn gp13.phx.gbl...
Ah cool. That points me in the right direction...

Kinda makes me feel stupid .. but it works .. :-P

thanks

-BB
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.29...
Brian Burgess wrote on 29 jul 2003 in
microsoft.publi c.inetserver.as p.general:

> Is there any 'trick' anyone knows to control a For Next to pass to the > next iteration in ASP VBScript? ..Similar to the 'continue' keyword > of C and C++?
>

For i=1 to 100
continue=false
' do things
if i=17 then continue=true
if not continue then
' do things
end if
Next

can be done simpler.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)



Jul 19 '05 #4
Brian Burgess wrote on 29 jul 2003 in
microsoft.publi c.inetserver.as p.general:
Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript
group...

For Count = 1 to 5
Do
If Count = 3 Then Exit Do
MsgBox Count
Exit Do:Loop
Next

Cool eh? a Do Loop wrapper ..


Silly American word "cool", and wrong too:

If Count=1 the do-loop will trigger indefinitly,
outputting messageboxes galore,
never even reaching count=2

The "Exit do:" as a label is also nonsense,
"Exit do" does not even use/need a label.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #5
That's what I was thinking when I first saw it, but I think the colon is
being used as a statement separator.
as in

For Count = 1 to 5
Do
If Count=3 then Exit Do
MsgBox Count
Exit Do
Loop
Next

I think that's what they were going for.

Furthermore, what's wrong with "cool?" I also enjoy saying "sit on it" and
I'm not American.
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.29...
Brian Burgess wrote on 29 jul 2003 in
microsoft.publi c.inetserver.as p.general:
Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript
group...

For Count = 1 to 5
Do
If Count = 3 Then Exit Do
MsgBox Count
Exit Do:Loop
Next

Cool eh? a Do Loop wrapper ..


Silly American word "cool", and wrong too:

If Count=1 the do-loop will trigger indefinitly,
outputting messageboxes galore,
never even reaching count=2

The "Exit do:" as a label is also nonsense,
"Exit do" does not even use/need a label.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #6
In article <#D************ **@TK2MSFTNGP09 .phx.gbl>, sh*****@hotmail .com
says...
That's what I was thinking when I first saw it, but I think the colon is
being used as a statement separator.
as in

For Count = 1 to 5
Do
If Count=3 then Exit Do
MsgBox Count
Exit Do
Loop
Next

I think that's what they were going for.

Furthermore, what's wrong with "cool?" I also enjoy saying "sit on it" and
I'm not American.


As others have said, this will loop indefinitely, plus you should not
put a MsgBox command in ANY ASP code - EVER.

A better way might be (also as mentioned before)

For Count = 1 to 5
If Count <> 3 then
' Do something when Count is not 3
End If
Next

--

Remove NOT from email address to reply. AntiSpam in action.
Jul 19 '05 #7
well, pardon my silliness.. however, what I have shown is working
correctly. I dont think it is a label in this case.. in fact I dont
believe labels work at all in script, but not sure if I remember that
correctly anyway. Here I think the colon is interpreted as something like
a new line.
So in this case, the Do only executes once for each iteration of the For
loop no matter what, and the If clause telling it if it can exit earlier.

Anyway, I thought it was elegant.

Thanks for the help..

-BB

"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.29...
Brian Burgess wrote on 29 jul 2003 in
microsoft.publi c.inetserver.as p.general:
Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript
group...

For Count = 1 to 5
Do
If Count = 3 Then Exit Do
MsgBox Count
Exit Do:Loop
Next

Cool eh? a Do Loop wrapper ..


Silly American word "cool", and wrong too:

If Count=1 the do-loop will trigger indefinitly,
outputting messageboxes galore,
never even reaching count=2

The "Exit do:" as a label is also nonsense,
"Exit do" does not even use/need a label.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #8
I needed a way to immediately go to the next iteration of the For(based on
an If clause) without exiting the For altogether.

I have been able to use the MsgBox when the ASP writes out an HTML '/script'
element by the way .. wanna see?

-BB
"Tom B" <sh*****@hotmai l.com> wrote in message
news:O1******** ******@TK2MSFTN GP12.phx.gbl...
I'm sure I don't see the point. The following does exactly the same thing, is easier to read and understand by others and is logical.

For Count = 1 to 5
If count <> 3 then
'blah blah blah -- can't use a Msgbox in ASP/VBScript
end if
Next
"Brian Burgess" <bb********@hot mail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript
group...

For Count = 1 to 5
Do
If Count = 3 Then Exit Do
MsgBox Count
Exit Do:Loop
Next

Cool eh? a Do Loop wrapper ..

-BB
"Brian Burgess" <bb********@hot mail.com> wrote in message
news:uj******** ******@tk2msftn gp13.phx.gbl...
Ah cool. That points me in the right direction...

Kinda makes me feel stupid .. but it works .. :-P

thanks

-BB
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.29...
> Brian Burgess wrote on 29 jul 2003 in
> microsoft.publi c.inetserver.as p.general:
>
> > Is there any 'trick' anyone knows to control a For Next to pass to the > > next iteration in ASP VBScript? ..Similar to the 'continue' keyword > > of C and C++?
> >
>
> For i=1 to 100
> continue=false
> ' do things
> if i=17 then continue=true
> if not continue then
> ' do things
> end if
> Next
>
> can be done simpler.
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)



Jul 19 '05 #9
I have shown in a previous message how/why this is working. But I have a
question concerning MsgBox. In this case it is only demo code of course,
but I do have some code that makes an HTML '/script' element which in turn
uses MsgBox. Is this bad as well? And if so, why?

Thanks..

-BB
"Dan Brussee" <db******@NOTbe tterwaycomputin g.com> wrote in message
news:MP******** *************** *@news-server.nc.rr.co m...
In article <#D************ **@TK2MSFTNGP09 .phx.gbl>, sh*****@hotmail .com
says...
That's what I was thinking when I first saw it, but I think the colon is
being used as a statement separator.
as in

For Count = 1 to 5
Do
If Count=3 then Exit Do
MsgBox Count
Exit Do
Loop
Next

I think that's what they were going for.

Furthermore, what's wrong with "cool?" I also enjoy saying "sit on it" and I'm not American.


As others have said, this will loop indefinitely, plus you should not
put a MsgBox command in ANY ASP code - EVER.

A better way might be (also as mentioned before)

For Count = 1 to 5
If Count <> 3 then
' Do something when Count is not 3
End If
Next

--

Remove NOT from email address to reply. AntiSpam in action.

Jul 19 '05 #10

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

Similar topics

11
7319
by: Derek Basch | last post by:
Is there a better way to count iterations that this?: pets = 0 for i in pets: pets += 1 print "pet" + "#" + pets Thanks, Derek Basch
2
2771
by: Steve Taylor | last post by:
Is there some reason why I shouldn't be able to use the same XPathExpression simultaneously in multiple iterations? The test below illustrates the problem. It seems that creating two XPathNodeIterators with the same expression creates a coupling between the iterators so they always point to the same position. Anyone care to comment? public void ReuseCompiledExpr() { XmlDocument doc = new XmlDocument();
23
22018
by: Mitchell Vincent | last post by:
Is there any way to "skip" iterations in a for loop? Example : for x = 1 to 10 if something = 1 next endif
8
2845
by: jvb | last post by:
Hey all, I figure it's Wednesday, why not put a question up for debate. Beyond personal preference, is there any benefit (performance or otherwise) to using one loop over the other? For example, I remember in hearing in class (many years ago...) that VB compiles For...Next loops as Do...While loops.
7
6734
by: kathy | last post by:
I have code: std::string s(1,'A'); for(int i=0;i<26;i++) { s = s{0] + 1; } what I expect is get A,B,C...Z. But I only got A,C,E,...
18
3718
by: Derek Basch | last post by:
What is the best way to count nested loop iterations? I can only figure to use an index but that seems kludgy. index = 0 for animal in zoo: for color in animal: index += 1 Thanks, Derek Basch
27
31474
by: Deephay | last post by:
Greetings all, I have a program that used the realloc() function to change the allocated size of a buffer, the program works with some arguments, but with some other arguments, it will show me the error message like: *** glibc detected *** realloc(): invalid next size: 0x0804c3a8 *** and then I inserted a perror("realloc") to see what happend, it says that:
2
1284
by: Francogrex | last post by:
Hi again, with a new question (beginner have a lot to learn). I am doing an updating algorithm where I have to do 10 iterations and each time need to replace the values of the matrix theta by the new estimated thetaNew matrix, but it doesn't seem to be working, there is no interative replacement, the values should end up being 0.6971233 0.09863044 0.1357830 0.06846318
2
19319
ADezii
by: ADezii | last post by:
If you are executing a code segment for a fixed number of iterations, always use a For...Next Loop instead of a Do...Loop, since it is significantly faster. Each pass through a Do...Loop that iterates a specified number of times, requires you to also implement or decrement some sort of Loop Counter, while a For...Next Loop does that work for you. Both Loops will provide the same results, but the For...Next Loop is substantially faster. One...
0
10673
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10408
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10147
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9227
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7689
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6899
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5712
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3889
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3032
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.