logo
vbRad Home
Source Code
Book Reviews
Forum
Links
About Us
Contribute

Compare Databases with SQL Effects Clarity
 
 How to play sound

Posted on
2/18/2001
Author:
Robert Gelb
Email:
Not Shown
Applies To OS:
NT, 9x, 2000
Product:
5, 6



To play a sound is pretty simple. Paste the code below into your app. If you are a distributing an app to many users, you might want to check first whether the target computer supports sound. For that, click here.

If you are keeping a 16-bit version of your application and would like to keep source compatibility, check out sndPlaySound API function which is being kept alive for compatibility sake.

Add the following to a .BAS, .FRM or .CLS

'Place in General declarations
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_ASYNC = &H1
Private Const SND_FILENAME = &H20000

'Returns True or False indicating whether Sound functions will work
Public Function PlaySoundFile(SoundFile As String) As Boolean
    PlaySoundFile = PlaySound(ByVal SoundFile, ByVal 0&, SND_ASYNC Or SND_FILENAME)
End Function

 


Add Your Comment  

Name: Email Address: all fields optional
Notify me via email when someone responds to this message (valid email required).

Enter the word: