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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| Option Explicit
Dim marche As Boolean, arret As Boolean
Private Sub QUITTER_Click()
End
End Sub
Sub chrono()
Dim départ As Double, ARRIVÉE As Double, durée As Double
Dim j As Long, i As Long, sd As Long, ms As Long
Dim mn As Long, tps As String, Temps As Double
i = 14
départ = GetTickCount&
'DoEvents
Do
Do While marche And Not arret '-> le bouton PAUSE entraîne [marche = False] => Sortie de cette boucle
ARRIVÉE = GetTickCount&
durée = ARRIVÉE - départ
Label1.Caption = durée
DoEvents 'Laisse un délai pour l'affichage (tout petit petit...)
Loop
If Not arret And Not marche Then
durée = ARRIVÉE - départ
mn = Int(durée / 1000 / 60)
sd = Int((durée / 1000) - (mn * 60))
ms = durée - (sd * 1000) - (mn * 1000 * 60)
tps = mn & ":" & sd & ":" & ms
LabelTemp.Caption = tps
Temps = Val(mn & "." & Right("00" & sd, 2) & Right("000" & ms, 3))
DoEvents
marche = True
End If
Loop Until arret
durée = ARRIVÉE - départ
mn = Int(durée / 1000 / 60)
sd = Int((durée / 1000) - (mn * 60))
ms = durée - (sd * 1000) - (mn * 1000 * 60)
tps = mn & ":" & sd & ":" & Right("000" & ms, 3)
LabelFin.Caption = tps
Temps = Val(mn & "." & Right("00" & sd, 2) & Right("000" & ms, 3))
End Sub
Private Sub DEPART_Click()
If Not marche Then
Init
arret = False
marche = True
chrono
End If
End Sub
Private Sub PAUSE_Click()
Dim j As Long
marche = Not marche
For j = 1 To 10000
DoEvents
Next
End Sub
Sub Init()
LabelTemp.Caption = "00:00:00"
LabelFin.Caption = "00:00:00"
End Sub
Private Sub ARRIVEE_Click()
arret = True
marche = False
End Sub
Private Sub UserForm_Initialize()
Init
End Sub |
Partager