The code below works fine if you are deleting something other than lowest item on the listbox. If you do, then you get an error saying "Specified argument was out of the range of valid values. Parameter name: '1' is not a valid value for 'value'."
VB Code:
On Error GoTo TheError Dim index As Integer If playlist.Items.Count < 1 Then MsgBox("A track must be in the playlist in order to use the remove function!", MsgBoxStyle.Exclamation, "Error") Else playlistPath.SelectedIndex = playlist.SelectedIndex If MP3.MP3Playing = False Then index = playlistPath.SelectedIndex If playlistPath.SelectedItem = MP3.MP3File Then MP3.MP3Stop() tmrTrack.Enabled = False lblPaused.Visible = False Me.startTime = Date.Now Me.tmrTrack.Stop() etime.Text = "-:--" rtime.Text = "-:--" ttime.Text = "-:--" WP.Text = "" trkSeek.Value = 0 playlistPath.Items.Remove(playlistPath.SelectedItem) playlist.Items.Remove(playlist.SelectedItem) lblPaused.Visible = False btnPause.Enabled = False mnuPause.Enabled = False btnPause.Enabled = False mnuPause.Enabled = False btnPause.Visible = True mnuPause.Visible = True btnResume.Enabled = False mnuResume.Enabled = False btnResume.Visible = False mnuResume.Visible = False btnStop.Enabled = False mnuStop.Enabled = False playlist.SelectedIndex = index playlist.Update() playlistPath.Update() ElseIf playlistPath.SelectedItem <> MP3.MP3File Then index = playlistPath.SelectedIndex playlistPath.SelectedIndex = playlist.SelectedIndex playlistPath.Items.Remove(playlistPath.SelectedItem) playlist.Items.Remove(playlist.SelectedItem) playlist.SelectedIndex = index playlist.Update() playlistPath.Update() End If Else index = playlistPath.SelectedIndex playlistPath.SelectedItem = playlist.SelectedItem playlistPath.Items.Remove(playlistPath.SelectedItem) playlist.Items.Remove(playlist.SelectedItem) playlist.Update() playlistPath.Update() playlist.SelectedIndex = index End If End If Exit Sub TheError: MsgBox(Err.Description, , " Error")




Reply With Quote