Beginner VB

Moderators: None (Apply to moderate this forum)
Number of threads: 1244
Number of posts: 2990

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to play sounds in VB6??? Posted by mOski on 9 Jun 2008 at 6:21 PM
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)


Report
Re: how to play sounds in VB6??? Posted by pVb on 11 Jun 2008 at 10:25 AM
: 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:\winnt\media\" & DEFAULT_FILE, 0)
Else
ret = sndPlaySound("C:\winnt\media\" & strFile, 0)
End If
End Sub

IC
Report
Re: how to play sounds in VB6??? Posted by mOski on 2 Jul 2008 at 10:22 PM
: 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!

(^_^)


Report
Re: how to play sounds in VB6??? Posted by mhine on 14 May 2011 at 3:25 AM
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 & "\Media\accepted.wav", 0, &H0)
End If A A A
| | |
| | |
Your Project Folder | |
Folder of where .WAV is |
File here



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.