Delphi里从Edit1到Edit5,初始值都为0,第一秒Edit1变为1;第二秒Edit2变为2;依次五个Edit全变位1,怎么写
3个回答
展开全部
你先在窗体上添加5个edit1-edit5,将5个编辑框TEXT值均设为0,再添加一个按钮BUTTON1,再添加一计时器Timer1,将timer1的INTERVAL值设为1000,将Enabled设为FALSE,代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Button1: TButton;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
button1.OnClick(sender);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if timer1.Enabled=false then
timer1.Enabled:=true;
if edit4.Text='1' then
edit5.Text:='1';
if edit3.Text='1' then
edit4.Text:='1';
if edit2.Text='1' then
edit3.Text:='1';
if edit1.Text='1' then
edit2.Text:='1';
if edit1.Text='0' then
edit1.Text:='1';
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Button1: TButton;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
button1.OnClick(sender);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if timer1.Enabled=false then
timer1.Enabled:=true;
if edit4.Text='1' then
edit5.Text:='1';
if edit3.Text='1' then
edit4.Text:='1';
if edit2.Text='1' then
edit3.Text:='1';
if edit1.Text='1' then
edit2.Text:='1';
if edit1.Text='0' then
edit1.Text:='1';
end;
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询