samedi 18 août 2018

Random item from listbox every 0,8 second

i have a code that you see below. Can you tell me how to optimize that? Because sometimes when I click random picker (this code shows random items every 0.8 sec, like 'roll the wheel') it isn't showing f.e. 20 items, like I defined... I just want to make this script work by that: I click a button and it is rolling the positions from a listbox, and showing items that aren't

Dim rnd As New Random
Dim rndIndex As Integer = rnd.Next(10, 20)

 For ill As Integer = 0 To rndIndex
            Dim rnd As New Random
            Dim randomIndex As Integer = rnd.Next(0, lCount)
            If Not Label1.Text = ListBox1.Items(randomIndex) Then
                Label1.Text = ListBox1.Items(randomIndex)
                Delay(0.08)
            Else
                rndIndex = rndIndex + 1
            End If
        Next

That doesn't work, because sometimes I see only 6-8 different items. It could be like that: I've got 10 numbers (0-9), and it puts the following numbers into label every 0,8 secs: 1, 5, 7, 4, 3, 1, 5, 8, 6, 3, 0, 3, 1, 5.




Aucun commentaire:

Enregistrer un commentaire