VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



vbFindInList NO API

by Yaser Hani (1 Submission)
Category: Coding Standards
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (11 Votes)

This searches for a string in a listbox, it can retrieve multiple results and can use only partial string..

Inputs
The string to search for, and the listbox to search in.
Assumes
Non
Code Returns
True if found, and it highlights the list items that contains the search criteria.
Side Effects
Non
API Declarations
'This is how it's done the EASY WAY, No API declarations required..suitable for small to medium lists...enjoy..
Function vbFind(vbString As String, vbList As ListBox, Optional iStart As Integer) As Boolean
Dim vbWhere As String
vbFind = False
If iStart < 0 Then iStart = 0
If vbString <> "" Then
For i = iStart To vbList.ListCount - 1
vbString = LCase(vbString)
vbWhere = LCase(vbList.List(i))
If InStr(1, vbWhere, vbString) > 0 Then
vbFind = True
Debug.Print (i)
vbList.Selected(i) = True
iStart = i + 1
End If
Next i
End If
If vbFind = False Then MsgBox "Search string not found, Please make sure that you've entered the file name correctly and try again.", vbCritical, "Error"
End Function

Rate vbFindInList NO API

Download vbFindInList NO API

Download vbFindInList NO API (3 KB)

vbFindInList NO API Comments

No comments have been posted about vbFindInList NO API. Why not be the first to post a comment about vbFindInList NO API.

Post your comment

Subject:
Message:
0/1000 characters