how to play sounds in VB6???

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

  • : 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
  • : 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!

    (^_^)


  • 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
  • Please I need your help, cos am writing a project on screen saver and am ask to create a .txt file and use a timer to display it.. But I use a stream reader and is not displaying so I need help on this please

Sign In or Register to comment.

Howdy, Stranger!

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

Categories