Visual Basic If statements issues

Associate
Joined
3 Jun 2005
Posts
22
Right here is my issue,

What i want to achieve using streamreader is to read between particular rows in a text file, and only out put the data in between the rows and continue for each item in the document. For example

Text Start
1
2
3
Text End

So i have some code that says if line contains text start then output the code after that until it reads text end. I can get it to either out put the entire document or out put any lines that read text start. Here is my code...

While lineoftext IsNot Nothing
If lineoftext.Contains("Text Start") Then
txtResults.Text = txtResults.Text & srIn.ReadLine & vbNewLine
End If
lineoftext = srIn.ReadLine()
End While

Can anyone see where im going wrong?
 
Thanks for the response. That's the one thing I'm struggling with, I'm not sure how to stop it when it gets to the text end.

I was hoping that I could write some code that would say

If line of text contains text start, read and output all the data until the line reads text end.

Then I want to loop this until the end of the document
 
Back
Top Bottom