VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Quickly Search a List Box. A popular item in a user interface is to link a text box to a list box

by Anonymous (267 Submissions)
Category: Windows System Services
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 16th July 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Quickly Search a List Box. A popular item in a user interface is to "link" a text box to a list box so that as the user types text into the

API Declarations



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
Public Const LB_FINDSTRING = &H18F

Rate Quickly Search a List Box. A popular item in a user interface is to link a text box to a list box



'2) Add the code below to the form
'3) If you run the code, typing text into the text box selects the first item in the list that matches the text in the text box. 

Sub Form_Load()
    List1.Clear
    List1.AddItem "Apples"
    List1.AddItem "Banana"
    List1.AddItem "Bread"
    List1.AddItem "Break"
End Sub

Sub Text1_Change()
   List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, _
   ByVal CStr(Text1.Text))
End Sub

Download this snippet    Add to My Saved Code

Quickly Search a List Box. A popular item in a user interface is to link a text box to a list box Comments

No comments have been posted about Quickly Search a List Box. A popular item in a user interface is to link a text box to a list box. Why not be the first to post a comment about Quickly Search a List Box. A popular item in a user interface is to link a text box to a list box.

Post your comment

Subject:
Message:
0/1000 characters