Normal Topic IF > and < statements not working 2 digit numbers (Read 918 times)
Darangen
Member
*
Offline



Posts: 8
Joined: Aug 25th, 2009
IF > and < statements not working 2 digit numbers
Nov 10th, 2009 at 9:46pm
Print Post Print Post  
I've got a program that uses multiple IF - ELSE statements to determine what range a number falls into.  It works great for numbers with at least 3 digits, however if it's a single digit or 2 digit number, it automatically jumps to the 3 digit version.  Here's some of the code:

Code
Select All
...
		ELSE IF (vTotal > 499) and (vTotal < 510)
	{
		FedTax = 41
	}
		ELSE IF (vTotal > 509) and (vTotal < 520)
	{
		FedTax = 43
	}
		ELSE IF (vTotal > 519) and (vTotal < 530)
	{
		FedTax = 44
	}
...
 



Here's the example.  Currently vTotal is 52.  The program is going though and decided to make FedTax 43, which is only supposed to happen if the number is between 510 and 519.

Any ideas on why this might be happening, and what I can do to fix it?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: IF > and < statements not working 2 digit numb
Reply #1 - Nov 10th, 2009 at 9:56pm
Print Post Print Post  
Hello Darangen,

Could you please post all of the code in that routine?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: IF > and < statements not working 2 digit numb
Reply #2 - Nov 10th, 2009 at 10:52pm
Print Post Print Post  
Are you sure that vTotal is a real number and not text?

What if you change vTotal to @ToNumber(vTotal) ?
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: IF > and < statements not working 2 digit numb
Reply #3 - Nov 11th, 2009 at 2:25pm
Print Post Print Post  
If Casting vTotal to a number is a necessity then it should only be done once before the If statement where vTotal gets set and/or declared.
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Darangen
Member
*
Offline



Posts: 8
Joined: Aug 25th, 2009
Re: IF > and < statements not working 2 digit numb
Reply #4 - Nov 12th, 2009 at 2:20pm
Print Post Print Post  
Thanks, vTotal was currently set as a string, when using @ToNumber, the problem went away.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: IF > and < statements not working 2 digit numb
Reply #5 - Nov 12th, 2009 at 5:49pm
Print Post Print Post  
You probably want to declare vTotal as the type you really want it to be.

var vTotal as Double
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged