How do I put in the time and date on a form in VB.NET? I did what my book has told me but all it shows up as is 01/01/2000 on the date and the time reads 12:01:01 and doesn't change. So how do I make it show the correct time and date? There is another part in my book that explains how to put it in the status bar but I don't want to put them in the status bar. Please help me!
Entering the time and date on a form
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Andrew Wooster77 pointsPosted Dec 22, 2005, 6:16 AM EST
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatetimepickerclasstopic.asp
Although I don't think this has to do with your issue, on a side note, the DateTime class cannot be set to nothing.
Michael Puckett2 pointsPosted Dec 22, 2005, 7:58 PM EST
1. Add A timer to your form.
2. Click on timer and then click on property's.
3. Set enabled to True; Set Interval to 1000 (this causes the timer to tick; 1000 will tick every second.
4. Double click the timer and insert the following code.
label1.Text = CStr(Date.Today.Now)
5. Remember that label1 here is representing whatever you are using and should be replaced with your object. Example: If you want the forms' text to display the time, then use me.text = ....
6. Run the program and watch it keep time.
You can play with the Date class and get different displays of time and date. Hope this helps :)