• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 666
  • Last Modified:

ComboBox Index and Select Case question

I have four combobox indexed as Combo1(index).  How can we use 'Select Case' for the Click event of Combo1(Index) ?  I tried it as follows but each combobox is mixing to a wrong statement.  The statement of each 'Case' use the 'For i=0 to Combo1(index).ListIndex'.  Any help please ?


Private Sub Combo1_Click(Index As Integer)
Dim i,j  As Integer

Select Case Combo1(j)

Case 0

'Statement 0

For i=0 to Combo1(index).ListIndex
'Some tasks
Next i

Case 1

'Statement  1

Case 2

'Statement  2

Case 3
'Statement 3
End Select

End Sub
0
COOMET
Asked:
COOMET
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Private Sub Combo1_Click(Index As Integer)
Dim i,j  As Integer

Select Case Combo1(index)

Case 0

'Statement 0

For i=0 to Combo1(index).ListIndex
'Some tasks
Next i

Case 1

'Statement  1

Case 2

'Statement  2

Case 3
'Statement 3
End Select

End Sub
0
 
COOMETAuthor Commented:
angelIII:

Thank you.  The code is still mixing the items of the list with the combo index.  Here is the idea.  Once I select a combo, say combo1(o), I click in the list of that combo.  If the ListIndex value of that combo is 10, 10 picture squares will be visible.  If the list index is 5, only five picture squares will be visible.... and so on.  Since I have four categories of pictureboxes, I linked each picturebox index with the combobox (index) event.  Thus

Case 0  'when I click at Combo1(0)

For i=0 to Combo1(Index).ListIndex
PictureBox1(i).Visible=True
Next i

===> If the listindex value while clicking at Combo1(0) is 5, then I have to get five pic boxes visible as follows:

For i=0 to 5
PictureBox1(i).visible=True
Next




0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
remove the complete select ... end statement, and use a single for loop:

For i=PictureBox1.Lbound to PictureBox1.Ubound
   PictureBox1(i).Visible= ( i <= Combo1(Index).ListIndex )
Next i

at least, that is what I understand you need to do
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

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 now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now