VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2

by Bader Mubarak (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 8th March 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2 Lines of code,very easy and very

Rate Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2



'add a textbox(text1),a listbox(list1) and a combobox(combo1)then add then following:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Const LB_FINDSTRING = &H18F
Const CB_FINDSTRING = &H14C


Private Sub Form_Load()
    'Add some items to the listbox
    With List1
        .AddItem "Computer"
        .AddItem "Screen"
        .AddItem "Modem"
        .AddItem "Printer"
        .AddItem "Scanner"
        .AddItem "Sound Blaster"
        .AddItem "Keyboard"
        .AddItem "CD-Rom"
        .AddItem "Mouse"
    End With
        With Combo1
        .AddItem "Computer"
        .AddItem "Screen"
        .AddItem "Modem"
        .AddItem "Printer"
        .AddItem "Scanner"
        .AddItem "Sound Blaster"
        .AddItem "Keyboard"
        .AddItem "CD-Rom"
        .AddItem "Mouse"
    End With
Text1.Text = ""
End Sub
Private Sub Text1_Change()
    'Retrieve the item's listindex
    List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal CStr(Text1.Text))
    Combo1.ListIndex = SendMessage(Combo1.hwnd, CB_FINDSTRING, -1, ByVal CStr(Text1.Text))
End Sub


Download this snippet    Add to My Saved Code

Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2 Comments

No comments have been posted about Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2 . Why not be the first to post a comment about Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2 .

Post your comment

Subject:
Message:
0/1000 characters