delphi undeclared identfier

来源:百度知道 编辑:UC知道 时间:2024/07/05 19:22:24
我运行以下代码:

procedure TForm1.Timer1Timer(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDateTime(Present, Year, Month, Day, Hour, Min, Sec, MSec);
StatusBar1.Panels[0].text:='现在的时间是:'+inttostr(Year)+'年'+inttostr(Month)+'月'+inttostr(Day)+'日'+inttostr(Hour)+'时'+inttostr(Min)+'分'+inttostr(Sec)+'秒';

end;
为什么老提示[Error] mainform1.pas(111): Undeclared identifier: 'DecodeDateTime'

'DecodeDateTime'这个函数没有声明.
你没有引用dateutils.pas单元文件.
你需要在interface或者implementation 后面加上 uses dateutils;
不过 个人意见 在implementation 后面加上 uses dateutils;
这样编译出来的文件会小一些.

未引用单元!
就象C里的库函数,你都要加相应的都文件,才能使用某些函数

因为你没有在代码最上面的uses中添加DateUtils的引用