home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk15 / format.pak / FLOATS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-08-24  |  1.1 KB  |  54 lines

  1. unit Floats;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls;
  8.  
  9. type
  10.   TFloatForm = class(TForm)
  11.     ValueEdit: TComboBox;
  12.     FormatEdit: TComboBox;
  13.     ResultEdit: TEdit;
  14.     Label1: TLabel;
  15.     Label2: TLabel;
  16.     Label3: TLabel;
  17.     Button1: TButton;
  18.     procedure Button1Click(Sender: TObject);
  19.     procedure FormCreate(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   FloatForm: TFloatForm;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33. procedure TFloatForm.Button1Click(Sender: TObject);
  34. begin
  35.   ResultEdit.Text := FormatFloat(FormatEdit.Text, StrToFloat(ValueEdit.Text));
  36. end;
  37.  
  38. procedure TFloatForm.FormCreate(Sender: TObject);
  39. begin
  40.   with ValueEdit.Items do
  41.   begin
  42.     Add('1234' + DecimalSeparator + '56');
  43.     Add('-12345' + DecimalSeparator + '678901');
  44.     Add('0');
  45.     Add('-1');
  46.     Add('1234567890' + DecimalSeparator + '12');
  47.     Add('123e14');
  48.     Add('-123e-8');
  49.   end;
  50.   ValueEdit.Text := ValueEdit.Items[0];
  51. end;
  52.  
  53. end.
  54.