Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exit Do

77 views
Skip to first unread message

Jorge Santos

unread,
Apr 12, 2002, 1:07:42 PM4/12/02
to
Hi all,


I though that the exit statement could be used
to exit from within a loop. Even the docs say so. However given the following code:
x=1
while x<10
response.write x
if x=5 then
exit do
end if
x=x+1
wend

I'm getting:
Microsoft VBScript compilation error '800a040f'
Invalid 'exit' statement
/itron/specials.asp, line 204
Exit Do
-----^


Any ideas?
Thanks,
Jorge

jim_w

unread,
Apr 12, 2002, 1:45:49 PM4/12/02
to
hi Jorge,

Your best bet may be to just not "fight-the-problem" and rewrite the loop as
a do-loop.

x=1
Do le x<10


response.write x
if x=5 then
exit do
end if
x=x+1

Loop


cheers, jw


"Jorge Santos" <san...@traxxinc.net> wrote in message
news:cae54c12.02041...@posting.google.com...

jim_w

unread,
Apr 12, 2002, 1:51:56 PM4/12/02
to
Er, sorry fumble fingers took over there, make that:

> Do WHILE x<10

time get off here, and goto lunch, jw

"jim_w" <jwarrington*noSteekin*@*Spam*worldnet.att.net> wrote in message
news:u7qSPkk4BHA.1864@tkmsftngp04...

Joseph Acosta

unread,
Apr 12, 2002, 1:47:30 PM4/12/02
to
Exit Do is for Do While or Do Until loops. The code below is a While Wend
loop, which doesn't support Exit Do.

You could use a do while loop with your code as follows:

x=1
Do while x < 10
response.write x
If x = 5 then


exit do
end if
x = x + 1

Loop

"Jorge Santos" <san...@traxxinc.net> wrote in message
news:cae54c12.02041...@posting.google.com...

Raymond D'Anjou

unread,
Apr 12, 2002, 1:51:34 PM4/12/02
to
Or you can keep the while loop:

x=1
while x<10
response.write x

if x=5 then
x=10
else
x=x+1
end if
wend

"Joseph Acosta" <jac...@san.rr.com> wrote in message
news:eF90fok4BHA.1288@tkmsftngp07...

Jorge Santos

unread,
Apr 12, 2002, 1:59:36 PM4/12/02
to
Thanks all.

I was aware of the Do While .. Loop and Do .. Loop Until but wan't aware
that Exit Do is only for Do loops (never get the obvious...).

Thanks again.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

0 new messages