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!

Number Formatting: "1" = "One" and "12" = "Tw

Status
Not open for further replies.

ImArchimedes

Technical User
Sep 25, 2007
62
Can a number variable such as 1 and 42 be converted into "One" and "Forty-Two"?

I place this question in the Formula section because I can't go into "Format Editor" --> "Number" Tab and set the field to some sort of number-to-text variant. The "totext" function in the formula editor, as you all know, only turns the number 42 into the string "42". Is there some other function I don't know about?

Please help if you can and, even if you can't, thanks for taking the time to read this and think about it.
 
Use:

ToWords({table.number},0) //0 for no fractions

-LB
 
Depending on your Crystal Reports version, you might be able to use the 'ToWords' function.

Examples
The following examples are applicable to both Basic and Crystal syntax:
ToWords(12345)
Returns twelve thousand three hundred forty-five and xx/100.
ToWords(12345.6749,2)
Returns twelve thousand three hundred forty-five and 67/100.
ToWords(12345.4999,0)
Returns twelve thousand three hundred forty-five.

The function treats the number as a whole, rather than as a series of individual numbers. That is, 123 is treated as the number one hundred twenty-three rather than the individual digits one, two, and three.
Negative numbers begin with the word "negative."
Currency field values and Number field values are treated in the same way and produce identical results.
Since the spelled out value will be much longer than the Number value, you will need to increase the size of the field box to accommodate the new field length.
 
Perfect guys. Just didn't know the function existed. Thank you both and, Elsenorjose, thanks for the in depth description.
 
Hmmm, I'm getting an odd return using that function.

I'm running it on a field called "Sequence" which is a Number field. This is a number representing the order something happends such as 1,2,3,4,etc... The formula I'm using is simple.

towords({Sequence})

These are the results I'm getting:

"one and xxx/100"
"two and xxx/100"
"three and xxx/100"

I'm going to just using the below formula to get rid of the " and xxx/100" but why is it doing this? Any ideas?

numbervar numlength:=(length(towords({tfRPTTripStop.Sequence}))-13);

left(towords({tfRPTTripStop.Sequence}),numlength);
 
try this
towords({yourfield},0)

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
thats the original suggestion from LBass by the way

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Oops, yeah, I reread and figured it out but never updated my post. Sorry guys. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top