Click to See Complete Forum and Search --> : Wav Files


RSH
May 8th, 2001, 10:22 AM
Can someone share the necessary code for playing the sound files included with windows when one hits like a command button. One button for each file would be fine.
73 RSH

The Ghost
May 25th, 2001, 09:58 PM
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Const SND_sYNC = &H0
Public Const SND_aSYNC = &H1
Public Const SND_NODEFAULT = &H2
Public Const SND_MEMORY = &H4
Public Const SND_LOOP = &H8
Public Const SND_NOSTOP = &H10


Call this sub each time you click on a command button

Sub PlaySoundClick()
Dim X As Long
Dim wFlag As Integer
Dim SoundName As String

wFlag = SND_aSYNC Or SND_NODEFAULT
X = sndPlaySound("C:\Archive\sound1.tmp", wFlag)
End Sub