I have following code for date and time in vb.net.
I am not able to set timer in the textbox 4 and 5.
What could be there in timer1 event?

        Dim theDate As Date
        theDate = Format(Now(), "short date")
        TextBox1.Text = theDate


        Dim mytime As System.DateTime
        Dim hours As Double = 2
        mytime = Now.ToShortTimeString


        TextBox2.Text = mytime
        Textbox3.Text = mytime.AddHours(+hours)

        Timer1.Start()

if you want to show date and time in textbox means?

Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        TextBox4.Text = DateTime.Now.Date
        TextBox5.Text = DateTime.Now.TimeOfDay.ToString()
End Sub

i have set only date in textbox1 and system time in textbox2 and time 2 hrs later in textbox3.
So that if anyone want to change time , he can
I just want to start timer in textbox2 and 3

Edited 2 Years Ago by Satyam_1

Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        TextBox1.Text = DateTime.Now.Date
        TextBox2.Text = DateTime.Now.TimeOfDay.ToString()
        TextBox3.Text = DateTime.Now.AddHours(2).TimeOfDay
End Sub

Hope this will help you!

This question has already been answered. Start a new discussion instead.