Click to See Complete Forum and Search --> : Combo box question


Silv
February 21st, 2000, 11:05 AM
In my program iam working with 2 combo box.Iam working with clear methods and the like but the problem iam facing is : If i choose a selection in the first combo box how can i decide what will be shown after in the second combo box.
The .clear methods work ok when i need to clear but if i only want the number 10 item to the 15 one on a 1 to 100 list how can i choose to only make them shown upon as an exemple choosing option 2 on the frist combo box ? It seem i can only show allthe list or clear it completely at the moment but cant only choose some items in the list. Thanks in advance if you can help me.

Johnny101
February 21st, 2000, 12:40 PM
Well, you could use the .Remove (index) method, but after doing that, all the other items' indexes will change. For example, if i have four items in a combo box with sequential indexes (1,2,3,4) and i remove the third item, the indexes will now be 1,2,3 even though i just removed the third one, the item with index four becomes index three. so my suggestion would be:

Sub RemoveItems()
'assume the combobox is named Combo1
'get the actual text values for the items you want to remove, put them in an array.
Dim x as integer
Dim i as integer
Dim theArray() as string

for x = 0 to ubound(theArray)
i = GetIndex(theArray(x),Combo1)
Combo1.Remove i
next x

End Sub

'this routine will go through the list and return the correct index
public Function GetIndex(sFind as string, cboBox as ComboBox) as integer

Dim i as Integer
Dim intCounter as Integer

With cboBox
intCounter = .ListCount - 1
for i = 0 to intCounter
If .List(i) = sFind then
GetIndex = k
Exit for
End If
next
End With

End Sub




That should get you going.

John

John Pirkey
MCSD
www.ShallowWaterSystems.com