Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting String to Number Question 1

Status
Not open for further replies.

LZido

Technical User
Aug 24, 2006
21
US
I have a field that is a string {Property.LANDINGZONE}. The formula below is not returning the correct results. I am assuming I need to convert the string into a number, but not sure how to do this.

if {Property.LANDINGZONE} in "0" to "7500" then 1
else
if {Property.LANDINGZONE} in "7501" to "14999" then 2
else if {Property.LANDINGZONE} > "15000" then 3

Any help would be appreciated.
 
ToNumber is the common function to convert from text to numbers. Doing ranges with number strings is always iffy because how strings are looked at.
 
I have tried that but getting an error "The keyword "then" is missing"

if TONUMBER{Property.LANDINGZONE} in "0" to "7500" then 1
else
if TONUMBER {Property.LANDINGZONE} in "7501" to "14999" then 2
else if TONUMBER {Property.LANDINGZONE} > "15000" then 3
 
Please try the following:

Code:
if    (TONUMBER{Property.LANDINGZONE} >=0 and TONUMBER{Property.LANDINGZONE} <=7500) then 1
else
if   (TONUMBER {Property.LANDINGZONE} >= 7501 and  TONUMBER {Property.LANDINGZONE} <=15000) then 2
else if TONUMBER {Property.LANDINGZONE} >= 15001 then 3
I have modified the formula a little bit to include the value of 15000.

[tt] 0-7500 1
7501-15000 2
15001 & above 3[/tt]

Please change appropriately if this is not what you want.



 
Thanks for the formula. It looks like it will work.

It is telling me - The ) is missing - and highlights the {Property.LANDINGZONE} field.

I tried putting ) in several places and cannot get it to work.
 
It is the one you gave me:

if (TONUMBER{Property.LANDINGZONE} >=0 and TONUMBER{Property.LANDINGZONE} <=7500) then 1
else
if (TONUMBER {Property.LANDINGZONE} >= 7501 and TONUMBER {Property.LANDINGZONE} <=15000) then 2
else if TONUMBER {Property.LANDINGZONE} >= 15001 then 3
 
Try this:

Code:
if    (TONUMBER({Property.LANDINGZONE}) >=0 and TONUMBER({Property.LANDINGZONE}) <=7500) then 1
else
if   (TONUMBER ({Property.LANDINGZONE}) >= 7501 and  TONUMBER ({Property.LANDINGZONE})<=15000) then 2
else if TONUMBER ({Property.LANDINGZONE})>= 15001 then 3
 
Yeah!!
You are the best!
Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top