Playing .wav or .mid
Files Automatically

  1. Place the wav or mid file in the directory where your project is stored.
  2. Use the Components choice on the Project menu to add the Microsoft Multimedia control (requires VB5 SP2 or later) to the project.
  3. Using the newly created toolbar icon add an instance of the control to the form containing the event which will play the sound.
  4. Left click on the control and use the properties pallet to assign it a name and set its Visible property to false.
  5. In the event were you want a wav file to play enter

    mciCommand.filename = app.path & "\x"
    mciCommand.Command = "Open"
    mciCommand.Wait = True
    mciCommand.Shareable = False
    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.

Contact Me

Access

Access

Home

Home

Links

Links

Miscellaneous

Other

Programs By Me

Programs

Visual Basic

Visual Basic

Windows

Windows