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