Lets see...hmm...well I think we should start off with playing sound files. Sound files in VB count as *.MIDI,*.RMI,*.WAV and a bunch of others I don't quite remember at this time but anyway lets start.
First off, go to the TOOLS area and select CUSTOM CONTROLS. After this, a box should appear and you should scroll down until you see the label Microsoft Multimedia Control, then check the box next to it and press ok.
Next, place a Multimedia Control on a form. Now, goto the properties box and once there goto the custom setup.
Ok, since this is just a quick demonstration we are going to un-check the following items. PrevVisible , NextVisible , PauseVisible , BackVisible , StepVisible , EjectVisible , RecordVisible and now check-offthe following PlayEnabled , StopEnabled.
This program will let you play any sound you wish. Now before we proceed, first add a Label to the form, a Command Button with the caption OPEN, and a CommonDialog Control. Now, here's the code:
Private Sub Command1_click()
On Error GoTo errhandler 'if the user presses cancel we must exit this procedure
CommonDialog1.Filter = "Midi Files(*.mid)|*.mid|Wav Files (*.Wav)|*.wav" ' this tells the computer what type of files we will be working with
CommonDialog1.ShowOpen 'show the open file dialog box
Label1.Caption = CommonDialog1.filename 'The label will display the path and name of the sound file selected
MMControl1.filename = CommonDialog1.filename 'the multimedia controls filename and path will be the same as the commondialogs
MMControl1.Command = "open" 'This opens the sound wave
errhandler: 'This is where the program goes if the cancel button is hit
Exit Sub ' Exit the procedure
End Sub
Now, run the program and then load a file in by clicking on the OPEN button and then press play or stop. See how easy this simple program was to make! If you want to download this program click on this --> Midi1.zip
There are several books on Visual Basic Multimedia programming or just Visual Basic Programming on the market today.
