用pascal做计算器
pascal吧
全部回复
仅看楼主
level 2
+号下的判断情况
procedure TForm1.Btn_addClick(Sender: TObject);
begin
if j=0 then //判断j的状态
begin
//不输出
end
else
if j=1 then //输入第一个数字。
begin
j:=2;
a:=strtofloat(Edit1.Text);
DFuhao:=FuHao;
Edit1.Text:='';
end
else
if j=2 then //判断第一个符号,且把他保存在DFuFao中。
begin
DFuHao:=FuHao;
end
else
if j=3 then
begin
b:=strtofloat(Edit1.Text); //此时输入第二个数字,且把它赋值给b.
Edit1.Text:=Floattostr(a+b);
end
else if j=4 then
begin
j:=2;
b:=0;
end;
DFuHao:=0;
end;
等号下的代码
procedure TForm1.Btn_dengyuClick(Sender: TObject);
begin
b:=strtofloat(Edit1.Text);
case DFuHao of
0: Edit1.Text := FloatToStr(a +b);
1: Edit1.Text := FloatToStr(a - b);
2: Edit1.Text := FloatToStr(a * b);
3: if StrToFloat(Edit1.Text)=0 then
begin
showmessage('运算错误');
end
else
Edit1.Text := FloatToStr(a /b);
end;
end;
这是遇到的问题,亲们怎么解决
2015年07月29日 10点07分 1
1