by Mark A (aka Aldinator) (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 15th September 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This is a StopWatch ... enough said.
Private mill, second, minute, hour As Integer
'add a timer (tmrStopWatch, label (lblTime), 3 command buttons (cmdStart, cmdStop, cmdReset)
Private Sub ResetValues()
mill = 0
second = 0
minute = 0
hour = 0
End Sub
Private Sub cmdReset_Click()
tmrStopWatch.Interval = 0
ResetValues
mill = mill - 1
lblTime.Caption = "00:00:00.0"
End Sub
Private Sub cmdStart_Click()
lblTime.Caption = "00:00:00.00"
ResetValues
tmrStopWatch.Interval = 100 ''ten milliseconds
End Sub
Private Sub cmdStop_Click()
If cmdStop.Caption = "Stop" Then
tmrStopWatch.Interval = 0
cmdStop.Caption = "Resume"
ElseIf cmdStop.Caption = "Resume" Then
tmrStopWatch.Interval = 100
cmdStop.Caption = "Stop"
End If
End Sub
Private Sub Form_Load()
ResetValues
lblTime.Caption = "00:00:00.0"
End Sub
Private Sub tmrStopWatch_Timer()
mill = mill + 1
If mill = 10 Then second = second + 1: mill = 0
If second = 60 Then minute = minute + 1: second = 0
If minute = 60 Then hour = hour + 1: minute = 0
lblTime.Caption = Format(Str(hour), "00") & ":" & _
Format(Str(minute), "00") & ":" & _
Format(Str(second), "00") & "." & _
Format(Str(mill), "0")
End Sub