Randomize items in listbox?
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts
Page 1 of 1
Does anybody know some code to randomize the order of the items in a listbox?
Hello skinke5000,
This code can randomize them nicely:
This code can randomize them nicely:
Code: Select all
Dim Rand As New System.Random
'SAVE ARRAYLIST OF ALL ITEMS FROM LISTBOX
Dim ListBoxItems As New System.Collections.ArrayList(ListBox1.Items)
'REMOVE ALL ITEMS FROM LISTBOX
ListBox1.Items.Clear()
'START RE POPULATING LISTBOX
While ListBoxItems.Count > 0
Dim Item As System.Int32 = Rand.Next(0, ListBoxItems.Count)
ListBox1.Items.Add(ListBoxItems(Item))
ListBoxItems.RemoveAt(Item)
End While
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023