将货币显示为不同的货币类型 ($10 -> R10)



如何更改货币类型的值?当我需要R.时,我的货币可以兑换美元

procedure TfrmFinal.addSubtractTotal; 
var 
total: currency; 
begin 
total := 0; 
frmDataModule.tblpins.First; 
while not frmDataModule.tblpins.Eof do 
begin 
total := total + 
frmDataModule.tblpins.FieldByName('qty').AsInteger * 
frmDataModule.tblpins.FieldByName('price').AsCurrency; 
frmDataModule.tblpins.Next; 
end; 
totalAmmountLabel.Text := total.ToString; 
end;

有几种方法可以解决这个问题。不幸的是,我没有TCurrentHelper,但这里有一些其他选项:

procedure TForm1.Button1Click(Sender: TObject);
var Total: Currency;
begin
Total := 155;
var FormatSettings := TFormatSettings.Create(7177); //LCID for South Africa, MAY not be necessary if that is the local setting on the machines you are supporting
button1.Caption := FloatToStrF(Total, ffCurrency, 15,2, FormatSettings);
button1.Caption := FormatCurr('', Total, FormatSettings);
button1.Caption := CurrToStr(Total, FormatSettings);
button1.Caption := CurrToStrF(Total,ffCurrency,2,FormatSettings);
end;

所有这些都略有不同。我更喜欢CurrToStrF(然后称为FloatToStrF(,但这只是出于习惯。

最新更新