Picking Up A Particular String

sivag

Member
Joined
Jul 10, 2007
Messages
15
Programming Experience
Beginner
Hi i need help regarding the following:


my goal is: Am reading a text file which has values delimited with '|'.
Now i need to search each line of text file for a specific string which i'll be receiving from user.If the searching string is found,i need to display a part of string from the line where i found the string.

I did the foll:

Am reading it with filestream reader & assigning those into a arraylist.

Using enumerator,i read each line from arraylist & temporarily assigning it to a variable.Then i used "contains" method to search the line for the specific string.

Problem is It works on all occurences of the string.For ex:if the string to be searched is CSC,it takes into account of all C,S,C's present in each line & displaying the other part of string from all lines wherever C,S,C's are found.It doesn't looking up for the particular combination "CSC"

Is there any other idea other than this or can this itself be made changes to make it work? PLZ HELP ME:)
 
as both the lines contain "bc"

What? Both lines do not contain "bc"

I think you need to change the logic, rather than searching for abc within the string (what you asked for first) you want to see if abc is in the second set of bars?

Dim bits() as String = line.SPlit("|"c)
If "abc".Equals(bits(1)) Then MessageBox.Show(bits(3))



In future, when asking a question, please try to present the problem logically, and clearly.. i.e. think like a computer, rather than a human
 
Back
Top