ok, I did try your sample, that WAS SO WHAT I NEEDED!! Thanks man!
Originally Posted by dglienna
I got my program to play the sound, loop (0.5 sec pause is noticeable but its okay), so whenever i run it in VB6 (i choose "run with full compile") it runs PERFECT and the cound is played. But when i compile an .exe (size of ~800kb with sound embedded) it starts up fine with all the grafix and everything i need but THERE IS NO SOUND PLAYED... i have no clue what could that be, in VB6 everything works fine, and when i compile final .exe it doesn't show any errors....
//Code from Main Form, the only window:
Dim Wav(16 To 16) As String 'make a string array to hold 4 Wav's
Private Sub Form_Load()
' the next line plays the WAV from the RES file, not from memory
'you could also say: "Call PlayRESSound(16, True)" to force your
'program to wait until the WAV is done playing
For i = 16 To 16 'loop through
Wav(i) = StrConv(LoadResData(i, "SOUND"), vbUnicode) 'load the WAV's into a string array
'add them to the listbox
Private Sub Form_Unload(Cancel As Integer)
sndPlaySound vbNullString, SND_ASYNC 'stop playing sound (otherwise will it will be played forever)
Private Sub cmdExit_Click()
//AND this is code from my only Module:
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Const SND_SYNC = &H0 ' play synchronously (default)
Public Const SND_ASYNC = &H1 ' play asynchronously (the program does not stop for the WAV)
Public Const SND_MEMORY = &H4 ' play from memory (from a String)
Public Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Public Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
' I got this sub from Kalani, very nicely done!
Public Sub PlayRESSound(iIndex As Integer, Optional bWait As Boolean)
On Error Resume Next ' just in case
If bWait = True Then
lFlags = SND_SYNC Or SND_MEMORY Or SND_LOOP
lFlags = SND_ASYNC Or SND_MEMORY Or SND_LOOP
' the next line does all the work.
vAddress = StrConv(LoadResData(iIndex, "SOUND"), vbUnicode)
sndPlaySound vAddress, lFlags
Thanx for ur time guys i really appreciate it