Show current date and time in real time....

laroberts

Freshman
Joined
Jun 29, 2005
Messages
34
I am looking for a way to display the current time and date in real time on my forms on a label. Can somebody show me the exact code to do this?

Thank you
 
use a timer and set the labels text when the timer ticks.

hth
/kejpa

(today in all lower case ;))
 
Add a System.Windows.Forms.Timer to your form, in design view, called Timer1. Add a Label to your form called Label1. Set the Timer Interval to 1000 (milliseconds) and Enabled to True. Double-click the Timer to create a handler for the default event, which is Tick. In the event handler put this line of code:
Visual Basic:
Me.Label1.Text = Date.Now.ToLongTimeString()
The Date type also supports ToShortTimeString and ToString with format information.
 
Back
Top