For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > November 2005 > how wud i break while loop on some condition









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how wud i break while loop on some condition
smart.bug@gmail.com

2005-11-29, 7:55 am

guys i have a inifint while loop
i.e. while 1
'statements
'statements
'statements

end while

if i want to break this loop on some condition ... how wud i do that...
i juz wana ask the statement for terminating a while loop (not do
while,,, only while)
thnx

Larry Lard

2005-11-29, 7:55 am


smart.bug@gmail.com wrote:
> guys i have a inifint while loop
> i.e. while 1
> 'statements
> 'statements
> 'statements
>
> end while
>
> if i want to break this loop on some condition ... how wud i do that...
> i juz wana ask the statement for terminating a while loop (not do
> while,,, only while)


There isn't one. The only things you can Exit from using Exit are Do,
For, Function, Property, Sub. Which is one of the reasons the
documentation says

> Tip The Do...Loop statement provides a more structured and flexible way to perform looping.


--
Larry Lard
Replies to group please

Ralph

2005-11-29, 7:55 am


<smart.bug@gmail.com> wrote in message
news:1133266006.069169.150180@f14g2000cwb.googlegroups.com...
> guys i have a inifint while loop
> i.e. while 1
> 'statements
> 'statements
> 'statements
>
> end while
>
> if i want to break this loop on some condition ... how wud i do that...
> i juz wana ask the statement for terminating a while loop (not do
> while,,, only while)
> thnx
>


Dim lCnt As Long
For idx = 0 To 0 Step 0
lCnt = lCnt + 1
If lCnt = 100 Then
Exit For
End If
Next


Ralph

2005-11-29, 7:55 am

Another variation ....

Dim lCnt As Long
For idx = 0 To 0 Step 0
lCnt = lCnt + 1
If lCnt = 100 Then idx = 1
Next

(I don't recommend this version as it will usually the poor
maintainer. <g> )

-ralph


JLuis Estrada

2005-11-29, 6:55 pm

do while 1
statements
statements
if condition then exit do
loop
<smart.bug@gmail.com> escribió en el mensaje
news:1133266006.069169.150180@f14g2000cwb.googlegroups.com...
> guys i have a inifint while loop
> i.e. while 1
> 'statements
> 'statements
> 'statements
>
> end while
>
> if i want to break this loop on some condition ... how wud i do that...
> i juz wana ask the statement for terminating a while loop (not do
> while,,, only while)
> thnx
>



Bob Butler

2005-11-29, 6:55 pm

<smart.bug@gmail.com> wrote in message
news:1133266006.069169.150180@f14g2000cwb.googlegroups.com
> guys i have a inifint while loop
> i.e. while 1
> 'statements
> 'statements
> 'statements
>
> end while


End While? End While is not a valid VB statement... if you mean WEND then

bLoop=True
While bLoop
'....
If exitcondition then bLoop=False
Wend

If you really do mean 'End While' then you ar ein the wrong place


--
<response type="generic" language="VB.Net">
This newsgroup is for users of Visual Basic version 6.0
and earlier and not the misleadingly named VB.Net
or VB 200x. Solutions, and often even the questions,
for one platform will be meaningless in the other.
When VB.Net was released Microsoft created new newsgroups
devoted to the new platform so that neither group of
developers need wade through the clutter of unrelated
topics. Look for newsgroups with the words "dotnet" or
"vsnet" in their name. For the msnews.microsoft.com news
server try these:

microsoft.public.dotnet.general
microsoft.public.dotnet.languages.vb

</response>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com