Display time

  • Thread starter Thread starter Will
  • Start date Start date
W

Will

Hi there ..

I wanna know how to display the time in a label and have
it change every sec with the system cock ...

meaning that its always syncronized with the system clock,
Sec per sec.

I need the code.

Thanks Guys!
 
Will said:
Hi there ..

I wanna know how to display the time in a label and have
it change every sec with the system cock ...

meaning that its always syncronized with the system clock,
Sec per sec.

I need the code.

Thanks Guys!

Drop a Timer from the toolbox to your Form. Set Interval property = 500. In
the timer's tick event, update the label. Date.Now returns the current date
and time. Call the ToString method of the returned date object. You can pass
the needed format to the function.
 
* "Will said:
I wanna know how to display the time in a label and have
it change every sec with the system cock ...

meaning that its always syncronized with the system clock,
Sec per sec.

Add a timer control ('System.Windows.Forms.Timer' to your form, set its
'Interval' property to 1000 and add this code to its 'Tick' event
handler:

\\\
Me.Label1.Text = DateTime.Now.ToShortTimeString()
///
 
* "Armin Zingler said:
Drop a Timer from the toolbox to your Form. Set Interval property = 500. In

Setting it to 500 is clever! I didn't think of that...
 
Back
Top