Comment utiliser (try..except) ?
Salut
mon probleme :quand laisser le (edit.text) vide un message s'affiche de type Econverterror , j'utiliser comme une solution [Try..Except..showmessage)
pour convert cet erreur.
mais toujout i'ya une chose qui cloche:le curceur s'arret et afficher :
[Error] Unit1.pas(123): Statement expected but 'PROCEDURE' found
[Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit1.pas'
mon source :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
procedure TForm1.CalculerClick(Sender: TObject);
var
g1,g,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12:real;
begin
try
a10:=2;
g:=9.81;
g1:=9810;
a8:=strtofloat (edit1.Text);
a12:=strtofloat (edit2.Text);
a9:=strtofloat (edit3.Text);
a11:=strtofloat (edit4.Text);
a5:=strtofloat (edit5.Text);
a6:=strtofloat (edit6.Text);
a1:=strtofloat (edit7.Text);
a2:=strtofloat (edit8.Text);
a4:=strtofloat (edit22.Text);
a4:=a12*g*a6;
resultat1:=(A5*a6*a7*a7*a8)/((a9*a10))+(((a11*a6*a7*a7)/(a10)));
resultat:=(A1-a2-resultat1-a4)/(g1);
edit10.Text:=floattostr (resultat);
except
showmessage ('Veuillez entre une valeur');
end; |