吖
吖诚
Unregistered / Unconfirmed
GUEST, unregistred user!
这是个计算器的小程序,现在有两个问题:第一、这个程序要怎样认定计算的先后顺序?
第二、当输入一次小数点后怎么实现不会再次接受输入在edit1上?
本人刚开始学delphi,论坛注册时间不长,分数虽少,还请大家见谅。如果哪位大虾知道,还请赐教,感激不尽~!
var
Form1: TForm1;
A:Extended;
B:boolean;
C:boolean;
D:boolean;
E:boolean;
implementation
{$R *.dfm}
procedure TForm1.Button4Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'0';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'1';
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'2';
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'3';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'4';
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'6';
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'5';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'7';
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'8';
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'9';
end;
procedure TForm1.Button15Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'.';
end;
procedure TForm1.Button13Click(Sender: TObject);
begin
A:=StrTofloat(Edit1.text);
Edit1.Text :='';
B:=true;
c:=false;
D:=false;
E:=false;
end;
procedure TForm1.Button14Click(Sender: TObject);
begin
Edit1.Text:='';
end;
procedure TForm1.Button16Click(Sender: TObject);
begin
if B=true then
Edit1.Text:=floatTostr(StrTofloat(Edit1.Text ) + A)
else if C=true then
Edit1.Text:=floatTostr(A - StrTofloat(Edit1.Text ))
else if D=true then
Edit1.Text:=floatTostr(StrTofloat(Edit1.Text ) * A)
else if E=true then
Edit1.Text:=floatTostr(A / StrTofloat(Edit1.Text ));
end;
procedure TForm1.Button17Click(Sender: TObject);
begin
A:=StrTofloat(Edit1.text);
Edit1.Text :='';
B:=false;
c:=true;
D:=false;
E:=false;
end;
procedure TForm1.Button12Click(Sender: TObject);
begin
A:=StrTofloat(Edit1.text);
Edit1.Text :='';
B:=false;
c:=false;
D:=true;
E:=false;
end;
procedure TForm1.Button11Click(Sender: TObject);
begin
A:=StrToInt(Edit1.text);
Edit1.Text :='';
B:=false;
c:=false;
D:=false;
E:=true;
end;
end.
第二、当输入一次小数点后怎么实现不会再次接受输入在edit1上?
本人刚开始学delphi,论坛注册时间不长,分数虽少,还请大家见谅。如果哪位大虾知道,还请赐教,感激不尽~!
var
Form1: TForm1;
A:Extended;
B:boolean;
C:boolean;
D:boolean;
E:boolean;
implementation
{$R *.dfm}
procedure TForm1.Button4Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'0';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'1';
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'2';
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'3';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'4';
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'6';
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'5';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'7';
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'8';
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'9';
end;
procedure TForm1.Button15Click(Sender: TObject);
begin
Edit1.text:=Edit1.Text+'.';
end;
procedure TForm1.Button13Click(Sender: TObject);
begin
A:=StrTofloat(Edit1.text);
Edit1.Text :='';
B:=true;
c:=false;
D:=false;
E:=false;
end;
procedure TForm1.Button14Click(Sender: TObject);
begin
Edit1.Text:='';
end;
procedure TForm1.Button16Click(Sender: TObject);
begin
if B=true then
Edit1.Text:=floatTostr(StrTofloat(Edit1.Text ) + A)
else if C=true then
Edit1.Text:=floatTostr(A - StrTofloat(Edit1.Text ))
else if D=true then
Edit1.Text:=floatTostr(StrTofloat(Edit1.Text ) * A)
else if E=true then
Edit1.Text:=floatTostr(A / StrTofloat(Edit1.Text ));
end;
procedure TForm1.Button17Click(Sender: TObject);
begin
A:=StrTofloat(Edit1.text);
Edit1.Text :='';
B:=false;
c:=true;
D:=false;
E:=false;
end;
procedure TForm1.Button12Click(Sender: TObject);
begin
A:=StrTofloat(Edit1.text);
Edit1.Text :='';
B:=false;
c:=false;
D:=true;
E:=false;
end;
procedure TForm1.Button11Click(Sender: TObject);
begin
A:=StrToInt(Edit1.text);
Edit1.Text :='';
B:=false;
c:=false;
D:=false;
E:=true;
end;
end.