我该如何尝试从列表框中选择一个随机项目。
logging.config.dictConfig(LOGGING)
当我在一个消息框中显示所选择的项目时,它会弹出2个消息框。每个消息框显示一个不同的项目。 示例:第一个消息框显示C:\ test \ blab.mp3 第二个显示C:\ test \ bleasds.mp3
答案 0 :(得分:0)
您可以尝试
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim currentTrack As Integer, temp As Integer, gen As Random = New Random()
Do
temp = gen.Next(0, listTracks.Items.Count)
currentTrack = temp
Dim result1 As DialogResult = MessageBox.Show(listTracks.Items(currentTrack).ToString + vbNewLine + "Play ?",
"Play", MessageBoxButtons.YesNo)
If result1 = DialogResult.Yes Then
AxWindowsMediaPlayer2.URL = listTracks.Items(currentTrack).ToString
Else
Exit Do
End If
Loop
End Sub