Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

Show numbers with thousand separators

Title: show numbers with thousand separators? function AddThousandSeparator(S: string; Chr: Char): string; var I: Integer; begin Result := S; I := Length(S) - 2; while I 1 do begin Insert(Chr, Result, I); I := I - 3; end; end; procedure TForm1.Button1Click(Sender: TObject); begin Edit1.Text := AddThousandSeparator('400500210', ''''); // -- 400'500'210 end; // Other possibility / andere M glichkeit: ThousandSeparator := ''''; label1.Caption := FormatFloat('#,###,###.###', 23453452); // -- 23'453'452