|
-
May 2nd, 2006, 10:59 AM
#1
Thread Starter
Member
[RESOLVED] While Loop Problem
I have a pretty simple while loop:
VB Code:
While (UBound(LUpper) > 1) And (Cross_product(LUpper(UBound(LUpper) - 2), LUpper(UBound(LUpper) - 1), LUpper(UBound(LUpper))) >= 0)
Delete_Element LUpper, UBound(LUpper) - 1
Wend
Problem is if a situation arises where Ubound(LUpper) = 1. Rather than moving on as the first paramater of the while loop fails, vb still tries to evaluate the parameters of cross_product function, and in the case of Ubound(LUpper) = 1 the first parameter is subscript out of range.
Is there a way to stop vb evaluating parameters despite the fact their state isn't relevant, or is there another way around forming a while loop to acheive my goal?
Im quite stressed atm so sorry if the solution is obvious, not thinking str8 
thanks in advance!
-
May 2nd, 2006, 11:07 AM
#2
Hyperactive Member
Re: While Loop Problem
Since there's no short-circut evaluation in VB, you might just have to have two exit points from the loop. Something like:
VB Code:
Do While (UBound(LUpper) > 1)
If (Cross_product(LUpper(UBound(LUpper) - 2), LUpper(UBound(LUpper) - 1), LUpper(UBound(LUpper))) >= 0) Then
Exit Do
End If
Delete_Element LUpper, UBound(LUpper) - 1
Loop
-
May 2nd, 2006, 12:31 PM
#3
Thread Starter
Member
Re: While Loop Problem
Ah thats a alternative solution, many thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|