Playing .wav or .mid
- Place the wav or mid file in the directory where your project is stored.
- Use the Components choice on the Project menu to add the Microsoft Multimedia control (requires VB5 SP2 or later) to the project.
- Using the newly created toolbar icon add an instance of the control to the form containing the event which will play the sound.
- Left click on the control and use the properties pallet to assign it a name and set its Visible property to false.
- In the event were you want a wav file to play enter
mciCommand.filename = app.path & "\x"
mciCommand.Command = "Open"
mciCommand.Wait = True
mciCommand.Command = "Play"
mciCommand.Command = "Close"
replacing the x in the first line with the file name to be played and mciCommand with the name of the MCI control.
If users will run your application by right clicking on a wav file or mid file and selecting something from a right click menu you can have the program play the file they right click on by replacing
app.path & "\x" with command$.
Each time you right click on a file and select a menu choice assigned to a VB5 or VB6 application or double click on a file whose default action runs a VB5 or VB6 application command$ is set equal to the
full path and name of the file you selected.
Lila Godel's Web Site
Brought To You By Hamilton Services, Inc.