Re: VB5 - Searching List?
What "list" would that be? Listbox, Combobox, some grid, multi line text, etc.. :confused:
In case you need to search Listbox or combo try this:
Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Const LB_FINDSTRING = &H18F
Private Const LB_FINDSTRINGEXACT = &H1A2
Private Const CB_FINDSTRING = &H14C
Private Sub Command1_Click()
Dim strText As String
'''strText = InputBox("Prompt", "Title", "search text")
strText = Text1.Text
List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRINGEXACT, -1, ByVal strText)
End Sub
Re: VB5 - Searching List?
Thanks, yeh it's a Listbox just that code doesn't seem to highlight the searched text. I press the search button and it doesn't give an error but also doesn't do anything. All the names are right aswell? :S
Re: VB5 - Searching List?
As you can see there are two constants available: LB_FINDSTRINGEXACT and LB_FINDSTRING.
In my sample I used LB_FINDSTRINGEXACT so try the other one instead.
Re: VB5 - Searching List?
Ooo it works, thanks once again!