Find string in array

shers

Well-known member
Joined
Aug 12, 2007
Messages
86
Programming Experience
1-3
Hi,

I'm working in VB.Net. I have a textbox in which the user enters a number of strings seperated by comma. I store this value in a string array like this

VB.NET:
  Dim Src() As String
  Src = txtVals.Text.Split(",".ToCharArray)

I want to search a dynamic string in this array. How could I do it in the fastest way?

Thanks
 
That is not working. It gives only 0 and -1.
Sounds like it's working to me. If those are the only values you can get the your array has no more than 1 element. 0 means that the value you're looking for is the first element and -1 means it's not found.
 
When I used trim and coded this way, it worked.

VB.NET:
For Each s As String In Src
   If Trim(s) = blk.Name.ToString Then
        LV.Items.Add(s)
   End If
Next

What should be wrong?
 
Back
Top