What kind of sound? An If statement "conditionally executes a group of statements, depending on the value of an expression".
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Did you mean by "easy" that you want to do as little programming as possible?
You could write a reusable function call inside of any if statements for playing sound.
Although I do not know how to play sound in VB6, I do know from working in other languages that most sounds that you want to play have to be streamed from a file.
That is... you need to obtain a buffer (or array) that can hold X amount of bytes of sound data. You then read data from the sound file into this buffer, and play it.
You would loop through the entire contents of the file until all the sound data is played.
I warn you though, if you load the whole file in one big buffer, then you will consume much more RAM than you need to.
I hope this helps in your search for whatever it is you are trying to find out. (If you spent some more time explaining thoroughly what issue you were having, it would benefit you by letting everyone know how we can help).
The function idea is exactly what i'm looking for.
I want to be able to call the sound in whenever I want it.
its a small file - a ringing bell to signal the end of a round.
How would I go about putting this into a function?
If you put the following code in a new Module in your project, you can call it each time you want to produce a 'sound':
Code:
Public Declare Function PlaySound _
Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long
Public Const SND_ASYNC = &H1
Public Const SND_LOOP = &H8
Public Const SND_MEMORY = &H4
Public Const SND_NODEFAULT = &H2
Public Const SND_NOSTOP = &H10
Public Const SND_SYNC = &H0
Public Const SND_ALIAS = &H10000
Public Const SND_APPLICATION = &H80
Public Const SND_ALIAS_ID = &H110000
Public Const SND_FILENAME = &H20000
Public Const SND_NOWAIT = &H2000
Public Const SND_PURGE = &H40
Public Const SND_RESOURCE = &H40004
Public gbResults As Boolean
You 'call' it by something like this:
Code:
gbResults = playsound(mySound, 0, SND_ASYNC)
or
Code:
gbResults = playsound(mySound, 0, SND_SYNC)
Where mySound is a string variable holding the path&fileName of the sound file.
You can also use the MMC (Multimedia control) if you prefer. Also, the code I sent plays wave (.wav) files. And the MMC can play .mp3 files. Not sure what other formats each play.....I use either, depending upon if I have .wav or .mp3 files, although, like I say, each may play different formats as well.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.