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!

convertion

Status
Not open for further replies.

coachvi

Technical User
Nov 19, 2008
111
GH
convert amount in figures into words any help something like this

1000 to one thousand
 
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"


[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
so can you tell me what is wrong with this

Add{CBBTHD.APPLAMOUNT + {CBBTSD.ADJAMOUNT}}
 
kindly help me then convert this to word


CurrencyVar SumAmt := ( Sum ( {CBBTHD.APPLAMOUNT})) + ( Sum ( {CBBTSD.ADJAMOUNT}));

if {?ALIGNMNT} = "Y" then // Used for alignment
"999,999,999.99"
ELSE
ToText ( ToNumber ( SumAmt ) , {CBBTHD.BTCHNODEC} )
 
I've already given you an answer that should work. If you'd rather do it your own way, fine, but then you're on your own.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
coachvi,

Did you end up with a solution to your problem?

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top