how to play sounds in VB6??? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how to play sounds in VB6???

mOskimOski Posts: 44Member
I was wondering if it was possible to play sounds in VB once the form loaded or if a statement was met then a sound would play itself like a prompt or something. I don't know how to use sounds on VB so I really need help....

thanks so much to the person that will help me...

(T_T)


Comments

  • pVbpVb Posts: 4Member
    : I was wondering if it was possible to play sounds in VB once the
    : form loaded or if a statement was met then a sound would play itself
    : like a prompt or something. I don't know how to use sounds on VB so
    : I really need help....
    :
    : thanks so much to the person that will help me...
    :
    : (T_T)
    :
    :
    :
    Hi
    Try that:

    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

    Sub PlaySound(Optional strFile As String)
    Dim ret
    Const DEFAULT_FILE = "Utopia - Erreur.WAV"
    'Chimes.wav
    'chord.wav
    'ding.wav
    'notify.wav
    'recycle.wav
    'ringin.wav
    'tada.wav - We have a winner
    'Utopia - Erreur.WAV - Erreur
    If strFile = "" Then
    ret = sndPlaySound("C:winntmedia" & DEFAULT_FILE, 0)
    Else
    ret = sndPlaySound("C:winntmedia" & strFile, 0)
    End If
    End Sub

    IC
  • mOskimOski Posts: 44Member
    : I was wondering if it was possible to play sounds in VB once the
    : form loaded or if a statement was met then a sound would play itself
    : like a prompt or something. I don't know how to use sounds on VB so
    : I really need help....
    :
    : thanks so much to the person that will help me...
    :
    : (T_T)
    :
    :
    :

    Thanks for the code!

    I have a question though, I think these codes uses the sounds that is in Windows' dll, I was wondering if it was possible to play a .wav file from a folder....? hehe....

    Thanks again for the help!

    (^_^)


  • mhinemhine Posts: 1Member
    Try This

    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
    (ByVal lpszName As String, ByVal hModule As Long, _
    ByVal dwFlags As Long) As Long

    Dim RetVal as Long

    Private Sub cmdPlay()
    RetVal= PlaySound(App.Path & "Mediaaccepted.wav", 0, &H0)
    End If A A A
    | | |
    | | |
    Your Project Folder | |
    Folder of where .WAV is |
    File here
Sign In or Register to comment.