- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
//source 源码 unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, Buttons;
type
TForm2 = class(TForm) soleplate: TPanel; nu1: TSpeedButton; nu2: TSpeedButton; nu3: TSpeedButton; op1: TSpeedButton; nu4: TSpeedButton; op2: TSpeedButton; nu7: TSpeedButton; nu8: TSpeedButton; nu9: TSpeedButton; display: TPanel; nu6: TSpeedButton; nu0: TSpeedButton; nu10: TSpeedButton; op5: TSpeedButton; nu5: TSpeedButton; op3: TSpeedButton; op4: TSpeedButton; procedure FormCreate(Sender: TObject); procedure nu1Click(Sender: TObject); procedure op1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Tign:Word;
a,b:Real;
q:Boolean;
implementation {$R *.dfm}
procedure TForm2.FormCreate(Sender: TObject);
begin
Tign :=0;
a:=0;b:=0; q:=False;
end;
procedure TForm2.nu1Click(Sender: TObject);
begin
if Form2.Tag=0 then display.Caption:=display.Caption+(Sender as TSpeedButton).Caption else begin
if Tag=10 then display.Caption:=0 else
display.Caption:=(Sender as TSpeedButton).Caption; Form2.Tag:=0;
end;
end;
procedure TForm2.op1Click(Sender: TObject);
begin
Form2.Tag:=1;
if q then begin
a:=StrToFloat(display.Caption);
q:=not q; end
else
begin b:=StrToFloat(display.Caption); case Tign of
0:display.Caption:=Format(%g,[a+b]); 1:display.Caption:=Format(%g,[a-b]); 2:display.Caption:=Format(%g,[a*b]);
3:if b0then display.Caption:=Format(%g,[a/b]) else
begin
ShowMessage(除数不能为 0!);
display.Caption;Format(%g,[a]);
q:=False;
end;
4:begin
b:=0;q:=False;
end;
end;
a:=StrToFloat(display.Caption);
end;
Tign:=(Sender as TSpeedButton).Tag;
end;
end.
//
//form 源码
object Form2: TForm2
Left = 0
Top = 0
Caption = #35745#31639#22120
ClientHeight = 442
ClientWidth = 537
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = Tahoma
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object soleplate: T
文档评论(0)