unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.XPMan;
type
TForm1 = class(TForm)
grp1: TGroupBox;
edt1: TEdit;
btn1: TButton;
btn2: TButton;
btn3: TButton;
btn4: TButton;
btn5: TButton;
btn6: TButton;
btn7: TButton;
btn8: TButton;
btn9: TButton;
btn10: TButton;
btn11: TButton;
btn12: TButton;
btn13: TButton;
btn14: TButton;
btn15: TButton;
btn16: TButton;
procedure btn16Click(Sender: TObject);
procedure btn15Click(Sender: TObject);
procedure btn14Click(Sender: TObject);
procedure btn13Click(Sender: TObject);
procedure btn12Click(Sender: TObject);
procedure btn11Click(Sender: TObject);
procedure btn10Click(Sender: TObject);
procedure btn9Click(Sender: TObject);
procedure btn8Click(Sender: TObject);
procedure btn7Click(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure btn6Click(Sender: TObject);
procedure btn5Click(Sender: TObject);
procedure btn4Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
value:Real;
zhen1:Byte;
implementation
{$R *.dfm}
function yunsuan(a,b:Real;C:integer):Real;
begin
case c of
1:yunsuan:=(a+b);
2:yunsuan:=(a-b);
3:yunsuan:=(a*b);
4:yunsuan:=(a/b);
end;
end;
procedure TForm1.btn10Click(Sender: TObject);
begin
edt1.Text:=edt1.Text+'7';
end;
procedure TForm1.btn11Click(Sender: TObject);
begin
edt1.Text:=edt1.Text+'6';
end;
procedure TForm1.btn12Click(Sender: TObject);
begin
edt1.Text:=edt1.Text+'5';
end;
procedure TForm1.btn13Click(Sender: TObject);
begin
edt1.Text:=edt1.Text+'4';
end;
procedure TForm1.btn14Click(Sender: TObject);
begin
edt1.Text:=edt1.Text+'3';
end;
procedure TForm1.btn15Click(Sender: TObject);
begin
edt1.Text:=edt1.Text+'2';
end;
procedure TForm1.btn16Click(Sender: TObject);
begin
edt1.Text:=edt1.Text+'1';
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
edt1.Clear;
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
if (edt1.Text<>'')and (zhen1=1) then
begin
edt1.Text:=FloatToStr(yunsuan(value,StrToFloat(edt1.Text),1));
Exit;
end
else if (edt1.Text<>'')and (zhen1=2) then
begin
edt1.Text:=FloatToStr(yunsuan(value,StrToFloat(edt1.Text),2))
end
else if (edt1.Text<>'')and (zhen1=3) then
begin
edt1.Text:=FloatToStr(yunsuan(value,StrToFloat(edt1.Text),3))
end
else if (edt1.Text<>'')and (zhen1=4) then
begin
edt1.Text:=FloatToStr(yunsuan(value,StrToFloat(edt1.Text),4))
end
else
Application.MessageBox('输入有误,请重试!','提示',0);
end;
procedure TForm1.btn3Click(Sender: TObject);
begin
value:=StrToFloat(edt1.Text);
edt1.Clear;
zhen1:=4;
end;
procedure TForm1.btn4Click(Sender: TObject);
begin
value:=StrToFloat(edt1.Text);
edt1.Clear;
zhen1:=3;
end;
procedure TForm1.btn5Click(Sender: TObject);
begin
value:=StrToFloat(edt1.Text);
edt1.Clear;
zhen1:=2;
end;
procedure TForm1.btn6Click(Sender: TObject);
begin
value:=StrToFloat(edt1.Text);
edt1.Clear;
zhen1:=1;
end;
procedure TForm1.btn7Click(Sender: TObject);
begin
edt1.Text:=edt1.Text+'0';
end;
procedure TForm1.btn8Click(Sender: TObject);
begin
edt1.Text:=edt1.Text+'9';
end;
procedure TForm1.btn9Click(Sender: TObject);
begin
edt1.Text:=edt1.Text+'8';
end;
end.
|