Results 1 to 6 of 6

Thread: little function

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Question 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*

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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.

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    one more question

    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

  4. #4

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    guys , help plz

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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.

  6. #6

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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 .

    The function works with or without using the variable "DirectSoundBuffer" , So why it's used ??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width