Computing.Net > Forums > Programming > remove items from combo box

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

remove items from combo box

Reply to Message Icon

Name: samantha
Date: January 27, 2009 at 11:33:10 Pacific
OS: Windows XP
Subcategory: C/C++
Comment:

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
Loop
End Sub



Sponsored Link
Ads by Google

Response Number 1
Name: shutat
Date: January 29, 2009 at 11:21:47 Pacific
Reply:

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

HTH


0
Reply to Message Icon

Related Posts

See More


NT 4.0 Drivers timed program



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: remove items from combo box

VB Removing Items from list Box www.computing.net/answers/programming/vb-removing-items-from-list-box/9822.html

Filtering more than one combo box www.computing.net/answers/programming/filtering-more-than-one-combo-box-/4992.html

combo box vs List box www.computing.net/answers/programming/combo-box-vs-list-box/10114.html