Hello all,

I the following code (with the help of others) which looksup info in my listbox.

vb Code:
  1. Private Const LB_FINDSTRING = &H18F
  2. Private Const LB_FINDSTRINGEXACT = &H1A2
  3.  
  4. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
  5. (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  6.  
  7. Private Sub txtLookup_Change()
  8.     Dim strText$
  9.    
  10.     strText = Trim$(txtLookUp.Text)
  11.     If strText <> "" Then
  12.          lstRadioSerials.ListIndex = FindItem(lstRadioSerials, strText)
  13.     Else
  14.         MsgBox "No matching record found; Please check your criteria!", vbInformation + vbOKOnly, "No Record Match"
  15.     End If
  16. End Sub
  17.  
  18. Private Function FindItem(lst As ListBox, strText As String) As Integer
  19.    
  20.     Dim iIndex As Integer
  21.     iIndex = SendMessage(lst.hwnd, LB_FINDSTRINGEXACT, -1, ByVal strText)
  22.     FindItem = iIndex
  23. End Function

This works for looking up the certain serials in my listbox, but what I would like to do is refine it a little more.

What I would like to add is this: when a user starts to type in the serial number and he types a wrong number (ie. he is looking for 1234 and he types 1224), then I would like an error message to state that there is no record with that serial number.

Right now when the user types the wrong number, the only thing that happens is that the highlighted part will not move anymore in the listbox.

I hope that I am not too confusing?