1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| 'Code Module
Private Declare Function SetTimer Lib "User32" _
(ByVal hWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "User32" _
(ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
Dim TimerID As Long
Sub TestChrono()
UserForm1.Show
End Sub
Sub TimerOff()
KillTimer 0, TimerID
End Sub
Sub TimerOn(Interval As Long)
TimerID = SetTimer(0, 0, Interval, AddressOf Chrono)
End Sub
Sub Chrono()
Dim H, DS
DS = CByte(UserForm1.Label2.Caption) + 1
UserForm1.Label2.Caption = CStr(DS)
If (DS Mod 10) = 0 Then
H = TimeValue(UserForm1.Label1.Caption) - TimeSerial(0, 0, 1)
'Impossible de changer le format Label1 en "nn:ss" cela ne marche pas
UserForm1.Label1.Caption = Format(H, "hh:mm:ss")
UserForm1.Label4.Caption = Format(H, "mm:ss")
UserForm1.Label2.Caption = 0
End If
If TimeValue(UserForm1.Label1.Caption) = 0 Then
Beep
EnMarche = False
TimerOff
End If
End Sub |
Partager