Public stp As Boolean
Public OldH
Public OldM
Public OldS
Public OLDMLN
Private Sub CommandButton1_Click()
stp = False
CommandButton1.Enabled = False
CommandButton2.Enabled = True
CommandButton3.Enabled = False
H = 0
For M = 0 To 59
For S = 0 To 59
For MLN = 0 To 59
t = Timer
Do Until Timer - t >= 1 / 60
DoEvents
Loop
If stp = True Then GoTo X
Label1.Caption = _
Format(H, "00") & ":" & Format(M, "00") _
& ":" & Format(S, "00") & ":" & Format(MLN, "00")
Next MLN
Next S
Next M
H = H + 1
X:
OldH = H
OldM = M
OldS = S
OLDMLN = MLN
stp = False
End Sub
Private Sub CommandButton2_Click()
CommandButton1.Enabled = True
CommandButton2.Enabled = False
CommandButton3.Enabled = True
stp = True
End Sub
Private Sub CommandButton3_Click()
CommandButton3.Enabled = False
CommandButton2.Enabled = True
CommandButton1.Enabled = False
stp = False
H = OldH
For M = OldM To 59
For S = OldS To 59
For MLN = OLDMLN To 59
t = Timer
Do Until Timer - t >= 1 / 60
DoEvents
Loop
If stp = True Then GoTo X
Label1.Caption = _
Format(H, "00") & ":" & Format(M, "00") _
& ":" & Format(S, "00") & ":" & Format(MLN, "00")
Next MLN
Next S
Next M
H = H + 1
X:
OldH = H
OldM = M
OldS = S
OLDMLN = MLN
stp = False
End Sub
Private Sub CommandButton4_Click()
Unload Me
End
End Sub
Private Sub UserForm_Initialize()
CommandButton1.Enabled = True
CommandButton1.Caption = "Start Timer"
CommandButton2.Enabled = False
CommandButton2.Caption = "Stop"
CommandButton3.Enabled = False
CommandButton3.Caption = "Resume Timer"
CommandButton4.Caption = "Cancel"
Label1.Caption = "00:00:00:00"
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub