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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding sound to VB programs

Status
Not open for further replies.

dan

MIS
Oct 7, 1998
298
0
16
US
In "old basic" there was the PLAY command that allowed the program to make a sound other than BEEP.  Is there a similar function in VB?  Better yet, is there an easy way to play a wav file from a VB program?
 
You will need to add Microsoft Multimedia Control through your Tools/References. I'm using VisualBasic 4, so I can't tell if this would work in any other version.<br><br>Then add the button to your form and code it accordingly. You will need to know the correct command <b>codes</b> to activate and close out the program.<br><br><br><i>Here's an example from one of my progs...</i><br><br>'Private Sub RunFileName()<br>'&nbsp;&nbsp;&nbsp;&nbsp;With mciControl<br>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.SetFocus<br>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.filename = NameOfFile<br>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Command = &quot;open&quot;<br>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Command = &quot;play&quot;<br>'&nbsp;&nbsp;&nbsp;&nbsp;End With<br>'End Sub<br><br><br><i>If the user selected REPEAT in the media player's preferences box, then the following will never be execuited</i>.<br><br><font color=red>***The following code will be initiated <b>AFTER</b> the media player has finished***</font><br>'Private Sub mciControl_Done(NotifyCode As Integer)<br>'&nbsp;&nbsp;&nbsp;&nbsp;mciControl.Command = &quot;Close&quot;<br>'End Sub<br><br><br>Just to let you know...The forum you should post a query in is the VisualBasic forum.&nbsp;&nbsp;See Forum list, select programmers, then langauges, and find Visual Basic.<br><br>Hope this gets you started on the right foot... Let us know if this is of any help.&nbsp;&nbsp;Good luck! <p> <br><a href=mailto: > </a><br><a href= > </a><br>You Show me your code, I'll show you mine. :cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top