Hi folks.
I have a stopwatch app that works great, but it counts up from 00:00:00(which is what I set the initial time to be). I can set the label to start at 00:45:00, but how can I make it count down to 00:00:00?
Thanks in advance.
I have a stopwatch app that works great, but it counts up from 00:00:00(which is what I set the initial time to be). I can set the label to start at 00:45:00, but how can I make it count down to 00:00:00?
Thanks in advance.
Code:
Public Class MyStopwatch
Dim sw As New Stopwatch
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles bttnStartStop.Click
If bttnStartStop.Text = "Start" Then
bttnStartStop.Text = "Stop"
Timer1.Start()
sw.Start()
Me.TopMost = False
ElseIf bttnStartStop.Text = "Stop" Then
bttnStartStop.Text = "Start"
Timer1.Stop()
sw.Stop()
Me.TopMost = True
End If
End Sub
Private Sub bttnReset_Click(sender As System.Object, e As System.EventArgs) Handles bttnReset.Click
Timer1.Stop()
sw.Reset()
Label1.Text = "00:00:00"
bttnStartStop.Text = "Start"
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Dim ts As TimeSpan = sw.Elapsed
Label1.Text = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds)
If ts.Minutes = 45 Then
sw.Reset()
Timer1.Stop()
frmBreak.ShowDialog()
Me.TopMost = True
bttnStartStop.Text = "Start"
Label1.Text = "00:00:00"
End If
End Sub
End Class