0

I have a problem with a thousand separator.I want to add a thousand separator and a decimal separator in a float value,for example 1000 will be 1.000,00.The decimal separator it works but the thousand separator it doesn't. So i try to work with FormatSettings.Here is my code for example

  workSettings := TFormatSettings.Create;
  workSettings.ThousandSeparator := '.';
  workSettings.DecimalSeparator:= ',';
  if (TryStrToFloat(e_pret.Text,articleInfo.Pret)) then begin
  articleInfo.Pret  := StrToFloat(e_pret.Text,wokSettings);
  end;

Thanks

Vlad Costin
  • 61
  • 1
  • 10

1 Answers1

0

ThousandsSeparator and DecimalSeparator only make sense in strings, not in binary floats. Look at FormatFloat() to create a formatted string with separators in it.

workSettings := TFormatSettings.Create;
workSettings.ThousandSeparator := '.';
workSettings.DecimalSeparator := ',';
if TryStrToFloat(e_pret.Text, articleInfo.Pret) then begin
   e_pret.Text := FormatFloat('#,##0.00', articleInfo.Pret, wokSettings);
end;
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770