Click to See Complete Forum and Search --> : Search list box


Amy998
September 20th, 1999, 10:53 AM
I have a .csv file saved with lastname, firstname, address, phone, fax, email information and I have a form with a text box which for searching the list box, a list box, six text boxes for showing the information about that person which i click in the list box.
When the form is loaded, only the lastname and firstname are added to the list box(I already finished this part).

What I need help is:
1. when I type something in the searching text box, the list below scrolls and shows me the name in the list which is nearest to the name in the searching text box in the first position which is visible and marks it.(This like Microsoft outlook's Address Book)
2. If this marked name is I need then I puch the enter key, all the information about this person will show in the six text boxes.

can somebode please help me to code this ?

Lothar Haensler
September 20th, 1999, 11:38 AM
how I'd approach it:
1. Trap the CHANGE event of the textbox. Whenever the TEXT property of the textbox is not "", send a LB_FINDSTRING message to the listbox using the SendMessage API (or, iterate over all entries using a

for i = 0 to list1.listcount-1



loop.
Then, set the listindex to the index of the found item to scroll it into view.

2. trap the keypress event for the textbox and watch for the ENTER key. If that occurs, split the listbox entry (.ListIndex) into its parts and assigns these parts to the corresponding textboxes.

One suggestion:
use a listview control instead of a listbox. It supports multiple columns (choose report view) and is easier to handle. Also, it has a FindItem method.