Bueno aquí un pequeño módulo para agregar sonidos wav a su aplicación selecciona entre el archivo local o jugar de Recursos.
(Google Translator)
(Google Translator)
Código [Seleccionar]
Option Explicit
'---------------------------------------------------------------------------------------
' Module : mPlayWAV
' DateTime : 20/04/2010 01:58AM
' Author : Mi4night
' Mail : mi4night@hotmail.com
'Special Thx : MSDN
' Purpose : Play a wav file from Resource or File
' Usage : At your own risk
' Requirements: None
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
'
'---------------------------------------------------------------------------------------
'Used API declaration
Private Declare Function sndPlaySound _
Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
Private Declare Function PlaySoundData _
Lib "winmm.dll" _
Alias "PlaySoundA" (lpData As Any, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long
'Enumuration to select the way of playing the file
Public Enum PlayType
WAVFromRes = 0
FromFile = 1
End Enum
'Flags used by API
Private Const SND_ASYNC = &H1
Private Const SND_NODEFAULT = &H2
Private Const SND_MEMORY = &H4
'Buffer for the Resource WAV File
Dim ResData() As Byte
Public Function PlayWAVSound(PType As PlayType, _
Optional ResID As Integer = 0, _
Optional ResType As String = vbNullChar, _
Optional WavPath As String = vbNullChar) As Integer
'Simple error handling
On Error GoTo errHandle:
Const Flags = SND_MEMORY Or SND_ASYNC Or SND_NODEFAULT
'Are any parameters used ?
If ResID = 0 And WavPath = "" Then
Exit Function
Else
'What king of playing type is selected ?
Select Case PType
Case 0
ResData = LoadResData(ResID, ResType)
PlayWAVSound = PlaySoundData(ResData(0), 0, Flags)
Case 1
PlayWAVSound = sndPlaySound(WavPath, SND_ASYNC Or SND_NODEFAULT)
End Select
End If
Exit Function
'Error handling
errHandle:
MsgBox "Error Code: " & Err.Number & vbCrLf & "Error Description: " & _
Err.Description, vbCritical, "Error"
End Function