标题:帮忙看看这段DELPHI代码是什么执行的
只看楼主
cch8080
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-3-18
结帖率:100%
 问题点数:0 回复次数:0 
帮忙看看这段DELPHI代码是什么执行的

请大家帮我看看这段代码是什么执行的,我什么看的糊里糊涂的,谢谢大家了!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, ExtCtrls;

type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
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;
procedure FormCreate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton12Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
var
s:word;
x,y:real;
v:boolean;
{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
s:=0;
x:=0;
y:=0;
v:=false;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
if form1.Tag=1 then
begin
if tag=10 then panel2.Caption:='0.'
else panel2.Caption:=(sender as tspeedbutton).Caption;
form1.Tag:=0;
end
else panel2.Caption:=panel2.Caption+(sender as tspeedbutton).Caption;
end;

procedure TForm1.SpeedButton12Click(Sender: TObject);
begin
form1.Tag:=1;
if v then
begin
x:=strtofloat(panel2.Caption);
v:=not v;
end
else
begin
y:=strtofloat(panel2.Caption);
case s of
0:panel2.Caption:=format('%g',[x+y]);
1:panel2.Caption:=format('%g',[x-y]);
2:panel2.Caption:=format('%g',[x*y]);
3:if y<>0 then
panel2.Caption:=format('%g',[x/y])
else
begin
showmessage('不能以0为除数!');
panel2.Caption:=format('%g',[x]);
v:=false;
end;
4:begin
y:=0;
v:=false;
end;
end;
x:=strtofloat(panel2.Caption);
end;
s:=(sender as tspeedbutton).Tag;
end;
end.

搜索更多相关主题的帖子: DELPHI 代码 
2007-04-03 16:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-128937-1-1.html




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

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