Results 1 to 6 of 6

Thread: checking combo box data(container?)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908

    checking combo box data(container?)

    Is there a way where i can check the items that have been added to the combo box before?( without any looping)...like

    If combo.( ? ) ="xxx" then
    ..


    thanks

  2. #2

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    yes you are rite..(value = the items that have been added in)...any simplier methods (using ny properties of the combo box) to check...

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427
    VB Code:
    1. Option Explicit
    2. Private Declare Function SendMessageString Lib "user32" Alias "SendMessageA" _
    3.                       (ByVal hWnd As Long, _
    4.                        ByVal wMsg As Long, _
    5.                        ByVal wParam As Long, _
    6.                        ByVal lParam As String) As Long
    7. Private Const LB_FINDSTRINGEXACT = &H1A2
    8. Private Const CB_FINDSTRINGEXACT = &H158
    9. Private Const CB_FINDSTRING = &H14C
    10. Private Const LB_FINDSTRING = &H18F
    11.  
    12. Private Sub Command1_Click()
    13.  
    14.     Dim lngRetVal As Long
    15.    
    16.     lngRetVal = SendMessageString(Combo1.hWnd, CB_FINDSTRINGEXACT, -1&, strSomeValue)
    17.    
    18.     If lngRetVal > -1& Then
    19.         ' It's already in the list and lngRetVal is the ListIndex
    20.     Else
    21.         ' It's not in the list
    22.     End If
    23.                    
    24. End Sub
    I added some extra stuff so that you can change it to do partial or exact searches on either a listbox or a combobox.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    ..wow..its a bit difficult for me to understand though...but will give a try...thanks alot..

  6. #6

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