Re : VBA chrono excel
re bonjour
cela fonctionne mais j ai un son continue toute les secondes je voudrais remplacer un constant par un seul par quoi remplacer ?merci
Const SIGNAL As Long = 30 'délai en secondes du beep avant la fin du chrono ///
'gestion chrono
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
Public Compteur As Long '///
Public LimiteStop As Long '###
Option Explicit
Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Dim TimerID As Long
Sub Play()
If PlaySound("C:\Users\utilisateur\Music\camion.wav", 0, 1) = 0 Then MsgBox "Fichier Wav inexistant"
End Sub
Sub TestChrono()
'lancement Userform
UserForm1.Show
End Sub
Sub TimerOff()
'arret du chrono
KillTimer 0, TimerID
If PlaySound("C:\Users\utilisateur\Music\camion.wav", 0, 1) = 0 Then MsgBox "Fichier Wav inexistant"
End Sub
Sub TimerOn(Interval As Long)
' en relation avec le bouton start du chrono
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
Compteur = Compteur + 1 '///
If Compteur + SIGNAL >= CLng(UserForm1.Label7) Then Play '###
H = TimeValue(UserForm1.Label1.Caption) + TimeSerial(0, 0, 1)
UserForm1.Label1.Caption = Format(H, "hh:nn:ss")
UserForm1.Label2.Caption = "0"
If Compteur = CLng(UserForm1.Label7) Then '###
Compteur = 0 '///
Call TimerOff '///
End If '///
End If
End Sub