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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting String field to number 2

Status
Not open for further replies.

justinkeller

Technical User
Dec 9, 2008
5
US
Hello,

I need assistance in trying to convert a string field to a number. My problem is that I have a few instances where non digits were used to signify blank values- ie. N, X so the simple tonumber command will not work. I do not care about the non numeric values. Is there any way to convert everything else and just ignore these problem instances?

Thanks
 
Assuming you are using CR9 or above you can test for numeric text

if isnumeric(stringnumber) = true then tonumber(stringnumber)
else 0

Ian
 
Or you can use VAL() which automatically returns zeros when it encounters strings. It also can read the digits before the first string. The formula:

Val ("102B")

returns the number 102.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides to Formulas, Parameters, Subreports, Cross-tabs, VB, Tips and Tricks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top