EDIT: I am so sorry! I have added my thread to the C# discussion thread instinctively wherein in fact I have been creating my application in VB.NET so sorry! Please transfer my thread to the appropriate location! Really sorry!
Hey all I am currently trying to mess around with a simple mp3 player and am in the process of creating a shuffle list from all the songs in my playlist.
So here is my random number generating code (which I guess does not work for it hangs my application)
For i As Integer = 0 To Me.songList.Count - 1
Dim wasIndexAdded As Boolean = False
Do Until wasIndexAdded
Dim randomClass As New Random(Me.songList.Count - 1)
Dim randNum As Integer = -1
randNum = randomClass.Next()
If Not Me.shuffleIndexList.Contains(randNum) Then
Me.shuffleIndexList.Add(randNum)
wasIndexAdded = True
End If
Loop
Next i
I do not know what is wrong with the code, I have tried another version of that here:
For i As Integer = 0 To Me.songList.Count - 1
Dim wasIndexAdded As Boolean = False
Dim randomClass As New Random()
Do Until wasIndexAdded
Dim randNum As Integer = -1
randNum = randomClass.Next(Me.songList.Count - 1)
If Not Me.shuffleIndexList.Contains(randNum) Then
Me.shuffleIndexList.Add(randNum)
wasIndexAdded = True
End If
Loop
Next i
Any help or suggestions will be greatly appreciated!