VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A Good ListBox Seach function

by noroom (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

This code searches a listbox for a given string, and returns the the ListIndex of the Item that matches the given string.

Inputs
The string you want to find in the listbox
Code Returns
if found: the ListIndex that matches the given string If not found: returns -1

Rate A Good ListBox Seach function

Private Function SearchList(ToSearch As String, lstList As ListBox) As Integer
Dim i As Integer
SearchList = -1
For i = 0 To lstList.ListCount - 1
 If LCase(lstList.List(i)) = LCase(ToSearch) Then
  SearchList = i
  Exit For
 End If
Next i
End Function

Download this snippet    Add to My Saved Code

A Good ListBox Seach function Comments

No comments have been posted about A Good ListBox Seach function. Why not be the first to post a comment about A Good ListBox Seach function.

Post your comment

Subject:
Message:
0/1000 characters