|
-
Apr 14th, 2007, 06:53 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Difficult Issue With ListBoxes
Hi
Right I have two list boxes, displaying 20 lines of information each, when a button is clicked, one line from each list box is randomly imported from a list box into a label, below is the coding being used.
Code:
Dim rnd As New Random()
Dim randomnumber As Integer = rnd.Next(1, stock1.Items.Count)
lblstock1.Text = stock1.GetItemText(stock1.Items(randomnumber))
Dim rnd1 As New Random()
Dim randomnumer1 As Integer = rnd.Next(1, stock2.Items.Count)
lblstock2.Text = stock2.GetItemText(lstyellow.Items(randomnumber))
After 20 button clicks the list boxes and everything goes to plan, however I want to ensure that entries from both listboxes do not confliced, until 20 button clicks.
Basically I want only 1 item from each listbox to be used once, therefore nothing is repeated, I hope you understand what I am trying to explain.
Help appriciated
Learning C♯
Data Binding & Bound Controls - Objects and wizards will never be as intelligent as you, do it yourself! (Unless your Pro)
-
Apr 14th, 2007, 07:11 AM
#2
Re: [2005] Difficult Issue With ListBoxes
I have posted code in the VB.NET CodeBank to make unique, random selections form a list. You can quite easily adapt it to your circumstances.
http://www.vbforums.com/showthread.php?t=393023
-
Apr 14th, 2007, 09:35 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] Difficult Issue With ListBoxes
Yep, thanks for that
Learning C♯
Data Binding & Bound Controls - Objects and wizards will never be as intelligent as you, do it yourself! (Unless your Pro)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|