Hello all,
I the following code (with the help of others) which looksup info in my listbox.
vb Code:
Private Const LB_FINDSTRING = &H18F Private Const LB_FINDSTRINGEXACT = &H1A2 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Sub txtLookup_Change() Dim strText$ strText = Trim$(txtLookUp.Text) If strText <> "" Then lstRadioSerials.ListIndex = FindItem(lstRadioSerials, strText) Else MsgBox "No matching record found; Please check your criteria!", vbInformation + vbOKOnly, "No Record Match" End If End Sub Private Function FindItem(lst As ListBox, strText As String) As Integer Dim iIndex As Integer iIndex = SendMessage(lst.hwnd, LB_FINDSTRINGEXACT, -1, ByVal strText) FindItem = iIndex 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?




Reply With Quote