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

Converting a string to a number

Status
Not open for further replies.

shannonlp

Technical User
Feb 9, 2006
163
US
Is it possible to convert a string to a number if the value is ‘(27.10) bps’?

I tried

ToNumber({@3ML Spread: New DNs string})

But got the error

‘The string is non-numeric.’

Is it not possible because there are letters in the value?

Thanks for any help.

-Shannon

 

whileprintingrecords;
stringvar x := {yourdbfield};
stringvar z;
numbervar y;

for y := 1 to len(x)

do

if isnumeric(x[y])
or x[y] = "." then
z := z + x[y]
else z;

tonumber(z)


Are negatives a possibility? If so, you need to add that to the test:

or x[y] = "-"

 
Great - this is very helpful! Thanks for the help.
 
Hi.

I'm trying to convert a string into a number as well and I have tried this solution but when I do it seems that my resulting numbers are multiplied all the way down through the report.
My string {VWDEPSTAT.DID} is actually a patient-ID (which in Denmark is always the same number for each patient no matter where in the system the patient is registered - always the same 8 digit social security number).
Using the above solution makes the first entry an 8 digit number equal to the social security number but the next patient's number is multiplied by 100 and so forth.
What's wrong?

Best regards Mads Stiig, Denmark
 

Please post more specific detail about what is happening, formula content, sample data, grouping, etc.


 
madsstiig,

Please stop crossposting/reasking your question.
You have a currently active post on this topic that you should be concentrating on. thread767-1623372
Most people here are very willing to help if you provide adequate information and are not impatient. This is not an 'instant solution center', although some members are absolutely amazing in their knowledge and grasp of other people's reports!
thanks.
ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top