Selectitem RANDOM inside Listbox on vb.net


Selectitem Index Random in Listbox on vb.net




Example On Listbox: 


Dim rnd As New Random
Dim randomIndex As 
Integer = rnd.Next(0, ListBox2.Items.Count - 1)
ListBox2.SelectedItem = (ListBox2.Items(randomIndex))






Contoh:



Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click


        Dim rnd As New Random


        Dim randomIndex As Integer = rnd.Next(0, ListBox2.Items.Count - 1)


        MessageBox.Show(ListBox2.Items(randomIndex))


End Sub





Hal ini berhasil di visual basic .NET 2010.


Sekian.


Happy Coding Guys.. 

Tidak ada komentar:

Posting Komentar