Results 1 to 2 of 2

Thread: combo box

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    Dallas,Tx,USA
    Posts
    30
    i want to create a combo box that will dynamically scroll according to what a user enters into a TEXT BOX. If you go into the VB help section and click on the index tab and start typing the combo box or list box dynamically scrolls down according to the alphebetic letters the user is typing into the above text box.

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I can help you if you'll settle for using a listbox instead of a combo (I'm sure there's a way to do it with a combo, but I'm not sure how).

    Anyway, I tested the following and it works:

    Put a textbox and listbox on a form, set the listbox's Sorted property to True.

    In a module, put the following code:
    Code:
    Public Declare Function sendMessageByString Lib "user32" _
        Alias "SendMessageA" (ByVal hwnd As Long, _
        ByVal wMsg As Long, ByVal wParam As Long, _
        ByVal lParam As String) As Long
    
    Public Const LB_SELECTSTRING = &H18C
    In your form, put the following code in the indicated events:
    Code:
    Private Sub Form_Load()
    
        With Combo1
            .AddItem "Hamburger"
            .AddItem "French Fries"
            .AddItem "Coca Cola"
            .AddItem "Cheeseburger"
            .AddItem "Fried Chicken"
            .AddItem "Apple Pie"
        End With
    
    End Sub
    
    Private Sub Text1_Change()
    
        Dim lngEntryNum     As Long
        Dim strTextToFind   As String
        
        strTextToFind = Text1.Text
        
        lngEntryNum = sendMessageByString(Combo1.hwnd, LB_SELECTSTRING, _
                                          0, strTextToFind)
    
    End Sub
    I hope this helps.

    "It's cold gin time again ..."

    Check out my website here.

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