search "a" automatically output all starts from "a..."
somebody can help me on how to write a code in vb search... for example i have a textbox1 and a listbox, the user search in the textbox1 field input data "a" then the listbox automatically higlight the value that starts "a..."? i know this is very easy for you. can u share it with me... tnx in advance. :)
Re: search "a" automatically output all starts from "a..."
Try a search for 'Listbox Autocomplete' as there are a few different approaches :)
Re: search "a" automatically output all starts from "a..."
Bruce! 'Listbox Autocomplete' is another component to use? can u provide more complete info. but tnx...
Re: search "a" automatically output all starts from "a..."
Quote:
Originally Posted by noielen
Bruce! 'Listbox Autocomplete' is another component to use? can u provide more complete info. but tnx...
No, it is code. Here is an example using a textbox to autocomplete searching a ListBox.
VB 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
'Add a textbox above the listbox. Call it txtSearch
Private Sub txtSearch_Change()
List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal CStr(txtSearch.Text))
End Sub