偶用time做个记时器  在time里编辑           label1.caption:=inttostr(strtoint(label1.caption)+1;
---但运行时候出错自动删除了所有代码

解决方案 »

  1.   

    你的括号都不匹配啊
    strtoint(label1.caption) 
    如果不能转换会出现异常
      

  2.   

     label1.caption内容固定吗,如果不固定用StrToIntDef(label1.caption,0)
      

  3.   

    label1.caption:=inttostr(strtoint(label1.caption)+1);
    ---这个是书上的代码呀 
      

  4.   

    偶用time做个记时器   在time里编辑           label1.caption:=inttostr(strtoint(label1.caption)+1; 
    ---但运行时候出错自动删除了所有代码label1.caption:=inttostr(strtoint(label1.caption)+1); 
    ---这个是书上的代码呀 以上两次的代码一样吗?
      

  5.   

    在timer的事件里面写  设定时间间隔为1000
      

  6.   


    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        Timer1: TTimer;
        Label1: TLabel;
        Button1: TButton;
        Button2: TButton;
        procedure Timer1Timer(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
    begin
        label1.caption:=inttostr(strtoint(label1.caption)+1);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      Timer1.Enabled:=false;     // stop the timer
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
       Timer1.Enabled:=true;     // start the timer
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      label1.caption:='1';
    end;end.