Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting .Wav files in a game. Nothing is working

Status
Not open for further replies.

bradshaw

Technical User
May 24, 2002
3
0
0
NZ
I have tried 3 ways to put sound in and I still can't get it to work. Can someone tell me exactly how to put a wav file in? I need the exact code preferably in an example and I would like to know how it works please
 
Hi bradshaw,

Try this Code:

In a Module place:-

'Windows 95,98
'Declare Function sndPlaySoundA Lib "c:\WINDOWS\SYSTEM\WINMM.DLL" (ByVal lpszSoundName$, ByVal ValueFlags As Long) As Long

'Windows 2000, NT
'Declare Function sndPlaySoundA Lib "C:\WINNT\system32\WINMM.DLL" (ByVal lpszSoundName$, ByVal ValueFlags As Long) As Long

'Windows XP
Declare Function sndPlaySoundA Lib "C:\WINDOWS\system32\WINMM.DLL" (ByVal lpszSoundName$, ByVal ValueFlags As Long) As Long

Global Const SND_SYNC = &H0
Global Const SND_ASYNC = &H1
Global Const SND_NODEFAULT = &H2
Global Const SND_LOOP = &H8
Global Const SND_NOSTOP = &H10

Sub PlayWavFile(sFile)

Dim iSoundFlags As Integer
Dim lSound As Long

iSoundFlags = SND_ASYNC Or SND_NODEFAULT
lSound = sndPlaySoundA(sFile, iSoundFlags)

End Sub


On a Form Place a Command Button and Add:-
Private Sub Command1_Click()
PlayWavFile("c:\winnt\media\tada.wav")
End Sub


HTH,

Codefish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top