Search Tools Links Login

A Good ListBox Seach function


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

Original Author: noroom

Inputs

The string you want to find in the listbox

Returns

if found: the ListIndex that matches the given string
If not found: returns -1

Code

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

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 97 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.