unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x1 : integer;
x2 : integer;
x3 : integer;
str1 : string;
str2 : string;
str3 : string;
implementation
{$R *.dfm}
//+
procedure TForm1.Button1Click(Sender: TObject);
begin
if ( edit1.Text = '' ) OR ( edit2.Text = '' ) then
messagebox(handle , '输入两个数啊' , '出错' , 0 )
else
begin
str1 := edit1.Text;
str2 := edit2.Text;
x1 := strtoint(str1);
x2 := strtoint(str2);
x3 := x1 + x2 ;
str3 := inttostr(x3);
edit3.Text := str3 ;
end;
end;
//-
procedure TForm1.Button2Click(Sender: TObject);
begin
if ( edit1.Text = '' ) OR ( edit2.Text = '' ) then
messagebox(handle , '输入两个数啊' , '出错' , 0 )
else
begin
str1 := edit1.Text;
str2 := edit2.Text;
x1 := strtoint(str1);
x2 := strtoint(str2);
x3 := x1 - x2 ;
str3 := inttostr(x3);
edit3.Text := str3 ;
end;
end;
//*
procedure TForm1.Button3Click(Sender: TObject);
begin
if ( edit1.Text = '' ) OR ( edit2.Text = '' ) then
messagebox(handle , '输入两个数啊' , '出错' , 0 )
else
begin
str1 := edit1.Text;
str2 := edit2.Text;
x1 := strtoint(str1);
x2 := strtoint(str2);
x3 := x1 * x2 ;
str3 := inttostr(x3);
edit3.Text := str3 ;
end;
end;
///
procedure TForm1.Button4Click(Sender: TObject);
begin
if ( edit1.Text = '' ) OR ( edit2.Text = '' ) then
messagebox(handle , '输入两个数啊' , '出错' , 0 )
else
begin
str1 := edit1.Text;
str2 := edit2.Text;
x1 := strtoint(str1);
x2 := strtoint(str2);
x3 := round(x1 / x2) ;
str3 := inttostr(x3);
edit3.Text := str3 ;
end;
end;
end.