DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  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

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links