If My.Computer.Network.Ping("tiancao.net") Then
MsgBox("能访问网站")
Else
MsgBox("网站访问受限")
End If
'Dim HTTP As New System.Net.WebClient
'Try
' Dim Str As String = HTTP.DownloadString("http://www.tiancao.net")
' MsgBox("网站正常访问")
'Catch ex As Exception
' MsgBox("网站访问中出现异常")
'End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim req As HttpWebRequest = CType(WebRequest.Create("http://www.tiancao.net"), HttpWebRequest)
Dim resp As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)
If resp.StatusCode = HttpStatusCode.OK Then
resp.Close()
MsgBox("true")
End If
Catch webex As WebException
MsgBox("False")
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If My.Computer.Network.IsAvailable = True Then
'如果可用
MsgBox("可用")
Else
'不可用
MsgBox("不可用")
End If
End Sub
[本日志由 tiancao1001 于 2018-03-03 08:50 PM 编辑]
|
|
暂时没有评论
| 发表评论 - 不要忘了输入验证码哦! |
用户登陆
站点日历
站点统计
最新评论
VB.net 判断网络或网址是否连接 [ 日期:2018-03-03 ] [ 来自: