borgo
asked on
Countdown to 2000
I'm looking to code a 2000 countdown timer.
Do you have any design advice ?
Have I to use label component and thread ? Or what else ?
I use TDate component. Then I calculate the days to the 1/1/2000 How can I print the TDate value as dd/mm/yy hh:mm:ss ? I try with DateToStr but it's a value like dd/mm/yy.
Do you have any design advice ?
Have I to use label component and thread ? Or what else ?
I use TDate component. Then I calculate the days to the 1/1/2000 How can I print the TDate value as dd/mm/yy hh:mm:ss ? I try with DateToStr but it's a value like dd/mm/yy.
hi borgo,
in addition to madshi a year 2000 Countdown
procedure TForm1.Timer1Timer(Sender: TObject);
Var
R : Real;
begin
r := StrToDateTime('01/01/2000 00:00:00') - Now;
Label1.caption := FloatToStr(Int(r)) + ' Days ' +TimeToStr(r);
end;
meikl
in addition to madshi a year 2000 Countdown
procedure TForm1.Timer1Timer(Sender:
Var
R : Real;
begin
r := StrToDateTime('01/01/2000 00:00:00') - Now;
Label1.caption := FloatToStr(Int(r)) + ' Days ' +TimeToStr(r);
end;
meikl
Hi meikl, looks nice... :-)
ASKER
Thank you Madshi.
But I find that the kretzschmar's answer is easier than yours.
But I find that the kretzschmar's answer is easier than yours.
No prob...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could use a label component. But I would suggest a simple TTimer object to do the work. Normally you don't need a thread for this.
Then you could use the function DateTimeToSystemTime, which converts TDateTime to TSystemTime.
type
TSystemTime = record
wYear: Word;
wMonth: Word;
wDayOfWeek: Word;
wDay: Word;
wHour: Word;
wMinute: Word;
wSecond: Word;
wMilliseconds: Word;
end;
Then you can format the string yourself.
More questions? Please ask... :-)
Regards, Madshi.