Advertisement
ASP_Volume3 Miscellaneous #44608

Easily Play a WAV File

This source code will easily allow you to play a WAV file from within your Visual Basic application WITHOUT using an ActiveX Control. The two most amazing facts about this source code that amazed me were: • The value for the "flag." I had absolutely no idea what to do for the flag. But I took a good guess at it, and I got it! • It will actually play the WAV file from the Visual Basic environment (you don't need to compile it to hear the sound).

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Sub PlayWav(Filename As String)
  sndPlaySound (Filename), &H80
End Sub
Private Sub cmdSound_Click()
  PlayWav "C:\WINDOWS\Media\Chord.wav"
  'Chord.wav is a file that comes along with both 
  'Windows 95 and 98 Operating Systems. If your
  'system is missing this file, specify a different WAV.
End Sub
'Now, press F5, or the Run button in the Visual Basic
'Environment, and then click the button. If you enjoy 
'this source code, please let me know by posting feedback.
'Thanks!
Upload
Original Comments (3)
Recovered from Wayback Machine