tags:

views:

134

answers:

3

How can in delphi convert :

'1' to '1,00'

or

'1,5' to '1,50'

e.g All variables are in string.

thank you

+1  A: 

You are looking for the formatFloat function i believe.

var
  sText : string;
begin
  sText := '1234';
  showMessage(formatFloat('#,###.00', strToFloat(sText)));

-Don.

Don Dickinson
+2  A: 

You can use Format or FormatFloat function. Format example (assuming ',' is decimal separator) is

procedure TForm1.Button1Click(Sender: TObject);
begin
   ShowMessage(Format('%.2f', [StrToFloat('1,5')]));
end;
Serg
A: 

Use FormatFloat. And it's Delphi, with "i", btw...

anonImous
Didn't you see that `FormatFloat` already was mentioned in an answer (with example code)?
Andreas Rejbrand