So I've been trying for about a month or so but been busy recently so couldn't address it then. Here is the code.
Public Class Form1
Dim CurrentTime As DateTime
Private Sub ButtonStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonStart.Click
ButtonStart.Enabled = False
ButtonPause.Enabled = True
CurrentTime = DateTime.Now()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Timer1.Enabled = False Then
' Pause timer, since timer keeps accumulating, need to find a way to subtract the time gathered when the pause started until pause ends (determined by user).
Else
Dim CurrentTimeElapsed As TimeSpan = DateTime.Now.Subtract(CurrentTime)
Label1.Text = CurrentTimeElapsed.Hours.ToString.PadLeft(2, "0"c) + ":" + CurrentTimeElapsed.Minutes.ToString.PadLeft(2, "0"c) + ":" + CurrentTimeElapsed.Seconds.ToString.PadLeft(2, "0"c) + "." + CurrentTimeElapsed.Milliseconds.ToString.PadLeft(3, "0"c)
End If
End Sub
Private Sub ButtonPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPause.Click
If Timer1.Enabled = False Then
ButtonPause.Text = "Pause"
Timer1.Enabled = True
Else
ButtonPause.Text = "Resume"
Timer1.Enabled = False
End If
End Sub
End Class
I know that even when the timer is disabled, it still keeps on accumulating so I need a way that when the timer is paused, the timer doesn't keep on accumulating and when the timer is resumed, the timer continues from where it was when it was paused. Any help is greatly appreciated.