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

Converting Numbers to Text

Status
Not open for further replies.

TheBlondOne

Programmer
May 22, 2001
346
GB
Hi all,

Im creating a fairly big crystal report, that contains about 5000+ records. What im trying to do is put a number at the side of each record to group on (thats the easy part). I then want to convert that number into text e.g
one
two
three....etc.

I have tried using the towords function but that returns extra parts that i don't need. E.g

Record number 4 is returned as four and xx/100.

The formula that i am using to test with at the minute is printed below, but as you can appreciate, im not manually typing in the number and then the text for 5000+ records, so any ideas would be appreciated.

Thanks in advance.

whileprintingrecords;
stringvar number;
numbervar crecordnumber:= crecordnumber + 1;
if crecordnumber = 1 then number := "one" else
if crecordnumber > 2 then number := "two" else
if crecordnumber = 3 then number := "three" else
if crecordnumber = 4 then number := "four" else
if crecordnumber = 5 then number := "five" else
if crecordnumber = 6 then number := "six" else
if crecordnumber = 7 then number := "seven".....etc
 
To eliminate the unwanted bits from the ToWords function do the following:

ToWords({Fieldname},0)

The ',0' extension drops any decimal part of the number, which is the 'xx/100' bit.

good luck

Bill
 
Cheers Bill thats done the trick, it always turns out to be something simple. Thanks alot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top