In the following Loop I am highlighting/selecting all the items in the listbox that match the ID records from the database. This is in VB6.
Do Until rec.EOF
For lngEntry = 0 To List(0).ListCount - 1
If InStr(1, List(0).List(lngEntry), rec!RegID) > 0 Then
List(0).Selected(lngEntry) = True
A typical listbox looks like this:Doe, John - 3
Hamilton, Mark - 12
Stan, Manny - 15
Hyde, Park - 2
In my code rec!RegID
contains the ID of the individual in the database. I'm not positive but I believe that the function InStr
searches a string within a string which is not what I exactly want because in the current code I have, Hyde, Park - 2
and Hamilton, Mark - 12
might cause an issue since they both have the number 2.
What I want, is to search for the unique ID string
to the right of the hyphen. How can I adjust my code to do exactly that? Maybe my code is currently doing that and I'm mistaken, but I could use a little guidance.