VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Easily Play a WAV File

by silverx10 (5 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

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).

Assumes
1) Create one (1) CommandButton Control on the Form, and set the Name property to "cmdSound" (minus the quotes).

Rate Easily Play a WAV File

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!

Download this snippet    Add to My Saved Code

Easily Play a WAV File Comments

No comments have been posted about Easily Play a WAV File. Why not be the first to post a comment about Easily Play a WAV File.

Post your comment

Subject:
Message:
0/1000 characters