Continuous timer Help!

I am new to VB and i have problem with my timer, I managed to run the timer until enddste 1.
How do I continue beyond that?

this is my code

Public Class Form1

Dim startdate As DateTime = DateTime.Parse(Date.Now)
Dim enddate As DateTime = DateTime.Parse("21:53:00")
Dim enddate1 As DateTime = DateTime.Parse("21:54:00")
Dim enddate2 As DateTime = DateTime.Parse("21:55:00")
Dim enddate3 As DateTime = DateTime.Parse("21:56:00")
Dim enddate4 As DateTime = DateTime.Parse("21:57:00")
Dim enddate5 As DateTime = DateTime.Parse("21:58:00")
Dim Flag As Boolean
Dim ts, ts1, ts2, ts3, ts4, ts5, ts6, ts7, ts8, ts9, ts10, ts11, ts12 As TimeSpan
Dim ts13, ts14, ts15, ts16, ts17, ts18, ts19, ts20, ts21, ts22, ts23, constant As TimeSpan
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
ts = enddate.Subtract(startdate)
ts1 = enddate1.Subtract(enddate)
ts2 = enddate2.Subtract(enddate2)
ts3 = enddate3.Subtract(enddate3)
ts4 = enddate4.Subtract(enddate4)
ts5 = enddate5.Subtract(enddate5)
Flag = True
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
ts2 = ts2.Subtract(New TimeSpan(0, 0, 1))
ts4 = ts4.Subtract(New TimeSpan(0, 0, 1))
'~~~ 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
If Flag = True Then
ts = ts1
Flag = False
ElseIf Flag = True Then
ts2 = ts3
Flag = False
ElseIf Flag = True Then
ts4 = ts5
Flag = False
End If
MessageBox.Show("Finished !")
End If
End Sub

End Class
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!