Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27512

VS 2010 do until line is empty

$
0
0
Hi All,
I have file like:
Code:

xxx,ccc
ccc,xxx
fff,kkk

aaa,www
www,aaa

ddd,eee
rrr,sss

And I want to find a certain row and start reading next rows until I reach blank. Something like that:
Code:

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Dim path As String = "D:\tariff.txt"
        Dim line As String
        Dim row As String
        Dim sr As StreamReader = New StreamReader(path)
        Do While sr.Peek() >= 0
            line = sr.ReadLine()
            If line = "xxx,ccc" Then
                Do Until line = ""
                    sr.Peek()
                    row = sr.ReadLine()
                    MsgBox(row)
                Loop
            End If
        Loop
        sr.Close()
    End Sub

Of course the above is not working, It doesn't stop on the empty line after "fff,kkk".
Could you please help me with that?

Thanks in advance!

Viewing all articles
Browse latest Browse all 27512

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>