Including sounds in your solutions

u can use directx8 to play sounds. u need to add a reference first, but its simple from then on.

first, right click on references and choose add references. in the com tab, choose DirectX 8 for Visual basic library - u need this reference, if it aint there, it aint happening.

then, at the top of the code, where key statements are usually placed, type :

Imports DxVBLibA

Add a command button and change the name to cmdSound

Then, in the buttons code center :

Private Sub cmdSound_Click()
dim myDSound as DirectSound8
dim myBufDesc as new DSBUFFERDESC()
dim D8 as new DirectX8()
dim myBuffer as DirectSoundSecondaryBuffer8
myBufDesc.guid3DAlgorithm = AUDIOCONSTANTS.GUID_DS3DALG_DEFAULT
myDSound = D8.DirectSoundCreate(vbNullString)
myBuffer = myDSound.CreateSoundBufferFromFile("C:\Sound.wav", myBufDesc)
The Above Sound can be changed to suit ur needs
myDSound.setCooperativeLevel(me.handle.toInt32, CONST_DSSCLFLAGS.DSSCL_NORMAL)
myBuffer.play(CONST_DSBPLAYFLAGS.DSBPLAY_DEFAULT)
End Sub
 
Back
Top