Sunday, 25 August 2013

Visual Basic - ListIndex problems

Visual Basic - ListIndex problems

So here's my problem: I'm creating a 'jukebox' using two listviews, you
double-click one, and it adds info to another listview. Additionally, it
adds the relevant mp3 info into an array. This array will be used by
Windows Media Player to play songs back-to-back.
Somehow I'm successful in transferring over the correct info into the 2nd
listview (lvTrackList), but after I double-click a second or third row of
info, the same information from the first double-click goes back through
the If statement. My array begins spacing out the tracks (for example,
after adding three songs, the array says that the first two spots are 0,
and the third slot is the first song that was selected) ... Please help!!!
'DoubleClick track playlist to add selected track to Queue
Private Sub lvTrackList_DoubleClick(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles
lvTrackList.DoubleClick
intCurrentSong = lvTrackList.SelectedIndices(0)
lvQueueList.Items.Add(lvTrackList.Items(lvTrackList.SelectedIndices(0)).Clone())
'determine applicable mp3 file
currentSong = lvQueueList.Items(0).Text
If currentSong = "Billy Lyons and Stackolee" Then
newSong = songsArray(0)
ElseIf currentSong = "Gus Cannon" Then
newSong = songsArray(1)
ElseIf currentSong = "Kansas Joe McCoy" Then
newSong = songsArray(2)
ElseIf currentSong = "Louis Armstrong" Then
newSong = songsArray(3)
End If
'add file to queueArray for appending to WindowsMediaPlayer playlist
ReDim queueArray(queueCount)
queueArray(queueCount) = newSong
queueCount += 1
End Sub

No comments:

Post a Comment