Results 1 to 3 of 3

Thread: Combo Box

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Posts
    2

    Question

    Hello everyone!!! Thanks in advance for any help/ insight that you can offer.

    Here's my issue:

    Say you have a combo box that gets its list items from a sequential file. The user enters a word that is NOT in the list. What type of event and what criteria do I use to find out that the word is NOT in the list.

    IE
    the combo box says: 'Apple' 'Orange' 'Pear'
    the user enters: 'Grape'

    Private Sub cboFruit_?()

    If cboFruit.Text <> 'what's in the combo box' Then
    ......
    End If


    Again, what type of event should be used and what is the criteria that needs to be used to compare the list to what the user enters?

  2. #2
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    Hi,

    This may not be the best option, but it seems to be a simple one.

    Combo1_Change (the change event for the combobox)

    dim counta as integer

    for counta = 0 to combo1.listcount-1

    'does it exist already

    'checking without case differences/trimming the extra spaces

    if combo1.text= combo1.list(counta) then

    'it exsists already
    'do something here
    else

    'it doesn't exist
    'do something here

    endif

    next


    I hope that helps
    DocZaf
    {;->










  3. #3

    FYI

    I'm not sure about VB, but MS Access 97 combo boxes had a really neat property called NotInList. This would set whether the combo box would handle anything other than what was intended be selected.

    There is a simple way around your problem. The style property of vb combo boxes can be changed. If you change it to 3 then this only allows users to select something from your box.

    Hope this helps

    Matt

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