The listbox itself only allows you to store the names of things, there isn't a "key" field that you can attach to each of the entires in it.
This means that while you can search by name :
Code:
Function FindByName(Text as string) as Long
Dim lNum as Long
For lNum = 1 to List1.ListCount
If List1(lNum) = Text Then
FindByName = lNum
Exit Function
End If
Next lNum
FindByName = -1
End Function
You can't actually search by code.
The only way you "could" try to fake it would be to use a collection and for each member of the collection you set the "key" value to be the ID code you are after. Then all you need to do is test to see if the ID code exists and then use that in the same function above.
Code:
Dim cTest as string
cTest = ""
On Error Resume Next
cTest = MyCollection(cIdToSearch)
On Error goto 0
If cTest <> "" Then
List1.Index = FindByName(cTest)
End If
Hope it leads you in the right direction.