Question 1:
I placed a timer "timStopwatch" in the form "frmStopwatch". Now, the stopwatch code is contained in a module "modStopwatch". All the variables listed have been declared in Sub Main().
Stopwatch code:
Code: Select all
Public Function StopwatchRun()
If Hours = 99 Then
frmStopwatch.timStopwatch.Enabled = False
Message = MsgBox("The timer has reached its limit of 99 hours. The stopwatch has been shut down.", vbOKOnly + vbExclamation, "Warning")
Else
If Minutes = 60 Then
Hours = Hours + 1
Minutes = 0
Else
If Seconds = 60 Then
Minutes = Minutes + 1
Seconds = 0
Else
If Milliseconds = 60 Then
Seconds = Seconds + 1
Milliseconds = 0
Else
Milliseconds = Milliseconds + 1
End If
End If
End If
End If
StopwatchRun = Milliseconds
End Function
Now, for the timer code:
Code: Select all
Private Sub timStopwatch_Timer()
lblTime.Caption = StopwatchRun()
End Sub
Question 2:
How do I make it so lblTime shows:
Hours : Minutes : Seconds : Milliseconds
In that orders? Hours, Minutes, Seconds, and Milliseconds are all variables, but the colons aren't. I thought of:
Code: Select all
lblTime.Caption = Hours, ":", Minutes, ":", Seconds, ":", Milliseconds
Thanks if you help...