为什么我用Delphi刚刚运行的时候没有问题,但是关闭再次运行后出错
[FatalError]Projecttime.dpr(5):Couldnotcompileusedunit'time.pas'代码是:unittime;interfac...
[Fatal Error] Projecttime.dpr(5): Could not compile used unit 'time.pas'
代码是:
unit time;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ExtDlgs;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Timer1: TTimer;
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);
var
datetime:Tdatetime;
str:string;
begin
datetime:=time;
str:=timetostr(datetime);
Label1.caption:=str;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=not timer1.Enabled;
end;
end. 展开
代码是:
unit time;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ExtDlgs;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Timer1: TTimer;
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);
var
datetime:Tdatetime;
str:string;
begin
datetime:=time;
str:=timetostr(datetime);
Label1.caption:=str;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=not timer1.Enabled;
end;
end. 展开
3个回答
展开全部
time.pas文件有问题。另外,计时器代码可做如此简化:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label1.caption:=timetostr(gettime);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label1.caption:=timetostr(gettime);
end;
追问
那为什么刚刚编写完了运行可以,关闭后再次打开运行就出错了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-02-29 · 知道合伙人软件行家
关注
展开全部
[Fatal Error] Projecttime.dpr(5): Could not compile used unit 'time.pas'
从这段错误提示来看,你没有引入time.pas这个文件。
从这段错误提示来看,你没有引入time.pas这个文件。
追问
那怎样引入,刚刚编写完了运行可以,关闭后就出错了,谢谢先了
追答
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ExtDlgs, time;
注意,你需要找到time.pas,可能在delphi安装目录下,也可能是某个自定义的单元文件。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询