Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Collection

Status
Not open for further replies.

NicoleM

Programmer
Oct 18, 2001
23
ZA
What is the most efficient method to search through a collection? (in this case the dropdownlistbox's item collection) for a PARTIAL match of a string ie
if the collection has 4 items:

1. House
2. Egg
3. Bannana
4. Bat

so If I search for Ba I would like 3 returned as the index and if I search for Bat then I would like 4!
(this particular dropdownlistbox does not have a data source)

Thanks!
Nicole
 
For i As Integer = 0 To lb.Items.Count - 1
If DirectCast(lb.Items(i), String).IndexOf("Ba") <> -1 Then Return i
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top