hey, what do i have to write, if i want date&time which updates itself? Label3.Caption := TimeToStr(Time) this just shows me the time, when i opened the program, but i want a time, that updates to the form every second (--> like a normal clock does).
1) Drop a TTimer object on your form
2) Set its 'Interval' propert to 1000 and its 'Enabled' property to true.
3) Double click on it to create an OnTimer event handler. Modify it som it looks something like this:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label3.Caption := TimeToStr(Time)
end;
And there you have it...
So drop a timer on the form, set to tick every 500ms or so, and write the time to your text time field in the event handler for the timer. You need to tick faster than smallest time interval you want to display. Note also that windows timers are pretty low priority, so if the CPU gets loaded, your timer might seem to "stick".
You can use the Timer component to update the label caption every second.
- Drop a timer on your form.
- Set the Interval property to 500, which will update the caption every half second.
- Set the Enabled property to true.
Double click on the timer and add the following code.
Label3.Caption := TimeToStr(Time)
You can also use the FormatDateTime function, to change how time is displayed