Searching contents of a Combo Box


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Searching contents of a Combo Box

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Searching contents of a Combo Box

    [Originally posted by Joe Melton]

    I need to give the user the option of restricting selection to the contents of the combo box or being able to manually type in a string that is not contained within the combo box (this is controlled through a check box. If the checkbox is checked, the user must select an item contained within the combo box. If it is unchecked, the user can enter a value not contained within the combo box).

    My problem is this (and I'm sure it's a very newbie problem):
    On user text entry, how do I search the contents of the combo box, using the text the user has entered as a search string? (If the check box is checked, and the search string is not found, a message box will appear telling the user that he or she must select a value contained within the combo box. If the check box is unchecked, the user may enter a value not contained within the combo box).

    I hope this is enough information. If you have an answer for me, please send me a code example. Thank you in advance.

    Joe Melton

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Searching contents of a Combo Box

    [Originally posted by FreeVBCode.com]

    Dim l as Long
    Dim lCnt as Long
    Dim bFound as Boolean

    lCnt = Combo1.ListCount - 1

    For l = 0 to lCnt
    If combo1.List(l) = Text1.Text Then
    bFound = True
    Exit For
    End If
    Next

    If not bFound then
    msgbox "Illegal Entry"
    End If

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Searching contents of a Combo Box

    [Originally posted by Joe Melton]

    Thanks.

    Joe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center