
List box search based on text box entry...
Dag,
You will need to delve into winapi to complete this!
Create two new Modules....
Paste the following into one...
'****************************************************
'* Created: 17/9/01
'* Author: Ross Francis
'* API Function Declaration to allow calls to send message
*****************************************************
Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
'API Message Constants Declaration for send message
'ListBox Find String
'eg: SendMessage (listbox.hwnd, LB_FindString, -1, byval cstr(String))
Public Const LB_FINDSTRING = &H18F
Paste the following into the other....
'****************************************************
'* Created: 17/9/01
'* Author: Ross Francis
'*
'* Usage: FindString ListboxName, TextBoxName
'* Use within the change event of a
'* textbox
'*
'* Other Information:
'* WinAPI declaration for SendMessage and
'* Constant LB_FindString must exist
'*
'****************************************************
Public Function FindString(ListBoxName As ListBox, _
TextBoxName As TextBox)
ListBoxName.ListIndex = SendMessage(ListBoxName.hwnd, _
LB_FINDSTRING, _
-1, _
ByVal CStr(TextBoxName.Text))
End Function
Then on your form where you have a textbox (Text1) and a listbox (List1) in
the change event of the textbox paste the following code...
Private Sub text1_Change()
FindString lstDefault, txtFind
End Sub
If this is any help please let me know!
Rossco
:-}
Quote:
> The end result is that I'm trying to allow the user to enter an employee's
> name in a text box, all the while the list box is displaying the employee
> who's name matches/starts with the letters typed. Any ideas? Or an
> alternate idea/method?
> Also, when creating an ActiveX.exe control is there anything special I
need
> to be aware of when adding that control to a form? Or when exiting from
an
> application?
> Thanks!