How to correlate VB commands

Hello,
Apologizes upfront for maybe not describing my problem\question clearly but i just started learning visual basic (using Visual Basic 6.0) and i managed to create a simple .exe file with 3 sub menus and a NEXT button, i know how to make each sub menu perform an action once i press on the NEXT button, but my question is how can i correlate these menus? for example:

Menu 1 has 3 choices:
USA
Russia
Italy

Menu 2 has 3 choices:
Green
Black
Blue

how can i make it so if i choose Russia + Green i get one action, but Russia + Blue will give me another action (or any other kind of a combination)

The simple code i made is written below


Private Sub Combo1_Change()

End Sub

Private Sub Combo2_Change()

End Sub

Private Sub Combo3_Change()

End Sub

Private Sub Command1_Click()
End
End Sub

Private Sub Command2_Click()


    Select Case Combo1.ListIndex
    Case 0
      MsgBox "Please choose first"
    Case 1
      MsgBox "USA"
    Case 2
      MsgBox "RUSSIA"
    Case 3
      MsgBox "ITALY"
   Case Else
        MsgBox "Please choose first"
    End Select
    
    
 
    Select Case Combo2.ListIndex
    Case 0
      MsgBox "Please choose first"
    Case 1
      MsgBox "GREEN"
    Case 2
      MsgBox "BLACK"
    Case 3
      MsgBox "BLUE"
      Case Else
        MsgBox "Please choose first"
    End Select

    

Private Sub Form_Load()

   Dim oMap As String
    Combo1.AddItem "<Select >"
    Combo1.AddItem "USA"
    Combo1.AddItem "RUSSIA"
    Combo1.AddItem "ITALY"
    
    Combo2.AddItem "<Select>"
    Combo2.AddItem "GREEN"
    Combo2.AddItem "BLACK"
    Combo2.AddItem "BLUE"

End Sub

Open in new window

johnnyjonathanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gplanaCommented:

Just put a select case statement inside the other, so you can create the 9 combinations:
Private Sub Command1_Click()
End
End Sub

Private Sub Command2_Click()
    Select Case Combo1.ListIndex
    Case 1
       Select Case Combo2.ListIndex
       Case 1
         MsgBox "USA+GREEN"
       Case 2
         MsgBox "USA+BLACK"
       Case 3
         MsgBox "USA+BLUE"
       Case Else
         MsgBox "Please choose first"
       End Select

    Case 2
       Select Case Combo2.ListIndex
       Case 1
         MsgBox "Russia+GREEN"
       Case 2
         MsgBox "Russia+BLACK"
       Case 3
         MsgBox "Russia+BLUE"
       Case Else
         MsgBox "Please choose first"
       End Select
    Case 3
       Select Case Combo2.ListIndex
       Case 1
         MsgBox "Italy+GREEN"
       Case 2
         MsgBox "Italy+BLACK"
       Case 3
         MsgBox "Italy+BLUE"
       Case Else
         MsgBox "Please choose first"
       End Select
   Case Else
        MsgBox "Please choose first"
    End Select
    
    

Private Sub Form_Load()
   Dim oMap As String
    Combo1.AddItem "<Select >"
    Combo1.AddItem "USA"
    Combo1.AddItem "RUSSIA"
    Combo1.AddItem "ITALY"
    
    Combo2.AddItem "<Select>"
    Combo2.AddItem "GREEN"
    Combo2.AddItem "BLACK"
    Combo2.AddItem "BLUE"

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GrahamSkanRetiredCommented:
You could concatenate the text values of the two combos. However this is an unusual way of working. Why not just put all (9 in this example) choices int one combo?

Select Case Combo1.Text & Combo2.Text
      Case  "USAGREEN"
          'Action 1
      Case   "USABLACK"
           'Action 2
'...

Open in new window

0
johnnyjonathanAuthor Commented:
@gplana, thanks but the idea isn't to create just 9 lists, i only gave examples the actual list is longer hence i wanted to do the correlations

@GrahamSkan, I'm sorry but i couldn't exactly understand from the example you wrote how can i take a selected action from combo1 and combo2 ?

where does it state which action i took?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

gplanaCommented:
My solution doesn't creat 9 lists, but just to make an example in how you can make a different action for every combination of the 3 values of both of your lists (so 3x3 = 9 combinations).
0
GrahamSkanRetiredCommented:
I left you to fill in the actions that you want to take in the commented out sample lines

However, if you want display a message box, you can do it in one line:


Private Sub Command2_Click()
      MsgBox "You selected " & Combo1.Text & " from Combo1 and " & vbCrLf & Combo2.Text & " from Combo2."
End Sub

Open in new window

0
jruheCommented:
Is this what you're looking for Johnny?  I took what gplana and GrahamSkan had and put them together in your original code.  Obviously, you can put the same code in Combo1_Change, but you may want to avoid the "Case Else" part in that combo box.
Private Sub Combo2_Change()
Select Case Combo1.Text & Combo2.Text
      Case  "USAGREEN"
          'Action 1
      Case   "USABLACK"
           'Action 2
...
      Case Else
         MsgBox "Please choose both a country and a color"
       End Select
End Sub

Open in new window

0
johnnyjonathanAuthor Commented:
Worked out great (after i figured what you mean) thanks a lot!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.