Results 1 to 9 of 9

Thread: ComboBox (CLEAR and ADDITEM)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    22

    ComboBox (CLEAR and ADDITEM)

    What is the code for Clearing ComboBox and adding Item to the Combobox?

  2. #2
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Now, not wanting to take the piss, but if you add a combo box to your form, then in the code window type Combo1 then press the . (full stop) you will get a list of properties/methods.
    Try it yourself, and see which properties you think may clear a combo box and add an item to a combo box

    Woka

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    22
    I've tried putting the "." but then...there isn't any suitable method that I can use.

  4. #4
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    You dont see combo1.additem or combo1.clear?

    You sure you have a ComboBox on your form?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    22
    There is only

    .Count
    .Item
    .LBound
    .UBound

    I'm very sure that it is ComboBox

  6. #6
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    What version of VB?

    Zip up your project and upload it.

  7. #7
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627
    Is that VBA?

  8. #8
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Right...u have a control array of combo boxes.
    U copied and pasted a combo onto your form and when VB asked "Do you want to create a control array" you clicked yes.

    This means that to get at the props/methods of a combo you would use combo.Item(2) or whatever the index value is of the combo box u want to use. Then press . and u will see all the mthods.

    Woka

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    It's in a control array - muliple controls have the same name, and must be accessed via their Index.

    If that isnt what you want, then just open the form in design view, select the control, and remove the value in the Index property. All will then be fine.

    If you do want a control array, then you need to use the index, eg: Combo1(0).AddItem "test"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width