
Delphi_jak ošetřit špatné zadání
Ahoj lidi, začínám s Delphi a nepřišel jsem na to, jak ošetřit:
- nezadání proměné (a1 - a3)
- zadání proměné (a1 - a3) ve špatném tvaru
Děkuji za radu
Martin
unit aaa;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a1,a2,a3,a4: Integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
a1:=StrToInt(Edit1.Text);
a2:=StrToInt(Edit2.Text);
a3:=StrToInt(Edit3.Text);
a4:=a1+a2+a3;
Edit4.Text:=IntToStr(a4);
end;
end.