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. list box 2 based on list box 1

2. Update Text Box from List Box

3. Beginner: Populating text box by selecting from list box

4. ADO List box and Text boxes

5. Filling in a text box based on value list selection

6. Toggling Between List Boxes at the Same Location and Selecting Records in Each List Box

7. Data entry into an @...LIST box???

8. List Box and Combo box

9. VFP5 - List/combo boxes with > 253 entries

10. pls help : COMBO box or list box

11. Application Role w/Access 2000 combo boxes, list boxes, reports

12. Automatically displaying combo box's drop down list on field entry


 
Powered by phpBB® Forum Software