![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | how to test a range of numbers I'm trying a test for below -10 and another test for 0 to -9.9 and a third for above. First and third test work corectly but I don't know how to test for the second, range values between 0 and -9.99. If SURFDIFF < -10 Then StaElev(10) = "BELOW" 'LABEL BELOW ' works End If 'how to you test a range between 0 and -9.99 If SURFDIFF < 0 and < -9.99 Then StaElev(10) = "BELOW WITHIN 10 FT" End If If SURFDIFF > 0 Then StaElev(10) = "ABOVE" 'GET LABEL ABOVE BELOW ' works End If Thank you John |
My System Specs![]() |
| | #2 (permalink) |
| | Re: how to test a range of numbers Well ... "between" means greater than some lower bound AND (hint!) less than some upper bound. But in programming, where the smallest details matter, you have to think about whether you want "greater than" or "greater than or equal to", and "less than" or "less than or equal to". The idiom I generally use, and I don't think there is much choice, is, for example, ... If (i >= -10) And (i <= 0) Then MsgBox("It's between -10 and 0") End If Although a better message in this case would be "It's greater than or equal to -10 and less than or equal to 0". (And I'm not sure if the parenthesizes in the If statement are necessary - but they don't hurt.) Also, think about the fact that if SURFDIFF is less than -10 then it can't also be greater than 0. So once your logic has determined that it is less than -10 it's a waste of the computer's precious time to see if it's also greater than 0. See if you can't structure your code so that it avoids the greater-than-0 test when SURFDIFF has already been determined to be less than -10. (You'll need to use the Else part of the If-Then-Else statement.) Failure to do this might lower your grade on this assignment by one letter grade. Good Luck, Bob "jcoon" <jcoonnh@xxxxxx> wrote in message news:%2330iWZ7FKHA.1340@xxxxxx Quote: > I'm trying a test for below -10 and another test for 0 to -9.9 and a third > for above. > First and third test work corectly but I don't know how to test for the > second, range values between 0 and -9.99. > > If SURFDIFF < -10 Then > StaElev(10) = "BELOW" 'LABEL BELOW ' works > End If > > 'how to you test a range between 0 and -9.99 > If SURFDIFF < 0 and < -9.99 Then > StaElev(10) = "BELOW WITHIN 10 FT" > End If > > If SURFDIFF > 0 Then > StaElev(10) = "ABOVE" 'GET LABEL ABOVE BELOW ' works > End If > > Thank you > > John > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: how to test a range of numbers On Fri, 7 Aug 2009 21:17:31 -0400, "eBob.com" <eBob.com@xxxxxx> wrote: Quote: >Well ... "between" means greater than some lower bound AND (hint!) less than >some upper bound. But in programming, where the smallest details matter, >you have to think about whether you want "greater than" or "greater than or >equal to", and "less than" or "less than or equal to". > >The idiom I generally use, and I don't think there is much choice, is, for >example, ... > >If (i >= -10) And (i <= 0) Then > MsgBox("It's between -10 and 0") >End If > >Although a better message in this case would be "It's greater than or equal >to -10 and less than or equal to 0". (And I'm not sure if the parenthesizes >in the If statement are necessary - but they don't hurt.) > >Also, think about the fact that if SURFDIFF is less than -10 then it can't >also be greater than 0. So once your logic has determined that it is less >than -10 it's a waste of the computer's precious time to see if it's also >greater than 0. > >See if you can't structure your code so that it avoids the greater-than-0 >test when SURFDIFF has already been determined to be less than -10. (You'll >need to use the Else part of the If-Then-Else statement.) Failure to do >this might lower your grade on this assignment by one letter grade. > >Good Luck, Bob > >"jcoon" <jcoonnh@xxxxxx> wrote in message >news:%2330iWZ7FKHA.1340@xxxxxx Quote: >> I'm trying a test for below -10 and another test for 0 to -9.9 and a third >> for above. >> First and third test work corectly but I don't know how to test for the >> second, range values between 0 and -9.99. >> >> If SURFDIFF < -10 Then >> StaElev(10) = "BELOW" 'LABEL BELOW ' works >> End If >> >> 'how to you test a range between 0 and -9.99 >> If SURFDIFF < 0 and < -9.99 Then >> StaElev(10) = "BELOW WITHIN 10 FT" >> End If >> >> If SURFDIFF > 0 Then >> StaElev(10) = "ABOVE" 'GET LABEL ABOVE BELOW ' works >> End If >> >> Thank you >> >> John >> If SURFDIFF < 0 AndAlso SURDIFF > -9.99 You should use AndAlso instead of And (and OrElse instead of Or). And always evaluates both expressions, AndAlso doesn't evaluate the second if there is no need to. Also be aware that values of -10 to -9.99 and 0 don't match any of your tests. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: how to test a range of numbers Bob, Thanks, I'm sample in cad 500,000 + coordinates with elevation against airport flight paths to determine if objects penetrate the approach surface. Surface object is 3D surface model which I need only objects that penetrate the surface and or are within 10 ft of the surface, all other are either 0 which is not within the surface model or far enough below (values below -10) that they are not used. With your help and others I can continue testing my samples. Thanks John "eBob.com" <eBob.com@xxxxxx> wrote in message news:O19qAY8FKHA.4732@xxxxxx Quote: > Well ... "between" means greater than some lower bound AND (hint!) less > than some upper bound. But in programming, where the smallest details > matter, you have to think about whether you want "greater than" or > "greater than or equal to", and "less than" or "less than or equal to". > > The idiom I generally use, and I don't think there is much choice, is, for > example, ... > > If (i >= -10) And (i <= 0) Then > MsgBox("It's between -10 and 0") > End If > > Although a better message in this case would be "It's greater than or > equal to -10 and less than or equal to 0". (And I'm not sure if the > parenthesizes in the If statement are necessary - but they don't hurt.) > > Also, think about the fact that if SURFDIFF is less than -10 then it can't > also be greater than 0. So once your logic has determined that it is less > than -10 it's a waste of the computer's precious time to see if it's also > greater than 0. > > See if you can't structure your code so that it avoids the greater-than-0 > test when SURFDIFF has already been determined to be less than -10. > (You'll need to use the Else part of the If-Then-Else statement.) Failure > to do this might lower your grade on this assignment by one letter grade. > > Good Luck, Bob > > "jcoon" <jcoonnh@xxxxxx> wrote in message > news:%2330iWZ7FKHA.1340@xxxxxx Quote: >> I'm trying a test for below -10 and another test for 0 to -9.9 and a >> third for above. >> First and third test work corectly but I don't know how to test for the >> second, range values between 0 and -9.99. >> >> If SURFDIFF < -10 Then >> StaElev(10) = "BELOW" 'LABEL BELOW ' works >> End If >> >> 'how to you test a range between 0 and -9.99 >> If SURFDIFF < 0 and < -9.99 Then >> StaElev(10) = "BELOW WITHIN 10 FT" >> End If >> >> If SURFDIFF > 0 Then >> StaElev(10) = "ABOVE" 'GET LABEL ABOVE BELOW ' works >> End If >> >> Thank you >> >> John >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Errors while run DTM Test USB Address Description Test | PowerShell | |||
| Out of Range ???? | Vista installation & setup | |||
| Router Range | Vista General | |||
| Range Operator | PowerShell | |||
| wlan range | Vista networking & sharing | |||