这是我用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、自己的机子配置差,打开程序多会造成以上问题,例如您正在听音乐下载电影游戏等,都会影响浏览速度。

建议关闭所有多余程序再试。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-09-27
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;
相似回答