?
Solved

ComboBox Index and Select Case question

Posted on 2007-09-27
3
Medium Priority
?
642 Views
Last Modified: 2013-12-26
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
Comment
Question by:COOMET
  • 2
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 19975002
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
 

Author Comment

by:COOMET
ID: 19975233
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
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
ID: 19976771
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question