unit Unit_16;

interface

uses
  Windows, Messages, SysUtils, Variants,
  Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    LabeledEdit3: TLabeledEdit;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

type
   EFloatingPointError = class(EMathError);

resourcestring
   Msg1 = 'Błąd operacji zmiennopozycyjnych: %s';
   Msg2 = 'Próba dzielenia przez zero: %s';

procedure TForm1.Button1Click(Sender: TObject);
begin
   try
     LabeledEdit3.Text:=FloatToStr(StrToFloat(LabeledEdit1.Text)/
                                   StrToFloat(LabeledEdit2.Text));
   except
     on Ex: EInvalidOp do
       raise EFloatingPointError.CreateFmt(Msg1, [Ex.Message]);
     //MessageBox(0, 'Błąd operacji zmiennopozycyjnych','Uwaga', MB_OK);
     on Ex: EZeroDivide do
       raise EFloatingPointError.CreateFmt(Msg2, [Ex.Message]);
     //MessageBox(0, 'Próba dzielenia przez zero','Uwaga', MB_OK);
     else
       raise;
   end;

end;
//---------------------------------------------------------
procedure TForm1.Button2Click(Sender: TObject);
begin
   Application.Terminate();
end;

end.
