chrono excel
bonjour a tous voici mon module pour mon emettre un son en fin de temps ,quand je lance le chrono un message apparait sur le vba pour m informer que pour Z une erreur de compilation:instruction incorrecte a l exterieur d une procedure
pouvez vous me renseigner svp ou me donner une autre astuce pour garder mes beeps des 30 secondes et emettre un son a la fin du chrono
cordialement
phil69
'***********************************************'
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
Public Declare Function Beep Lib "kernel32.dll" _
(ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Private Declare Function GetTickCount Lib "kernel32.dll" () As Longng
If PlaySound(Z, 0, 1) = 0 Then MsgBox Z & " inexistant"
ChDir C: Users , Utilisateur, Music, camion.wav
Dim TimerID As Long
Sub TestChrono()
'lancement Userform
UserForm1.Show
End Sub
Sub TimerOff()
'arret du chrono
KillTimer 0, TimerID
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 Beep '###
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
apparament Z ne ui convient