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
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