Board index » delphi » Converting currency to string

Converting currency to string

Edit1.Text := '$' + FormatFloat(('#,##0.00', MyCurrencyValue);

Quote
"Maxx" <mac...@hotmail.com> wrote in message

news:8c28gb$182$1@news.ihug.co.nz...
Quote
> How does one convert a currency variable to a string for display in a
label?
> I cannot find anything in the help files?

 

Re:Converting currency to string


"Maxx" <mac...@hotmail.com> skrev i en meddelelse
news:8c28gb$182$1@news.ihug.co.nz...

Quote
> How does one convert a currency variable to a string for display in a
label?
> I cannot find anything in the help files?

You didn't look very hard, did you?
This is one way to do it:
  Label1.Caption := CurrToStrF(Total, ffCurrency, 2);
It takes the users locale information into account automatically.

Finn Tolderlund

Re:Converting currency to string


Quote
In article <8c28gb$18...@news.ihug.co.nz>, "Maxx" <mac...@hotmail.com> writes:
>How does one convert a currency variable to a string for display in a label?
>I cannot find anything in the help files?

Label1.Caption := Format('%m', [12344.456]);

... produces  12,344.456 in my country - England

it takes the currency symbol, symbol position, negative placement, post-decimal
number of digits, and thousands separator from the system settings.

Look up "format strings" in help. I find Format() better than concatenating
string conversions together, because you can enter text into the formatting
string :-

Label1.Caption := Format('You owe me %m, pay me %m a week', [12344.456,
12344.56/20]); produces "You owe me 12,344.46, pay me 617.22 a week".

Alan Lloyd
alangll...@aol.com

Re:Converting currency to string


How does one convert a currency variable to a string for display in a label?
I cannot find anything in the help files?

Re:Converting currency to string


Quote
"AlanGLLoyd" <alangll...@aol.com> wrote in message

news:20000331132407.24408.00000276@nso-cm.aol.com...

Quote
> Label1.Caption := Format('You owe me %m, pay me %m a week', [12344.456,
> 12344.56/20]); produces "You owe me 12,344.46, pay me 617.22 a week".

What a subtle way of hinting that your answer is worth the time it took you
to write it <vbg>

Joanna

Re:Converting currency to string


Im Artikel <20000331132407.24408.00000...@nso-cm.aol.com>, alangll...@aol.com
(AlanGLLoyd) schreibt:

Quote
>Label1.Caption := Format('You owe me %m, pay me %m a week', [12344.456,
>12344.56/20]); produces "You owe me 12,344.46, pay me 617.22 a week".

But make sure that the currency really is the local one. Otherwise you may
receive 617 Lire, instead of Pounds ;-)

DoDi

Other Threads