FileName Property Example (Multimedia MCI Control)

Visual Basic Example

To change the FileName property of a Multimedia MCI control at run time, you must close and then reopen the Multimedia MCI control.

The following example finds a selected item, closes the Multimedia MCI Control, resets the DeviceType property, resets the FileName property with the selected item, then reopens the Multimedia MCI control. To try the example, place a Multimedia MCI control and a FileListBox on a form, and paste the code into the  Declarations section of the form.

Private Sub File1_Click()
   Dim i As Integer
   For i = 0 To File1.ListCount - 1
      If File1.Selected(i) = True Then
         MMControl1.Command = "close"
         MMControl1.DeviceType = "WaveAudio"
         MMControl1.FileName = "c:\windows\" & File1.List(i)
         MMControl1.Command = "open"
      End If
   Next i
End Sub