2013-05-20 86 views
4

我想讀從互聯網.txt文件幾號,並顯示在文本框中,但無果而終......vb.net從web.txt文件中讀取文本並將其顯示在文本框中?

這些系統的輸入:

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

這裏是閱讀文件的代碼:

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 

回答

8

試試這個:

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 
+0

謝謝你,爲我工作。我忘了在LOAD上設置私人分區,現在就像一個魅力。 – Chelovek

相關問題