K
kensou
Unregistered / Unconfirmed
GUEST, unregistred user!
需要两个时钟程序
一个是console程序
我的代码如下program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
aaa,bbb:string;
begin
{ TODO -oUser -cConsole Main : Insert code here }
Present:= Now;
DecodeDate(Present, Year, Month, Day);
aaa := 'DATE is:' + IntToStr(YEAR) + ' nian '
+ IntToStr(Month) + ' yue ' + IntToStr(day)+' ri ';
DecodeTime(Present, Hour, Min, Sec, MSec);
bbb := 'TIME is:' + IntToStr(HOUR) + ':'
+ IntToStr(min)+':'+inttostr(sec);
writeln (' ####################################');
writeln (' # '+aaa+' #');
writeln (' # '+bbb+' #');
writeln (' # press ctrl+C to exit #');
writeln (' ####################################');
readln;
end.
问题很明显 ,不能动态刷新数据,请高手帮忙修改
第二个要求在mainmenu的菜单项目的caption动态显示当前时间和日期
我的代码如下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
d,t:string;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
mainmenu1.items[2].Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime(Present, Hour, Min, Sec, MSec);
mainmenu1.items[3].Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
end;
end.
我觉得这么做不对,但又想不到其他办法
调试时会出现list out of bonds 错误
到底该怎样做呢
望各位高手指点迷津
一个是console程序
我的代码如下program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
aaa,bbb:string;
begin
{ TODO -oUser -cConsole Main : Insert code here }
Present:= Now;
DecodeDate(Present, Year, Month, Day);
aaa := 'DATE is:' + IntToStr(YEAR) + ' nian '
+ IntToStr(Month) + ' yue ' + IntToStr(day)+' ri ';
DecodeTime(Present, Hour, Min, Sec, MSec);
bbb := 'TIME is:' + IntToStr(HOUR) + ':'
+ IntToStr(min)+':'+inttostr(sec);
writeln (' ####################################');
writeln (' # '+aaa+' #');
writeln (' # '+bbb+' #');
writeln (' # press ctrl+C to exit #');
writeln (' ####################################');
readln;
end.
问题很明显 ,不能动态刷新数据,请高手帮忙修改
第二个要求在mainmenu的菜单项目的caption动态显示当前时间和日期
我的代码如下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
d,t:string;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
mainmenu1.items[2].Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime(Present, Hour, Min, Sec, MSec);
mainmenu1.items[3].Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
end;
end.
我觉得这么做不对,但又想不到其他办法
调试时会出现list out of bonds 错误
到底该怎样做呢
望各位高手指点迷津