Incremental Search in VB.NET


I have a grid bound to a database.  I want the user to be able to make incremental search.(User will enter some letters in text box and the string starting with the same should be highlighted) I am using the function Instr (of VB.NET):

for each Row in Mydatagrid.Rows
If Instr(str1,str2,comparemethod.text) > 0 then
currentrow = activerow
Exit for
end if

The problem is that if I want to search for strings starting with 'r' and in the rows there is a person containing the name like Bear, then this name is highlighted first instead of the one starting with R. How should I program this so that the string STARTING with the first few characters of the text box is displayed.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If Left(str1,Len(str2)) = str2 then
p_gauri7Author Commented:
I get a build error saying, public property Left has  no parameters and its return type can not be indexed
Sorry, it should be Strings.Left(...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.