Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Adding sound to VB programs

Adding sound to VB programs

Adding sound to VB programs

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?

RE: Adding sound to VB programs

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.

Then add the button to your form and code it accordingly. You will need to know the correct command codes to activate and close out the program.

Here's an example from one of my progs...

'Private Sub RunFileName()
'    With mciControl
'        .SetFocus
'        .filename = NameOfFile
'        .Command = "open"
'        .Command = "play"
'    End With
'End Sub

If the user selected REPEAT in the media player's preferences box, then the following will never be execuited.

***The following code will be initiated AFTER the media player has finished***
'Private Sub mciControl_Done(NotifyCode As Integer)
'    mciControl.Command = "Close"
'End Sub

Just to let you know...The forum you should post a query in is the VisualBasic forum.  See Forum list, select programmers, then langauges, and find Visual Basic.

Hope this gets you started on the right foot... Let us know if this is of any help.  Good luck!

You Show me your code, I'll show you mine. 8-)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close