• Initiateur de la discussion Initiateur de la discussion phil69
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

phil69

XLDnaute Occasionnel
bonjour le forum

sur mon chrono j ai besoin d emettre un son .wav a 30 secondes avant la fin de chaque compte a rebourd (attention plusieur compte a rebourd sur le meme chronocar plusieur discipline mais les 30 dernieres seconde ne bouge pas ) avez vous une astuce

merci pour votre aide
 

Pièces jointes

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
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
38
Affichages
1 K
  • Question Question
XL 2021 VBA excel
Réponses
4
Affichages
452
Réponses
9
Affichages
1 K
Réponses
6
Affichages
662
Retour