dimanche 10 février 2019

How to pick a random item from a listbox in visual Basic

How can i pick a random item from a listBox.This is what i have tried.

Public currentTrack As Integer
Public temp As Integer
Public generic As Random = New Random()
tempInt = gen.Next(0, listTracks.Items.Count + 1)
        currentTrack = temp
        MessageBox.Show(listTracks.Items(currentTrack))
        AxWindowsMediaPlayer1.URL = listTracks.Items(currentTrack)

When i display the picked item at a messagebox it pops up 2 message Boxes.Each message box displays a different item. example: the first messagebox shows C:\test\blab.mp3 and the second shows C:\test\bleasds.mp3




Aucun commentaire:

Enregistrer un commentaire