Results 1 to 3 of 3

Thread: [RESOLVED] [2005] Difficult Issue With ListBoxes

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    UK
    Posts
    489

    Resolved [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)

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    UK
    Posts
    489

    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
  •  



Click Here to Expand Forum to Full Width