delphi7 做简单计算器 只包括 加减乘除就好
3个回答
展开全部
用delphi7实现简单的加减乘除,还有一些科学运算。。。以下是一些源代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,math;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Button15: TButton;
Edit1: TEdit;
Button16: TButton;
Button17: TButton;
Button18: TButton;
Button19: TButton;
Button20: TButton;
Button21: TButton;
Button22: TButton;
Button23: TButton;
Button24: TButton;
Button25: TButton;
Button26: TButton;
Button27: TButton;
Button28: TButton;
Button29: TButton;
Button30: TButton;
procedure Button13Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button16Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
procedure Button17Click(Sender: TObject);
procedure Button18Click(Sender: TObject);
procedure Button19Click(Sender: TObject);
procedure Button20Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button21Click(Sender: TObject);
procedure Button22Click(Sender: TObject);
procedure Button23Click(Sender: TObject);
procedure Button24Click(Sender: TObject);
procedure Button25Click(Sender: TObject);
procedure Button26Click(Sender: TObject);
procedure Button27Click(Sender: TObject);
procedure Button28Click(Sender: TObject);
procedure Button29Click(Sender: TObject);
procedure Button30Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x:string;
n:integer;
implementation
{$R *.dfm}
procedure TForm1.Button13Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'0';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'1';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'2';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'3';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'4';
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'5';
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'6';
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'7';
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'8';
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'9';
end;
procedure TForm1.Button14Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'.';
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button12Click(Sender: TObject);
begin
edit1.Clear ;
end;
procedure TForm1.Button16Click(Sender: TObject);
begin
n:=1;
x:=edit1.Text;
edit1.Clear ;
end;
procedure TForm1.Button15Click(Sender: TObject);
begin
case n of
1:
edit1.Text :=floattostr(strtofloat(x)+strtofloat(edit1.Text ));
2:
edit1.Text :=floattostr(strtofloat(x)-strtofloat(edit1.Text ));
3:
edit1.Text :=floattostr(strtofloat(x)*strtofloat(edit1.Text ));
4:
if StrToFloat(Edit1.Text)=0 then
begin
Edit1.Text:='error';
Exit;
end
else
edit1.Text :=floattostr(StrToFloat(x)/StrToFloat(Edit1.Text));
end;
end;
procedure TForm1.Button17Click(Sender: TObject);
begin
n:=2;
x:=edit1.Text ;
edit1.Clear ;
end;
procedure TForm1.Button18Click(Sender: TObject);
begin
n:=3;
x:=edit1.Text ;
edit1.Clear ;
end;
procedure TForm1.Button19Click(Sender: TObject);
begin
n:=4;
x:=edit1.Text ;
edit1.Clear ;
end;
procedure TForm1.Button20Click(Sender: TObject);
begin
x:=edit1.Text ;
edit1.Text :=floattostr(sqr(strtofloat(x)));
end;
procedure TForm1.Button11Click(Sender: TObject);
begin
if (Edit1.Text='0') or (length(Edit1.Text)=1) then
Edit1.Text:=''
else
Edit1.Text:=Copy(Edit1.Text,0,length(Edit1.Text)-1);
end;
procedure TForm1.Button21Click(Sender: TObject);
begin
edit1.Text :=floattostr(sin(strtofloat(edit1.Text )*(pi/180)));
end;
procedure TForm1.Button22Click(Sender: TObject);
begin
edit1.Text :=floattostr(cos(strtofloat(edit1.Text)*(pi/180)));
end;
procedure TForm1.Button23Click(Sender: TObject);
begin
edit1.Text :=floattostr(tan(strtofloat(edit1.Text)*(pi/180)));
end;
procedure TForm1.Button24Click(Sender: TObject);
begin
edit1.Text :=floattostr(arcsin(strtofloat(edit1.Text ))*(180/pi));
end;
procedure TForm1.Button25Click(Sender: TObject);
begin
edit1.Text :=floattostr(arccos(strtofloat(edit1.Text ))*(180/pi));
end;
procedure TForm1.Button26Click(Sender: TObject);
begin
edit1.Text :=floattostr(ln(strtofloat(edit1.Text )));
end;
procedure TForm1.Button27Click(Sender: TObject);
begin
edit1.Text :=floattostr(log10(strtofloat(edit1.Text )));
end;
procedure TForm1.Button28Click(Sender: TObject);
begin
edit1.text:= floattostr(pi);
end;
procedure TForm1.Button29Click(Sender: TObject);
begin
edit1.Text :=floattostr(exp(strtofloat(edit1.Text ))) ;
end;
procedure TForm1.Button30Click(Sender: TObject);
begin
edit1.Text :=floattostr(sqrt(strtofloat(edit1.Text )) );
end;
End.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,math;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Button15: TButton;
Edit1: TEdit;
Button16: TButton;
Button17: TButton;
Button18: TButton;
Button19: TButton;
Button20: TButton;
Button21: TButton;
Button22: TButton;
Button23: TButton;
Button24: TButton;
Button25: TButton;
Button26: TButton;
Button27: TButton;
Button28: TButton;
Button29: TButton;
Button30: TButton;
procedure Button13Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button16Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
procedure Button17Click(Sender: TObject);
procedure Button18Click(Sender: TObject);
procedure Button19Click(Sender: TObject);
procedure Button20Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button21Click(Sender: TObject);
procedure Button22Click(Sender: TObject);
procedure Button23Click(Sender: TObject);
procedure Button24Click(Sender: TObject);
procedure Button25Click(Sender: TObject);
procedure Button26Click(Sender: TObject);
procedure Button27Click(Sender: TObject);
procedure Button28Click(Sender: TObject);
procedure Button29Click(Sender: TObject);
procedure Button30Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x:string;
n:integer;
implementation
{$R *.dfm}
procedure TForm1.Button13Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'0';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'1';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'2';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'3';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'4';
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'5';
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'6';
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'7';
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'8';
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'9';
end;
procedure TForm1.Button14Click(Sender: TObject);
begin
edit1.Text :=edit1.Text +'.';
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button12Click(Sender: TObject);
begin
edit1.Clear ;
end;
procedure TForm1.Button16Click(Sender: TObject);
begin
n:=1;
x:=edit1.Text;
edit1.Clear ;
end;
procedure TForm1.Button15Click(Sender: TObject);
begin
case n of
1:
edit1.Text :=floattostr(strtofloat(x)+strtofloat(edit1.Text ));
2:
edit1.Text :=floattostr(strtofloat(x)-strtofloat(edit1.Text ));
3:
edit1.Text :=floattostr(strtofloat(x)*strtofloat(edit1.Text ));
4:
if StrToFloat(Edit1.Text)=0 then
begin
Edit1.Text:='error';
Exit;
end
else
edit1.Text :=floattostr(StrToFloat(x)/StrToFloat(Edit1.Text));
end;
end;
procedure TForm1.Button17Click(Sender: TObject);
begin
n:=2;
x:=edit1.Text ;
edit1.Clear ;
end;
procedure TForm1.Button18Click(Sender: TObject);
begin
n:=3;
x:=edit1.Text ;
edit1.Clear ;
end;
procedure TForm1.Button19Click(Sender: TObject);
begin
n:=4;
x:=edit1.Text ;
edit1.Clear ;
end;
procedure TForm1.Button20Click(Sender: TObject);
begin
x:=edit1.Text ;
edit1.Text :=floattostr(sqr(strtofloat(x)));
end;
procedure TForm1.Button11Click(Sender: TObject);
begin
if (Edit1.Text='0') or (length(Edit1.Text)=1) then
Edit1.Text:=''
else
Edit1.Text:=Copy(Edit1.Text,0,length(Edit1.Text)-1);
end;
procedure TForm1.Button21Click(Sender: TObject);
begin
edit1.Text :=floattostr(sin(strtofloat(edit1.Text )*(pi/180)));
end;
procedure TForm1.Button22Click(Sender: TObject);
begin
edit1.Text :=floattostr(cos(strtofloat(edit1.Text)*(pi/180)));
end;
procedure TForm1.Button23Click(Sender: TObject);
begin
edit1.Text :=floattostr(tan(strtofloat(edit1.Text)*(pi/180)));
end;
procedure TForm1.Button24Click(Sender: TObject);
begin
edit1.Text :=floattostr(arcsin(strtofloat(edit1.Text ))*(180/pi));
end;
procedure TForm1.Button25Click(Sender: TObject);
begin
edit1.Text :=floattostr(arccos(strtofloat(edit1.Text ))*(180/pi));
end;
procedure TForm1.Button26Click(Sender: TObject);
begin
edit1.Text :=floattostr(ln(strtofloat(edit1.Text )));
end;
procedure TForm1.Button27Click(Sender: TObject);
begin
edit1.Text :=floattostr(log10(strtofloat(edit1.Text )));
end;
procedure TForm1.Button28Click(Sender: TObject);
begin
edit1.text:= floattostr(pi);
end;
procedure TForm1.Button29Click(Sender: TObject);
begin
edit1.Text :=floattostr(exp(strtofloat(edit1.Text ))) ;
end;
procedure TForm1.Button30Click(Sender: TObject);
begin
edit1.Text :=floattostr(sqrt(strtofloat(edit1.Text )) );
end;
End.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在校学生吗?
自己做去 就算网上搜索一下也不难啊
要是有学长的话肯定有留底的,还有学长可以请教 何乐而不为呢?
自己做去 就算网上搜索一下也不难啊
要是有学长的话肯定有留底的,还有学长可以请教 何乐而不为呢?
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个貌似不难吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询