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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search function - string comparison

Status
Not open for further replies.

tutuster

Programmer
Feb 2, 2005
41
FI
I am working on a search function to compare strings, one provided by the user (search string) and the other provided by existing data (listview item/text).

I have no clue where to start, I've looked up the compare and compareordinal methods but they don't open up to me.

For example , user searches for "book", and the listview has several matching items such as "ebook", "book store" "booking" or similar *book* strings.

Anyone who could point me to a direction? Any use of the Like-statement?

Thanks for any replies

-tutuster-
 
Try using the IndexOf method of the ListView Item.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Maybe my question was not clear enough, listview was not the problem..

Anyway, I solved the issue by using InStr-method, suits well for my purpose.
 
What I meant was that you can use IndexOf on a string (I just used the text of the ListView item as an example). IndexOf does basically the same thing as InStr but it can be used directly on a string (and I would personally use it over InStr). i.e.
Code:
        Dim strTest As String = "12345"
        Dim intPosition As Integer
        intPosition = strTest.IndexOf("4")

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top