Searching through a ListBox for a specific value
Posted on 2004-03-26
I'm trying to figure out a way to search through items in a listbox for a specific word or phrase. I've found a way to do it by using.........
Const LB_FINDSTRING = &H18F
Private Declare Function SendMessageByNum Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal _
wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
.......but that only works if the user enters exactly what is on the entire line in the listbox.
My listbox contains a concatenation of about 10 different fields from the table, so a few sample lines might look something like this...
34651 - 03/25/2004 - 27 MAIN ROAD - EASTGATE SUBDIVISION - WALTER GOSSE - JANE GOSSE
14387 - 01/15/2004 - 145 SPRUCE STREET - OAK SUBDIVISION - JACK JONES - JUDY JONES
39843 - 09/18/2003 - 8 TOPSAIL ROAD - WOODLANDS SUBDIVISION - JOHN SMITH - BEV SMITH
26349 - 02/13/2004 - 88 CHURCH ROAD - GRANVILLE SUBDIVISION - JIM TATE - MARY WHITE
I want the user to be able to type in a search phrase, for example, JOHN, and have it make the line with the word JOHN in it the selected record.
It will work if JOHN is at the beginning of the line, but not in the middle somewhere.
Do you know if there is a way to do this?