Chelovek Chelovek - 1 month ago 16
Vb.net Question

vb.net read text from web .txt file and show it in textbox?

I am trying to read few number from internet .txt file and show it in text box, but without result...

These systems are imported:

Imports System.IO
Imports System.Text
Imports System.Net


Here is the code of reading file:

Dim address As String = "http://www.url.com/text.txt"
Dim client As WebClient = New WebClient()
Dim reply As String = client.DownloadString(address)
TextBox2.Text = reply

Answer

Try this instead:

Dim address As String = "http://www.stackoverflow.com"
Dim client As WebClient = New WebClient()
Dim reader As StreamReader = New StreamReader(client.OpenRead(address))
Textbox2.Text = reader.ReadToEnd
Comments