Hi
Here is a simplified stand alone example, not completely checked, but should work OK. See if this helps.
' Form1 with Label1
Option Strict On
Option Explicit On
Public Class Form1
Dim sw As New Stopwatch
Dim switch As Boolean = True
Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown
Label1.Text = "Start"
End Sub
Sub DoTimer()
sw.Start()
' simulate running process loop
Do
Label1.Text = GetTime(sw.ElapsedMilliseconds)
Application.DoEvents()
' dummy load
Threading.Thread.Sleep(1000)
Loop Until switch
End Sub
Function GetTime(ms As Long) As String
Dim secs As Long = 1000
Dim mins As Long = 60 * secs
Dim hrs As Long = 60 * mins
Dim h As Long = (ms \ hrs)
Dim m As Long = (ms - (h * hrs)) \ mins
Dim s As Long = (ms - (h * hrs) - (m * mins)) \ secs
Dim rs As String = s.ToString("00s")
If m > 0 Then rs = m.ToString("00m ") & s.ToString("00s")
If h > 0 Then rs = h.ToString("00h ") & m.ToString("00m ") & s.ToString("00s")
Return rs
End Function
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
' NOTE: sw is kept running
If switch Then
switch = False
DoTimer()
Else
switch = True
End If
End Sub
End Class