-
little function
Code:
Function DXSound_Init(Hwnd As Long) As Boolean
Set ds = dx.DirectSoundCreate(vbNullString)
ds.SetCooperativeLevel Hwnd, DSSCL_PRIORITY
DXSound_Init = True
End Function
guys I don't what's wrong with me !!!!
basically what does the last line of code mean ?
I've seen a lot of func. act like this
DXSound_Init = True
a mean why the function returns true ?(why not false)
*thanx for your time*
-
That function returns a boolean. It has to either be true or false.
Usually you will have more code than that if your returning a variable. True should signal success of some kind in the function. False would be returned if something in the function failed. This one you gave us for an example might as well have been a Sub.
One more reason I would do this, is for something like this:
MyFunction(DXSound_Init(Hwnd))
Where you want to pass in a bool variable to MyFunction and want to perform the DXSound_Init function first. This would take care of two at once...in a way.
-
one more question :D
Code:
Function DXSound_LoadSound(SoundFileName As String) As DirectSoundBuffer
Dim dsBuf As DSBUFFERDESC
Dim dsBuffer As DirectSoundBuffer
Dim WF As WAVEFORMATEX
dsBuf.lFlags = DSBCAPS_CTRLVOLUME Or PS_CTRLFREQUENCY
Set dsBuffer = ds.CreateSoundBufferFromFile(SoundFileName, dsBuf, WF)
Set DXSound_LoadSound = dsBuffer
End Function
now how about "DirectSoundBuffer" is that the returning value ??
(some told me this set the properities of the function , I don't know really )
thanx dude
-
-
I think that DirectSoundBuffer is an object that is in the DX library. Either that, or an enumeration of somekind. I have never messed with DX before, so I am probably wrong.
-
thanx hellswraith for your replay
well , DirectSoundBuffer is an object in the DS(DirectSound) library.Anyhow , I'm not asking about where is it located .:p
The function works with or without using the variable "DirectSoundBuffer" , So why it's used ??