Create a project with a form。
drag a TTimer and a label。
所有代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FInc, FNum: Integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Caption := IntToStr(FNum);
FNum := FInc + FNum;
if FNum = 9 then
FInc := -1;
if FNum = 0 then
FInc := 1;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FInc := 1;
FNum := 0;
end;
end.