| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1153 人关注过本帖
标题:求助delphi
取消只看楼主 加入收藏
sheng443
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-7-1
收藏
 问题点数:0 回复次数:0 
求助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]]
搜索更多相关主题的帖子: delphi 
2008-09-12 18:14
快速回复:求助delphi
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031767 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved