Results 1 to 6 of 6

Thread: Comparing Listbox Values

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    101

    Comparing Listbox Values

    Hi there,

    I have five listboxes that are populated from five different datasources basically I have connected to an MS Access database and I am running SQL queries effectively so the five listboxes are populated via datatables for example dtInterests, dtHobbies, dtMovies, DtTV and dtMusic

    my question is how would I compare the values that are being stored in each listbox I want the application to check each of the five listboxes and if the value is the same (in my case the valuemember is the customer id) then store the result somewhere (in a textbox)

    thank for any help in advance

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

    Re: Comparing Listbox Values

    You're going to have to provide a more complete explanation. Do all of these DataTables have a CustomerID? Are you interested in every item in every list or just the selected items? Etc. Please provide a full and clear description of the problem each time you start a thread.
    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
    Lively Member
    Join Date
    Oct 2008
    Posts
    101

    Re: Comparing Listbox Values

    Yes i need to compare the whole list of each listbox and match which items are the same and the customer id (cust_id) is the value which is grabbed from the database yes

  4. #4
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: Comparing Listbox Values

    So like a dating service, Customer2 has the X amount of interests from each of the listboxes as Customer1?
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    101

    Re: Comparing Listbox Values

    yes this is exactly right i need to match customers intrests from the populated listboxes and if for example all five listboxes contain the same customer id then it will be a very good match!

  6. #6
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: Comparing Listbox Values

    So then what you would need to do is loop through each list box and compare customer2 items to customer1 items, store the like items for each list box.

    What I would be using is a CheckedListBox not a ListBox where you add all of the possible items you can think of. This would make running a query to check each list box for customer2 to customer1 much easier. Just compare the checked values are the same, and then say return any records where the count equals a certain amount.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

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