Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating sounds in VB

Status
Not open for further replies.

RollyS

Programmer
Jan 28, 2001
42
PH
Does anybody know how to do this in VB code?

Instead of using the Beep to produce a sound, I would like to use the sound card of my computer to produce a sound. I don't like the sound produced by the Beep because it's too feeble. I like the one that sounds like "Blam!" whenever you make a mistake.

Thanks.
 
I'm new to VB but you can use VBExclamation or VBCritical for a MsgBox, and it will use the default sound of the computers sound scheme. Every day above ground is a GOOD DAY!!!
 
1. Insert inside your BAS module:
'********************************************************
Public Declare Function PlaySound _
Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, ByVal hModule As Long, _
ByVal dwFlags As Long) As Long
Public Const SND_FILENAME = &H20000 ' name is a file name
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_SYNC = &H0


2. Call the function somewere in your form:

PlaySound "MySoundFolder\MySoundFile", 0, SND_ASYNC

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top