Программирование - это просто
Advertisement
arrow arrow Delphi arrow Delphi: format (, , )
06.02.2023 .
1:
C#
Delphi
Web-
Excel-
.
Delphi: format (, , ) E-mail
megabax   
28.01.2010 .

 Delphi: format (, , )

, , , , . , , :

procedure TForm1.btnCalkClick(Sender: TObject);
begin
        lbResult.Caption:=FloatToStr(123/456);
end;

:

Delphi:  format (,    )

, , ? , format.

procedure TForm1.btnCalkClick(Sender: TObject);
begin
       lbResult.Caption:=Format(' %.3n',[123/456]);
end;

:

Delphi:  format (,    )

Delphi   Format, 'C' . , - ( []).

, % :

d = ( )
e =
f =
g =
m =
n = ()
p =
s =
u =
x =


:

procedure TForm1.btnCalkClick(Sender: TObject);
var i:integer;
begin
    i:=123;
    lbResult.Caption:=Format('%d %x ',[i,i]);
end;

:

Delphi:  format (,    )

:

%[Index:][-][Width][.Precision]Type

, :. - - , 2 , .

:

procedure TForm1.btnCalkClick(Sender: TObject);
begin
      lbResult.Caption:=Format('%.4f',[123.456]);
end;

:

Delphi:  format (,    )

, format. TListBox ( Standart). lbFormatDemo. OnClick:

procedure TfrmFormatDemo.btnStartClick(Sender: TObject);
var
     text : string;
begin
     // 1
     lbFormatDemo.Items.Add(Format('%s', ['Hello']));

     //
     lbFormatDemo.Items.Add(Format('String = %s', ['Hello']));

     //
     lbFormatDemo.Items.Add(Format('Decimal = %d', [-123]));
     lbFormatDemo.Items.Add(Format('Exponent = %e', [12345.678]));
     lbFormatDemo.Items.Add(Format('Fixed = %f', [12345.678]));
     lbFormatDemo.Items.Add(Format('General = %g', [12345.678]));
     lbFormatDemo.Items.Add(Format('Number = %n', [12345.678]));
     lbFormatDemo.Items.Add(Format('Money = %m', [12345.678]));
     lbFormatDemo.Items.Add(Format('Pointer = %p', [addr(text)]));
     lbFormatDemo.Items.Add(Format('String = %s', ['Hello']));
     lbFormatDemo.Items.Add(Format('Unsigned decimal = %u', [123]));
     lbFormatDemo.Items.Add(Format('Hexadecimal = %x', [140]));
end;

, :

Delphi:  format (,    )

, :

procedure TfrmFormatDemo.btnStartClick(Sender: TObject);
begin
      //
      // ,
      // <>, ,

      lbFormatDemo.Items.Add(Format('Padded decimal = <%7d>', [1234]));

      // '-' ,
      lbFormatDemo.Items.Add(Format('Justified decimal = <%-7d>', [1234]));

      // 0
      lbFormatDemo.Items.Add(Format('0 padded decimal = <%.6d>', [1234]));

      //
      // ,
      lbFormatDemo.Items.Add(Format('Width + precision = <%8.6d>', [1234]));

      //
      //
     lbFormatDemo.Items.Add(Format('Reposition after 3 strings = %s %s %s %1:s %s',['Zero', 'One', 'Two', 'Three']));

     // , , *
     // ECONVERTERROR.

     lbFormatDemo.Items.Add(Format('In line = <%10.4d>', [1234]));
     lbFormatDemo.Items.Add(Format('Part data driven = <%*.4d>', [10, 1234]));
     lbFormatDemo.Items.Add(Format('Data driven = <%*.*d>', [10, 4, 1234]));
end;

Delphi:  format (,    )

 

( 18.02.2013 . )
 
« .   . »
 
© 2023 Программирование - это просто
Joomla! - , GNU/GPL.
© 2005-2008 Joom.Ru - Joomla!
Design by Mamboteam.com | Powered by Mambobanner.de
  .