Play “.wav” files using VB

By | 2002-06-01

Play WAV files using VB ~ awesome ~ Add sound to your projects!
by: EM Dixson
http://developer.ecorp.net
HUNDREDS of FREE Visual Basic Source Code Samples, Snippets, Projects and MORE!

Original Author: EM Dixson

Inputs

NA

Assumptions

NA

Returns

NA

Side Effects

NA

API Declarations

NA

Code

***************************************************************
*         http://developer.ecorp.net         *
***************************************************************

Auhor: EM Dixson
This code shows how to play a wave file from VB.
Call the sub like this:
  PlaySound "C:MyFolderMySound.wav"
Note that if the file is not found the windows default sound
will be played instead.

Paste the following code into a module:
'//*********************************//'
Public Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Sub PlaySound(strFileName As String)
  sndPlaySound strFileName, 1
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.