求助delphi
请问如何写组件只单击一次有效,我是菜鸟,想写一个计算器,大家帮我看看(大家不好意思,可能是我没说明原因,我是想请问,当按了两个小数点的时候让它在eidt中显示一个),代码如下:unit Unit1;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
SpeedButton11: TSpeedButton;
SpeedButton12: TSpeedButton;
SpeedButton13: TSpeedButton;
SpeedButton14: TSpeedButton;
SpeedButton15: TSpeedButton;
SpeedButton16: TSpeedButton;
SpeedButton17: TSpeedButton;
SpeedButton18: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
procedure SpeedButton8Click(Sender: TObject);
procedure SpeedButton9Click(Sender: TObject);
procedure SpeedButton10Click(Sender: TObject);
procedure SpeedButton11Click(Sender: TObject);
procedure SpeedButton13Click(Sender: TObject);
procedure SpeedButton14Click(Sender: TObject);
procedure SpeedButton15Click(Sender: TObject);
procedure SpeedButton16Click(Sender: TObject);
procedure SpeedButton17Click(Sender: TObject);
procedure SpeedButton18Click(Sender: TObject);
procedure SpeedButton12Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a,c:Double;
b:integer;
implementation
{$R *.dfm}
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
edit1.Text:=edit1.text+'1';
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
edit1.Text:=edit1.text+'2';
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
edit1.Text:=edit1.text+'3';
end;
procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
edit1.Text:=edit1.text+'4';
end;
procedure TForm1.SpeedButton5Click(Sender: TObject);
begin
edit1.Text:=edit1.text+'5';
end;
procedure TForm1.SpeedButton6Click(Sender: TObject);
begin
edit1.Text:=edit1.text+'6';
end;
procedure TForm1.SpeedButton7Click(Sender: TObject);
begin
edit1.Text:=edit1.text+'7';
end;
procedure TForm1.SpeedButton8Click(Sender: TObject);
begin
edit1.Text:=edit1.text+'8';
end;
procedure TForm1.SpeedButton9Click(Sender: TObject);
begin
edit1.Text:=edit1.text+'9';
end;
procedure TForm1.SpeedButton10Click(Sender: TObject);
begin
edit1.Text:=edit1.text+'0';
end;
procedure TForm1.SpeedButton11Click(Sender: TObject);
begin
edit1.Text:=edit1.Text+'.';
end;
procedure TForm1.SpeedButton13Click(Sender: TObject);
begin
b:=1;
a:=strtofloat(edit1.Text);
edit1.Clear;
end;
procedure TForm1.SpeedButton14Click(Sender: TObject);
begin
b:=2;
a:=strtofloat(edit1.Text);
edit1.Clear;
end;
procedure TForm1.SpeedButton15Click(Sender: TObject);
begin
b:=3;
a:=strtofloat(edit1.Text);
edit1.Clear;
end;
procedure TForm1.SpeedButton16Click(Sender: TObject);
begin
b:=4;
a:=strtofloat(edit1.Text);
edit1.Clear;
end;
procedure TForm1.SpeedButton17Click(Sender: TObject);
begin
edit1.clear;
end;
procedure TForm1.SpeedButton18Click(Sender: TObject);
begin
close;
end;
procedure TForm1.SpeedButton12Click(Sender: TObject);
begin
case b of
1:c:=a+strtofloat(edit1.text);
2:c:=a-strtofloat(edit1.text);
3:c:=a*strtofloat(edit1.text);
4:c:=a/strtofloat(edit1.text);
end;
edit1.text:=floattostr(c);
end;
end.
[[it] 本帖最后由 sheng443 于 2008-9-13 01:59 编辑 [/it]]