Softtech
asked on
Format currency to string
Assuming...
var
Money : Currency;
How does one convert a TCurrency value to a formatted string, such as...
$x,xxx,xxx.xx
...so that if Money := 1234.5 then the resulting text string would contain '$1,234.50'
var
Money : Currency;
How does one convert a TCurrency value to a formatted string, such as...
$x,xxx,xxx.xx
...so that if Money := 1234.5 then the resulting text string would contain '$1,234.50'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry Shengw,
When I started your comment was not up
Regards
Asw
When I started your comment was not up
Regards
Asw
My name is shenqw,but many many people ask me shengw.Oh,my god! ^o^
Hi. You can use delphi CurrToStr, that converts currency according to windows language settings.
function CurrToStr(Value: Currency): string;
from SysUtils unit;
Shenqw: I have the very same problem - they call me Aleg although I'm AleQ
function CurrToStr(Value: Currency): string;
from SysUtils unit;
Shenqw: I have the very same problem - they call me Aleg although I'm AleQ
ASKER
The precision "4" is insufficient for a value such as 1234.50, nonetheless ASW's response comes closest to meeting my needs.
Thank you Shenq, however, the '[1234.50]' did not fulfil my needs, since I was trying to pass a variable, not a static value.
Thank you Shenq, however, the '[1234.50]' did not fulfil my needs, since I was trying to pass a variable, not a static value.
oh,my god!!!
why you not try:
procedure TForm1.Button1Click(Sender : TObject);
var
Money : Currency;
begin
Money:=12345.5;
CurrencyString:='$';
CurrencyFormat:=0;
ThousandSeparator:=',';
ShowMessage(Format('%.2m', [Money]));
end;
why you not try:
procedure TForm1.Button1Click(Sender
var
Money : Currency;
begin
Money:=12345.5;
CurrencyString:='$';
CurrencyFormat:=0;
ThousandSeparator:=',';
ShowMessage(Format('%.2m',
end;
Hi Softtech,
Try this
Var
Money : Currency;
begin
Money := 1234.50;
Label1.Caption := FloatToStrF(Money, ffCurrency, 6, 2);
Asw
Try this
Var
Money : Currency;
begin
Money := 1234.50;
Label1.Caption := FloatToStrF(Money, ffCurrency, 6, 2);
Asw
ASKER
Shenqw asked: oh,my god!!! why you not try:
My reply: Why? Because I'm a novice and you are the expert, and your original response assumed I knew that the variable 'Money' could be placed between [] brackets...which I did not know.
My reply: Why? Because I'm a novice and you are the expert, and your original response assumed I knew that the variable 'Money' could be placed between [] brackets...which I did not know.
begin
CurrencyString:='$';
CurrencyFormat:=0;
ThousandSeparator:=',';
ShowMessage(Format('%.2m',
end;