Option Explicit
Dim StopTimer As Boolean
Dim Etime As Single
Dim Etime0 As Single
Dim LastEtime As Single
Dim lapnr As Integer
Private Sub ExitBtn_Click()
StopTimer = True
Unload Me
End Sub
Private Sub ResetBtn_Click()
StopTimer = True
Etime = 0
Etime0 = 0
LastEtime = 0
ElapsedTimeLbl.Caption = "00:00:00.00"
End Sub
Private Sub StartBtn_Click()
StopTimer = False
Etime0 = timer() - LastEtime
Me.Repaint
Do Until StopTimer
Etime = Int((timer() - Etime0) * 100) / 100
If Etime > LastEtime Then
LastEtime = Etime
ElapsedTimeLbl.Caption = Format(Etime / 86400, "hh:mm:ss.") & Format(Etime * 100 Mod 100, "00")
DoEvents
End If
Loop
End Sub
Private Sub StopBtn_Click()
StopTimer = True
Laplbl = ""
Beep
End Sub
Private Sub LapBtn_click()
Laplbl.Caption = ElapsedTimeLbl
lapnr = lapnr + 1
Range("A" & lapnr) = "lap " & lapnr
Range("B" & lapnr) = ElapsedTimeLbl
End Sub
Private Sub UserForm_Activate()
Range("A:B") = ""
ElapsedTimeLbl = "00:00:00.00"
End Sub