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

发布于 2025-01-21 03:59:34 字数 470 浏览 0 评论 0原文

如何改变一种货币的价值?当我需要 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;

how does one change the value of the type of currency? I am getting $ for my currency when i need 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;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨曦慕雪 2025-01-28 03:59:34

有几种解决这个问题的方法。不幸的是,我没有TCurrencyHelper,但这里还有其他一些选择:

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),但这只是出于习惯。

There are a few ways to solve this. Unfortunately, I don't have the TCurrencyHelper, but here are a few other options:

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;

All of them are slightly different. My preference would be CurrToStrF (which then calls FloatToStrF), but that is just out of habit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文