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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop sound

Status
Not open for further replies.
Sep 12, 2007
45
US

I have managed to add music to a splash screen I created.

I want the music to stop when the splash screen closes but this does not happen.

The following is the code for the play sound function ............

Option Compare Database
Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal filename As String, ByVal snd_async As Long) As Long
Function Playsound(sWavFile As String)
'Purpose: Plays a sound.
'Argument: the fu11 path and file name.
If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function

AND

The following is the procedure that plays the sound when the splash screen opens ........

Private Sub Form_Open(Cancel As Integer)

Playsound ("C:\tunes\longtunes.wav")

End Sub

Is there a way to stop the sound from playing in the code of the 'On Close property?

Private Sub Form_Close()

End Sub
 
This question was addressed on 27th July in forum702, where you originally asked.
 

Got it! Used the following entry in the 'On Close' event of the form!
Now the sound/Wav File stops playing as soon as the form closes

--------------------------------
Private Sub Form_Close()

Playsound vbNullString

End Sub

--------------------------------

Thanks for your help contributors.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top