List box search based on text box entry... 
Author Message
 List box search based on text box entry...

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!



Sun, 27 Jun 2004 00:52:10 GMT  
 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!



Sun, 27 Jun 2004 05:33:32 GMT  
 List box search based on text box entry...
Thank you!  That works great.

Also, any ideas on the ActiveX control?

Thanks again,
Dag

Quote:

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



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



Sun, 27 Jun 2004 07:37:24 GMT  
 List box search based on text box entry...
I am glad that it helped. I did once read an article about ActiveX controls
in the Knowledge Base, but your best bet would be to go to MSDN and read the
online help pages on creating an ActiveX control!

Rossco
:-}


Quote:
> Thank you!  That works great.

> Also, any ideas on the ActiveX control?

> Thanks again,
> Dag


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



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



Thu, 08 Jul 2004 04:25:24 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Text Box Entry To Text Box Display?

2. Limiting Access to Text Boxes, List Boxes and Combo Boxes

3. Columns in List box, when inserting text from text box (VBA)

4. Copy Last entry on Combo Box to Text Box

5. Help: Search Text In List Box

6. help: Implementing a list box using a unbound text box

7. Displaying Records in List Box as Data is input to Text Box on Form

8. Update Text Box from List Box

9. Resizing a Rich Text Box and a List Box

10. List Boxes n text Boxes

11. Help in understanding drag drop from a list box to a rich text box

12. List Box Help for Text Box Input

 

 
Powered by phpBB® Forum Software