Three57m, strongm and Hypetia,
I have written a small test app that has three command buttons, each attempting to your code, respectively. Strongm's is the only one that will compile, so, for now, Three57's and Hypetia's (which appears to rely on Three's) code is partially 'commented out."
strongm --
I tried your code on my development computer and it works fine (as does mine). I will try it at the client location soon and get back to you.
Three57m --
First, you sent me into a NEW WORLD of .RES. Thank you! For the first time, I added a .RES group of files. Got my three media files in under the "WAVE" group like you instructed. My code looks like this:
Code:
' module1
'api
Public Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As Any, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
'constants
Public Const SND_APPLICATION = &H80
Public Const SND_ALIAS = &H10000
Public Const SND_ALIAS_ID = &H110000
Public Const SND_ASYNC = &H1
Public Const SND_FILENAME = &H20000
Public Const SND_LOOP = &H8
Public Const SND_MEMORY = &H4
Public Const SND_NODEFAULT = &H2
Public Const SND_NOSTOP = &H10
Public Const SND_NOWAIT = &H2000
Public Const SND_PURGE = &H40
Public Const SND_RESOURCE = &H40004
Public Const SND_SYNC = &H0
' form1
Private Function PlayWaveSound() As Boolean
Dim SoundByte() As Byte
On Error GoTo PSError
'Load SoundByte from Resource File
SoundByte = LoadResData(101, "WAVE")
PlaySound SoundByte(0), 0, SND_MEMORY Or SND_NODEFAULT Or SND_ASYNC
PlayWaveSound = True
Exit Function
PSError:
PlayWaveSound = False
End Function
When I run this, I get a "type mismatch" error on compile at "PlaySound SoundByte..." with the word "SoundByte" highlighted, so of course the app doesn't run. Can you detect the error? I tried changing your 'dim SoundByte() as Byte' to 'Static SoundByte() as Byte' like Hypetia recommended, but no luck (I didn't exactly expect that to solve the mismatch problem.) Your help is appreciated and, again, thanks for the journey into .res.
Hypetia --
I tried modifying three57m's code above with your suggestion. I am running this code in a stand alone "SoundTester" app that only has a form. I put the "static..." in the subroutine, then moved it to general declarations (where it would not be allowed), and I really don't have a seperate module attached for this simple test app. Nevertheless, I couldn't get your suggestion to work. Please advise.
THANKS TO ALL OF YOU. I will report back as to whether strongm's simple change made a difference. Three and Hypetia, I would appreciate any additional help you can give.
Ortho
![[lookaround] [lookaround] [lookaround]](/data/assets/smilies/lookaround.gif)
"you cain't fix 'stupid'...