Reputation: 195
When i run this code it displays the Date and time in two separate textbox but the timer doesn't run.I mean the seconds part not moving...Here is my code Thanks
Private Sub Studentattend_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = TimeString
TextBox2.Text = DateString
Label4.Text = Now
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label4.Text = TimeString
Label4.Text = Now
End Sub
Upvotes: 0
Views: 124
Reputation: 1799
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label4.Text = TimeString
Label4.Text = Now
End Sub
There's no point to change Label4.Text twice, just use Now.ToString() to format the time. For example, Label4.Text = Now.ToString("hh:mm:ss") will give you the current time in hh:mm:ss format. Also, make sure that the timer interval (measured in milliseconds) is correct. And if you want to update your textbox, you will have to add the code inside the Timer1_Tick:
TextBox1.Text = Now.ToString()
Upvotes: 2