vb.net:webclient无法正常工作?

时间:2009-12-29 18:52:38

标签: vb.net webclient

Dim instance As WebClient
Dim address As String
Dim avoids as string

address = "http://www.ecosavetech.com/avoid.txt"

avoids = instance.DownloadString(address)

MsgBox(avoids)

msgbox没有显示任何内容。

请帮忙!我也没有收到任何错误

我正在使用Imports System.Net

2 个答案:

答案 0 :(得分:4)

确定你没有收到任何错误?您的代码在未引用实例的变量上调用DownloadString方法。你可能也希望创建一个WebClient

Dim instance As New WebClient()
Dim address As String
Dim avoids As Atring

address = "http://www.ecosavetech.com/avoid.txt"

avoids = instance.DownloadString(address)

MsgBox(avoids)

答案 1 :(得分:4)

在您共享的代码中,您实际上并未创建WebClient。

Dim instance as WebClient = new WebClient()