当前位置:编程学习 > Delphi >>

这是我用delphi编的计算器,有内部错误,求高手帮我看看

补充:var Form1: TForm1; str1,str2,str3:string; int1,int2:Integer; opr,jia,jian,chen,chu:boolean; int3:real; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin if opr=true then edit2.Text:= str2+'0' else edit1.text:= str1+'0'; end;//其他数字按钮类似 procedure TForm1.Button11Click(Sender: TObject); begin if opr=true then edit2.Text:= '' else edit1.text:= ''; end; procedure TForm1.Button13Click(Sender: TObject); begin opr:= true; jia:= true; jian:= false; chen:= false; chu:= false; end;//其他运算按钮类似 procedure TForm1.Button12Click(Sender: TObject); begin int1:= strtoint(str1); int2:= strtoint(str2); if jia=true then int3:=int1+int2 else if jian=true then int3:=int1-int2 else if chen=true then int3:=int1*int2 else int3:=int1/int2; str3:= floattostr(int3); panel1.Caption:= str3; end; initialization str1:= ''; str2:= ''; opr:= false; jia:= false; jian:= false; chen:= false; chu:= false; end.
答案:1、自己的机子配置差,打开程序多会造成以上问题,例如您正在听音乐下载电影游戏等,都会影响浏览速度。 

建议关闭所有多余程序再试。
其他:initialization
str1:= '';
str2:= '';
opr:= false;
jia:= false;
jian:= false;
chen:= false;
chu:= false;
把这段写到FormCreate或FormShow中,比如:
procedure TForm1.FormCreate(Sender: TObject);
begin
str1:= '';
str2:= '';
opr:= false;
jia:= false;
jian:= false;
chen:= false;
chu:= false;

end; 

上一个:delphi中怎样输出记录型变量
下一个:Delphi 中函数返回值 怎么定义 我刚学这

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,