Results 1 to 5 of 5

Thread: Wave sounds in vb programs

  1. #1

    Thread Starter
    Member bcx7's Avatar
    Join Date
    May 1999
    Location
    Adelaide, South Australia, Australia
    Posts
    46

    Unhappy

    how can i play a wav sound in a vb program.

    i am using media player control but that only for win 98.

    plus if i put the sound in the same directory as the program (after it's compiled to exe) it can't find them. i didn't sepecify a path to look in. i just wrote the sound name.

    i've tried sound recorder control but it didn't work. (some error)

    is there a another way to play wave sounds that is compatible with windows 95.

    thank you
    I Use Visual Basic 5.0 Enterprise Edition SP3

  2. #2
    Guest
    Code:
    Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long 
    Public Const SND_ASYNC = &H1 
    Public Const SND_NODEFAULT = &H2 
    
    Put the above code in the General Declarations of a module. Then, to play a file, use: 
    
    Call sndPlaySound("C:\MyFile.wav", SND_ASYNC Or SND_NODEFAULT) 
    
    To stop all wave sounds currently playing, use: 
    
    Call sndPlaySound(vbNullString, SND_NODEFAULT)

  3. #3

    Thread Starter
    Member bcx7's Avatar
    Join Date
    May 1999
    Location
    Adelaide, South Australia, Australia
    Posts
    46
    Thank you very much

    but will it work if you don't specify a path. (in other words, will it look for the sound in the same directory as the program is, if i don't put a path for it?)
    I Use Visual Basic 5.0 Enterprise Edition SP3

  4. #4
    Guest
    If it is in your directory:

    Code:
    Call sndPlaySound(App.path & "\MyFile.wav", SND_ASYNC Or SND_NODEFAULT)
    If it is a different directory:

    Code:
    Call sndPlaySound("C:\Windows\MyFile.wav", SND_ASYNC Or SND_NODEFAULT)

  5. #5
    Guest
    And if the file is not found, I makes the standard Beep sound.

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