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

Amount (in word) format

Status
Not open for further replies.

EngJoo

Programmer
May 14, 2002
90
0
0
MY
Greeting,

does anyone can guide what is the syntax for converting a amount to WORDS?

for example:

935 = nine hundred thirty-five only

Thanks
EngJoo
 
What version of Crystal?

Version 9 has : ToWords() That you can use...not sure if available in prior versions.
 
The ToWords command will automatically turn a whole number into words. Say ToWords({Your.Amount}). For whole numbers this is OK: 4,304 becomes four thousand three hundred four.

Decimals - normally used for currency - are a different matter . ToWords({Your.Amount},2) for 4304.34 will give you four thousand three hundred four and 34/100. For zero pence it would be and xx/100. (This is Crystal 8.5: later versions may be better.)

You can get a much neater look using something like:
Code:
if Truncate({Your.Amount}) = {Your.Amount}
then
ToWords({Your.Amount}) & " pounds exactly" 
else
ToWords({Your.Amount}) & " pounds, "  &
Towords(Tonumber(Right(totext({Your.Amount}, 2), 2))) & " pence"

ToWords has been available since at least Crystal 8.5, which I used to use.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top