0
所以這裏是我的問題:我使用兩個列表視圖創建'點唱機',你雙擊一個,它將信息添加到另一個列表視圖。此外,它還將相關的mp3信息添加到數組中。 Windows Media Player將使用此數組連續播放歌曲。Visual Basic - 列表索引問題
不知何故,我成功地將正確的信息轉移到第二個listview(lvTrackList)中,但是當我雙擊第二行或第三行信息後,第一次雙擊時的相同信息會通過如果聲明。我的陣列開始分隔軌道(例如,在添加三首歌曲後,陣列說前兩個斑點是0,第三個插槽是被選中的第一首歌曲)...請幫助!!!
Dim songsArray() As String = {"FurryLewis-BillyLyonsAndStackolee.Mp3", "GusCannon-PoorBoyALongWayFromHome.Mp3", "JoeMcCoy-PileDriverBlues.Mp3", "LouisArmstrong-ComeBack,SweetPapa.mp3"}
Dim queueArray() As String 'Queue for Playlist, containing songnames
Dim queueCount As Integer = 0 'Count for queueArray
'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
請出示至少'songsArray','queueArray'和'queueCount'的定義。 –
顯然,你將不得不擺脫檢查「currentSong」的那個糟糕的代碼。那隻會添加Nothing。您添加的項目不是lvQueueList.Items(0),它在最後添加。 –
已編輯...我已經爲songsArray等添加了信息,但正如您所看到的,queueArray和queueCount沒有特別之處。 – SonShawk