How to end a while-loop?

Perigon

Junior member
Messages
17
Likes
0
Hi guys!

I want to end an while-loop if my condition is no longer met (for exampel if C < C[1]).
I tried this:

While cond = true Begin
If conditioncode....
Else cond = false;
End;

I think this should stop it? I even tried with numbers if that's the prob (true = 1 and false = 0) but it made no difference.

Is there a command to quit the loop earlier, like a return() as in other languages?

Thanks in advance!
/Johan
 
In VB/VBA the structure is . . . .

X = 0

While X < 10

X = X + 1

Wend

Note that X = 10 after coming out of the loop
 
Could you perhaps post a code sample to illustrate the problem. The code outline you posted earlier looks fine.
 
Perigon said:
Hi guys!

I want to end an while-loop if my condition is no longer met (for exampel if C < C[1]).
I tried this:

While cond = true Begin
If conditioncode....
Else cond = false;
End;

I think this should stop it? I even tried with numbers if that's the prob (true = 1 and false = 0) but it made no difference.

Is there a command to quit the loop earlier, like a return() as in other languages?

Thanks in advance!
/Johan

You can start by telling what language it is :LOL:
In some languages you have to use == for conditions and = for assignments or = for conditions and := for assignments etc.
 
I may have misunderstood your intention about exiting a while loop. Are you trying to exit the loop before the end of the loop block?
 
Exactly 3tuple, if my conditions are not met i want to exit the loop. But i solved it, using numbers insted. If my condition is not met i set the counter (replaced the cond-variable) to the stopvalue,, i.e:

While ii < 15 Begin;

... Else ii = 15;

End;


And then it stopped ;-P
Thanks anyway guys!
 
Top