我用的是D6:
    问题如下:
            原代码:unit time;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Timer1: TTimer;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
   Label1.Caption:='当前时间:';
   Label2.Caption:=TimeToStr(Time);{这里不知道有什么问题?}   Label1.Visible:=true;
   Label2.Visible:=true;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
     Label1.Caption:=' ';
     Label2.Caption:=' ';     Label1.Visible:=false;
     Label2.Visible:=false;
end;procedure TForm1.Button3Click(Sender: TObject);
begin
   close;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
   Timer1.Enabled:=true;
end;end.问题提示:
      [Error] time.pas(37): '.' expected but ')' found
      [Fatal Error] Dtime.dpr(5): Could not compile used unit 'time.pas'
谢谢各位大虾指点小弟。

解决方案 »

  1.   

    一个这样的问题就放200分。分真多,羡慕.........
    改:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
       Label1.Caption:='当前时间:';
       Label2.Caption := DateTimeToStr(TimeOf(Now));//取的仅仅是时间。时、分、秒。
       Label2.Caption := DateTimeToStr(DateOf(Now))
       Label2.Caption:=DateTimeToStr(Now);//都取
       Label1.Visible:=true;
       Label2.Visible:=true;
    end;Uses
      DateUtils;
      

  2.   

    Label2.Caption:=TimeToStr(Time);{这里不知道有什么问题?改成  Label2.Caption:=TimeToStr(now);
      

  3.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
       Timer1.Enabled:=true;
    end;//你这是什么意思?每个激活事件都要置其Enable := True?没有任何意义。
      

  4.   

    这儿的代码没问题  procedure TForm1.Timer1Timer(Sender: TObject);
    begin
       Timer1.Enabled:=true;
    end;编译应该可以通过的
      

  5.   

    Label2.Caption:=TimeToStr(now);还有这个.....
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
       Timer1.Enabled:=true;
    end;如果你程序初试化时候timer1的enabled为false的话,那么它永远无法为true
      

  6.   

    你的这段代码没问题,我试过,可能问题出在别的地方。
    不知道你的timer组件干什么用?你这样可能没用吧。如果你想让时间动态变化显示,跟电子表一样,你应该把buttonclick的代码写道timer1的ontimer事件里,同时设置好timer的属性
      

  7.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
       Timer1.Enabled:=true;
    end;这句话没什么意义!你的代码没有任何问题,可能是别的原因。
    请把你的PAS文件名换一下,有可能和DELPHI的内部PAS文件同名而出错!
      

  8.   

    unit time 改一下 unit time1 等等
      

  9.   

    Time 是 Object 关键字 ,不能用在单元名中