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!

How to play *.wav file while reporting an error

Status
Not open for further replies.

artskib

Programmer
Jul 17, 2002
8
US
How can I play a *.wav file along with displaying an error message.

Here is my code


If myvariable > 10 Then
' Play the *.wav file here
msgbox ("myvariable cannot be greather than 10")
End If
 
Replace "C:\ding.wav" with the file path and file name of your sound file.



Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_ASYNC = &H1 'play asynchronously
Const SND_FILENAME = &H20000 'name is a file name

Private Sub play(soundName As String)
PlaySound SoundName, 0, SND_ASYNC Or SND_FILENAME
End Sub

If myvariable > 10 Then
play("C:\ding.wav")
msgbox ("myvariable cannot be greather than 10")
End If
 
Do I need to include any components with this function?
When I run the program I get the Compiler err: Sub or Function not defined.

I've placed the function definition in the module file.
 
Please never mind.
I had to make the play fuction public in order to get it to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top