|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 jobkkk 于 2016-4-4 23:40 编辑
做了一点点的if判断,在除法时,或不输数直接按"="号,程序出错的问题..... 其他可能还有没有考虑到的地方,请指教....
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
edt1: TEdit;
btn1: TButton;
btn2: TButton;
btn3: TButton;
btn4: TButton;
btn5: TButton;
btn6: TButton;
btn7: TButton;
btn8: TButton;
btn9: TButton;
btn10: TButton;
btn11: TButton;
btn_off: TButton;
btn12: TButton;
btn_A: TButton;
btn_B: TButton;
btn_C: TButton;
btn_D: TButton;
btn_E: TButton;
btn_F: TButton;
btn_G: TButton;
procedure FormCreate(Sender: TObject);
procedure btn_offClick(Sender: TObject);
procedure btn_EClick(Sender: TObject);
procedure btn_FClick(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure btn4Click(Sender: TObject);
procedure btn5Click(Sender: TObject);
procedure btn6Click(Sender: TObject);
procedure btn7Click(Sender: TObject);
procedure btn8Click(Sender: TObject);
procedure btn9Click(Sender: TObject);
procedure btn10Click(Sender: TObject);
procedure btn11Click(Sender: TObject);
procedure btn12Click(Sender: TObject);
procedure btn_AClick(Sender: TObject);
procedure btn_GClick(Sender: TObject);
procedure btn_BClick(Sender: TObject);
procedure btn_CClick(Sender: TObject);
procedure btn_DClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
temp: Real;
tttt: integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Edt1.Handle,GWL_STYLE,GetWindowLong(Edt1.Handle,GWL_STYLE) or ES_right);
end;
procedure TForm1.btn_offClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.btn_EClick(Sender: TObject);
begin
edt1.Text:= '0' ;
temp:=0;
tttt:=1;
end;
procedure TForm1.btn_FClick(Sender: TObject);
begin
edt1.Text:= FloatToStr(StrToFloat(edt1.Text)*100);
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'1';
end
else
begin
edt1.Text:=edt1.text+'1';
end;
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'2';
end
else
begin
edt1.Text:=edt1.text+'2';
end;
end;
procedure TForm1.btn3Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'3';
end
else
begin
edt1.Text:=edt1.text+'3';
end;
end;
procedure TForm1.btn4Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'4';
end
else
begin
edt1.Text:=edt1.text+'4';
end;
end;
procedure TForm1.btn5Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'5';
end
else
begin
edt1.Text:=edt1.text+'5';
end;
end;
procedure TForm1.btn6Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'6';
end
else
begin
edt1.Text:=edt1.text+'6';
end;
end;
procedure TForm1.btn7Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'7';
end
else
begin
edt1.Text:=edt1.text+'7';
end;
end;
procedure TForm1.btn8Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'8';
end
else
begin
edt1.Text:=edt1.text+'8';
end;
end;
procedure TForm1.btn9Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'9';
end
else
begin
edt1.Text:=edt1.text+'9';
end;
end;
procedure TForm1.btn10Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'0';
end
else
begin
edt1.Text:=edt1.text+'0';
end;
end;
procedure TForm1.btn11Click(Sender: TObject);
begin
if edt1.Text='0'
then
begin
edt1.Text:='';
edt1.Text:=edt1.text+'00';
end
else
begin
edt1.Text:=edt1.text+'00';
end;
end;
procedure TForm1.btn12Click(Sender: TObject);
begin
if (edt1.Text='0') or (edt1.Text='00')
then
begin
edt1.Text:='0'+'.';
end
else
begin
edt1.Text:=edt1.text+'.';
end;
end;
procedure TForm1.btn_AClick(Sender: TObject);
begin
Form1.btn_G.Click();
tttt:=1;
temp:=StrToFloat(edt1.text);
edt1.Text:='';
end;
procedure TForm1.btn_BClick(Sender: TObject);
begin
Form1.btn_G.Click();
tttt:=2;
temp:=StrToFloat(edt1.text);
edt1.Text:='';
end;
procedure TForm1.btn_CClick(Sender: TObject);
begin
Form1.btn_G.Click();
tttt:=3;
temp:=StrToFloat(edt1.text);
edt1.Text:='';
end;
procedure TForm1.btn_DClick(Sender: TObject);
begin
Form1.btn_G.Click();
tttt:=4;
temp:=StrToFloat(edt1.text);
edt1.Text:='';
end;
procedure TForm1.btn_GClick(Sender: TObject);
begin
if edt1.Text=''
then
begin
edt1.Text:='0';
end;
begin
case tttt of
1:edt1.Text:=FloatToStr(temp+strtofloat(edt1.text));
2:edt1.Text:=FloatToStr(temp-strtofloat(edt1.text));
3:edt1.Text:=FloatToStr(temp*strtofloat(edt1.text));
4:begin
if (edt1.Text='') or (edt1.Text='0')
then
begin
edt1.Text:='0'
end
else
begin
edt1.Text:=FloatToStr(temp/strtofloat(edt1.text));
end
end;
end;
end;
end;
end.
|
评分
-
查看全部评分
|