【发布时间】:2017-12-03 23:22:48
【问题描述】:
我正在尝试将我的外部 IP 放入标签中,因此我正在根据站点下载结果,但是当我通过 VPN 更改我的 IP 时,应用程序崩溃了,我相信这是因为它没有检查如果它把绳子拉下来,他试过了。
在表单加载中...
If Label1.Text = LastIp Then
Try
Dim wc As New WebClient
Label1.Text = wc.DownloadString("http://icanhazip.com/")
If you can not then
Label.Text = "Failed to get IP"
End if
End If
表格...
【问题讨论】:
-
使用
Try/Catchstatement。另外,如果您能告诉我们您遇到的错误,那将会很有帮助。
标签: vb.net ip try-catch detection downloadstring