Reputation: 17
I am fetching 3 line of text from a website with my vb.net application and i only want to show the second line in my my label when i press a button. The code i currently have show me all the 3 lines. How can i only display the 2nd line.
Dim webAddress As String = "Website"
Dim reader As StreamReader
Dim request As WebRequest
Dim response As WebResponse
Dim data As String = ""
Try
request = WebRequest.Create(webAddress)
request.Timeout = 30000
response = request.GetResponse()
reader = New StreamReader(response.GetResponseStream())
data = reader.ReadToEnd
Catch ex As Exception
MsgBox(ex.Message)
End Try
Upvotes: 0
Views: 1597
Reputation: 186
Read individual lines:
reader.ReadLine() 'read and discard the first line
data = reader.ReadLine() 'read the line you want
reader.ReadToEnd 'read and discard the rest
Upvotes: 0
Reputation: 3663
You may do this after ReadToEnd:
Label1.Text = Split(data, VBCrLf)(1)
Upvotes: 1