2 Replies - 486 Views - Last Post: 16 April 2011 - 03:57 PM Rate Topic: -----

#1 bongskei  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-April 11

combo box matching problem

Posted 16 April 2011 - 01:58 AM

hi, I am new with vb6 and i have some difficulties and problem in matching the two combo boxes. here is i want to do if it is possible:

the 1st combo box has an item of "ice_cream" and "burger" ; the 2nd combo box has "rocky road", "vanilla", "beef" and "checken". if I select the "ice_cream" in the 1st combo box, the 2nd combo box will only display "rocky road" and "vanilla", and the 2nd one will be on the other list.

do anyone have an idea about my situation?

Is This A Good Question/Topic? 0
  • +

Replies To: combo box matching problem

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 301
  • View blog
  • Posts: 1,782
  • Joined: 26-March 09

Re: combo box matching problem

Posted 16 April 2011 - 04:22 AM

You need to have the relationship with the data defined somewhere (a database maybe) and then populate the 2nd combo box dynamically based on the selection of the first combobox.
Was This Post Helpful? 0
  • +
  • -

#3 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: combo box matching problem

Posted 16 April 2011 - 03:57 PM

By the way, set your combobox's style property to the third selection, dropdown list.

Now, how you do what maj is suggesting depends partly on how often you will want to change the rules. If you're new to VB6, then start this way:

1. Populate your first box with your burger and ice cream selections.
2. Create an array with two dimensions. The first dimension will have an index (0, 1, 2....). The second will have your values (beef chicken, etc.). Set the first dimension to the index value of the correct selection in the first box.
3. Whenever the first box's selection changes:
a. Clear the second box.
b. Loop through the array, adding any items whose index matches the index of the selected item in the first box.

Keep in mind that this is kind of a "quick and dirty" solution. It will get messy if you need to make a change to the items in your lists. Which, over time, you probably will. There are better solutions, such as a database as maj has mentioned, and also you can keep your stuff in text files and change those.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1