Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I attach a sound to a button?

Status
Not open for further replies.

helloeveryone

Technical User
Aug 22, 2003
1
FR
Is there anyway to make a button, and when I click on it, it makes a sound from a .wav file?
 
Paste the following code into a module (not a Form Module).
In the click event of your command button call this routine, passing it the location of the wave file you wish to play
Code:
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
   (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Public Sub PlayWav(WaveFileName As String)
Dim N As Long
   
   N = sndPlaySound(WaveFileName, 0)
   
End Sub
Durkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top