remove items from combo box

samantha January 27, 2009 at 11:33:10
Specs: Windows XP
hiya guys...

well i have 2 combo boxes. start_time and end_time. They both contain 26 times starting from 09:00:00 to 22:00:00. Depending on what time is chosen for the start time, i want times equal to it and less than it to be removed from the end_time combo box. This is actually for VB6.

this is the code i have so far: it works sometimes but at times shows 'invalid procedure calll or argument' error

Private Sub Command1_Click()
Dim cbo_list_item As Integer
cbo_list_item = -1

Do Until cbo_list_item = 27
cbo_list_item = cbo_list_item + 1
If cmb_Start_Times.Text >= cmb_End_Times.List(cbo_list_item) Then
cmb_End_Times.RemoveItem (cbo_list_item)
End If
End Sub

See More: remove items from combo box

Report •

January 29, 2009 at 11:21:47
Not sure if it's what you're after, but try the code below. combo1 is the start.

What event triggers the random proceedure error? Are you resetting combo2 (end time) prior to calculating new times?

Dim idx As Integer

Private Sub Combo1_Click()

   idx = Combo1.ListIndex
End Sub

Private Sub Command1_Click()

   Dim i As Integer
   For i = idx To 0 Step -1
      Combo2.RemoveItem i
   Next i
   Combo2.Text = IIf(Combo2.ListCount > 0, Combo2.List(0), "No data")   
End Sub


Report •
Related Solutions

Ask Question