laroberts Posted June 30, 2005 Posted June 30, 2005 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 Quote
kejpa Posted June 30, 2005 Posted June 30, 2005 use a timer and set the labels text when the timer ticks. hth /kejpa (today in all lower case ;)) Quote
laroberts Posted July 1, 2005 Author Posted July 1, 2005 ??? Yes but how will that get the correct time to display? Also do you have a code example? Thank you Quote
jmcilhinney Posted July 1, 2005 Posted July 1, 2005 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:Me.Label1.Text = Date.Now.ToLongTimeString()The Date type also supports ToShortTimeString and ToString with format information. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.