How do I format an Integer using current locale in Delphi

Roddy picture Roddy · Nov 17, 2008 · Viewed 9.1k times · Source
var i : integer;

i := 1234567;

Given the above, I want the string "1,234,567" as output (assuming UK locale). IntToStr just gives me "1234567". I'm sure there's a one-liner for this, but I can't find it...

Answer

Bruce McGee picture Bruce McGee · Nov 17, 2008

Try the format function.

Label1.Caption := Format('%.0n', [i + 0.0]);