VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Search for a string in Listbox

by Download Land Software (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

Search for string in listbox

Assumes
This project needs a ListBox, named List1 and a TextBox, named Text1
Code Returns
the Listindex of the string that is found.
API Declarations
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Const LB_FINDSTRING = &H18F

Rate Search for a string in Listbox

Private Sub Form_Load()
  'KPD-Team 1998
  'URL: http://www.allapi.net/
  'E-Mail: [email protected]
  'Add some items to the listbox
  With List1
    .AddItem "Computer"
    .AddItem "Screen"
    .AddItem "Modem"
    .AddItem "Printer"
    .AddItem "Scanner"
    .AddItem "Sound Blaster"
    .AddItem "Keyboard"
    .AddItem "CD-Rom"
    .AddItem "Mouse"
  End With
End Sub
Private Sub Text1_Change()
  'Retrieve the item's listindex
  List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal CStr(Text1.Text))
End Sub

Download this snippet    Add to My Saved Code

Search for a string in Listbox Comments

No comments have been posted about Search for a string in Listbox. Why not be the first to post a comment about Search for a string in Listbox.

Post your comment

Subject:
Message:
0/1000 characters