Chacking a number falls between 2 numbers
Hello everyone,
Here is what I am trying to do.
I need to check if value A which lets say is 5.45 falls between value B 6.45 and Value C 4.45 if it does than A is correct and the Color changes to Green, if it is incorrect the color changes to Red. Keep in mind that A, B, and C are all variables.
A is user input answer
B HC1 [color:#FF0000]6.45[/color]
HC1 = value( "Drop Loss 1" )+1 [color:#FF0000]5.45 + 1= 6.45[/color]
Drop Loss 1 = Str$(value( "Footage Counter Drop" )*4.66/100)[color:#FF0000]117 * 4.66 /100 = 5.45[/color]
C LC1 [color:#FF0000]4.45[/color]
LC1 = value( "Drop Loss 1" )-1 [color:#FF0000]5.45 - 1= 4.45[/color]
Drop Loss 1 = Str$(value( "Footage Counter Drop" )*4.66/100) [color:#FF0000]117 * 4.66 /100 = 5.45[/color]
What I have tried is:
A <= B and A<= C Change Color to green
A > B or A < C Change color to red
The issue I am running across is that it dont seam to take in to account the Decimal places. It will mark the answer correct from 4 6.99 I need it to be wrong at 6.46 and above and at 4.44 and below.
Can someone out there please help me with this?
Thanks, Rick
Re: Chacking a number falls between 2 numbers
OMG Rick this is way over my brain loss body. Forgive me, but you write like a PHD person. Is there anyway to ask this different?
Thanks
Marv
Re: Chacking a number falls between 2 numbers
set HC1 to value("Drop Loss 1")+1.0
also do the same for LC1, use 1.0 instead of 1.
Also, you may want to make 100 turn into 100.0, that actually looks like it's the bigger problem. When you divide by an integer, you're going to get an integer back.
Try those and let us know.
-Eliyahu
Re: Chacking a number falls between 2 numbers
Thanks for your quick response.
Eliyahu I tried what you said and am still getting the same results. I changed where I had +1 to +1.0, -1 to -1.0 and /100 to /100.0
Nivram In a nut shell I have 3 values which are all going to be values that contain decimals.
Value A is an Edit box that the user will type in a number
Value B is the highest the number can be and still be correct
Value C is the lowest the number can be and still be correct
I am using compare two general values. Is there something I have to do to the edit box? I did try this and still got the same results.
Compare two general values:
Edit Value( "Drop Loss Ans 1" )*1.0
Greater
value( "Drop Loss HC 1" )
Thanks,
Rick
Re: Chacking a number falls between 2 numbers
Rick, Edit Value of an edit box return an integer. If you want the user to be able to enter a float, you need to use Val(EditText$("edit box")). That's where your problem is coming from.
Re: Chacking a number falls between 2 numbers
You never said you were using an edit box...
Saying Edit Value( "Edit Box" ) will *always* return an integer.
To get a float, you have to use Val(Edittext$( "Edit Box" ))
EDIT: Nevermind - Eliyahu got there first :)
Re: Chacking a number falls between 2 numbers
Yea I'm just ninja like that. ^_^
Having to use Val around the string is quite frustrating, perhaps Edit Box should have an Edit Decimal("Edit Box") Expression so the code doesn't look so bad.
Re: Chacking a number falls between 2 numbers
Frustrating? It makes perfect sense to me - In my opinion the Edit Value expression is completely unnecessary, actually. As we can see, it has disadvantages and makes people overlook Val().
Re: Chacking a number falls between 2 numbers
Right, I just don't see why there is Edit Value but only for integers. It should either be 1 or both. To me it'd make more sense for Edit Value to return a decimal. If you want it as an int, you could do Int(Edit Value())
Re: Chacking a number falls between 2 numbers
Thanks Eliyahu that worked. Sorry about the confusion in my first post I made the mistake of assuming that you knew how "A" was being inputed. Thanks again for the help as I would have never thought of that.