How to use mmcontrol in visual basic

Written by laura gittins
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to use mmcontrol in visual basic
(Comstock/Comstock/Getty Images)

The Microsoft Multimedia Control, or MMControl, is a Visual Basic tool that plays media files. You will not find MMControl to be one of the default tools in your toolbox, but you can add it to your list of controls with the Components list. You can add MMControl so you can integrate audio or video files to your project. However, MMControl accepts only one file at a time, so if you want to create your own MP3 player, you will need to use an array to store your track list.

Skill level:
Moderate

Other People Are Reading

Instructions

  1. 1

    Open a Visual Basic project. Click on "Project" from the menu, and select "Components." Scroll down to "Microsoft Multimedia Control 6.0," and double-click it to add a check box to the selection. Click "OK" to close the Components window. This adds MMControl to your toolbox.

  2. 2

    Double click the MMControl tool in the toolbox to add one to your form. Click and drag the control to a point on the form where you need it.

  3. 3

    Open the code window. Type "Dim track List(4) As String" at the top. This will create an array that will hold five tracks (numbered zero to four). Type "Dim track Number As Integer" to create a counter variable.

  4. 4

    Open the "Form_Load()" function. Type "track List(0) = file_path" to load your first track into your array, where "file_path" is the actual location of your MP3 file on your computer. Do this again for "track(List(1)" to "track List(4)."

  5. 5

    Type "MMControl1.Command = "Open"" in the "Form_Load()" function to open the device when the program starts. Type "track Number = 0" on the next line and "MMControl1.FileName = track List(trackNumber)" on the line after that. Type "MMControl.Command = "Play" on the final line in the function.

  6. 6

    Open the "Form_Unload" function, and type "MMControl.Command = "Close"" to stop the control when your program ends.

  7. 7

    Open the "MMControl1_NextClick" function. Type the following lines:

    MMControl1.Command = "Stop"

    If track Number = 4 Then

    track Number = 0

    Else

    track Number = track Number + 1

    End If

    MMControl1.FileName = list(trackNumber)

    MMControl1.Command = "Open"

    MMControl1.Command = "Play"

  8. 8

    Open the "MMControl1_PrevClick" function. Type the following lines:

    MMControl1.Command = "Stop"

    If track Number = 0 Then

    track Number = 4

    Else

    track Number = track Number - 1

    End If

    MMControl1.FileName = list(trackNumber)

    MMControl1.Command = "Open"

    MMControl1.Command = "Play"

  9. 9

    Press "F5" to start your program and listen to your MP3s.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.