unit UFDeclencher;

interface

uses
  SysUtils, Classes, QGraphics, QControls, QForms, QDialogs,
  QStdCtrls;

type
  TForm1 = class(TForm)
   Button1: TButton;
   Label1: TLabel;
   Edit1: TEdit;
   Label2: TLabel;
   Edit2: TEdit;
   procedure Button1Click(Sender: TObject);
  private
   { Déclarations privées }
  public
   { Déclarations publiques }
  end;

var
  Form1: TForm1;

implementation


{$R *.DFM}


procedure TForm1.Button1Click(Sender: TObject);
var x,y,z:real;
begin
try  //protection générales   (mettre un point d'arrêt ici et observer)
  x:=strtofloat(edit1.text);
  y:=0;   // changer la valeur de y=10 par y=0
  z:=x / y;
  try  //cas particulier
  z:=y / x;
  except //gestion du cas particulier
  on EZeroDivide do
  begin
    Showmessage('Division interne  par zéro impossible');
    z:=0;
    //raise //redéclenche le EZeroDivide
  end
  end
;
except
  on EZeroDivide do
  begin
  Showmessage('valeur z=1, par défaut');
  z:=1
  end
end
;
edit2.text:=floattostr(z);
end;

end.