I am new to vb and trying to create a timer that will countdown for sets of time interval. I managed to display the countdown for enddate but I have no idea how to continue to enddate1 as soon as enddate finished.
My code as follows:
Public Class Form1
Dim startdate As DateTime = DateTime.Parse(Date.Now)
Dim enddate As DateTime = DateTime.Parse("14:41")
Dim enddate1 As DateTime = DateTime.Parse("14:42")
Dim ts As TimeSpan = enddate.Subtract(startdate)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ts = ts.Subtract(New TimeSpan(0, 0, 1)) '~~~ Subtract 1 second
'~~~ Display it
Label1.Text = CStr(ts.Hours) & " Hours: " & CStr(ts.Minutes) & " minuter: " & CStr(ts.Seconds) & " second"
'~~~ Check if the countdown is finished or not
If Math.Floor(ts.TotalSeconds) = 0 Then
Timer1.Stop()
MessageBox.Show("Finished !")
End If
End Sub
End Class