VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Search a ListBox Control Quickly Using API Call

by Yuening Dai (30 Submissions)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 14th December 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Search a ListBox Control Quickly Using API Call

API Declarations


Private Declare Function SendMessage Lib "User32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
lParam As Any) As Long

Rate Search a ListBox Control Quickly Using API Call



Private Sub Text1_Change()
    List1.ListIndex = SendMessage(List1.hWnd, LB_FINDSTRING, -1, _
                ByVal Text1.Text)
End Sub
'
'If you like that the found item list stays next to top of the ListBox control,
'you can try this:
Private Sub Text1_Change()
    '
    On Error Resume Next
    '
    List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, _
                ByVal Text1.Text)
    '
    List1.TopIndex = List1.ListIndex - 1
    '
End Sub

Download this snippet    Add to My Saved Code

Search a ListBox Control Quickly Using API Call Comments

No comments have been posted about Search a ListBox Control Quickly Using API Call. Why not be the first to post a comment about Search a ListBox Control Quickly Using API Call.

Post your comment

Subject:
Message:
0/1000 characters