范文 |
vb判断联网代码,判断联网是在vb软件中不可或缺的,在搜索了很多的判断联网代码中,这个是在csdn上面找到的简单方便好用。 贴出来跟大家分享 Function islink_fun(url) As Boolean Dim xmlHttp As Object, i, j j = 0 Set xmlHttp = CreateObject("Microsoft.XMLHTTP") xmlHttp.open "GET", url, True xmlHttp.send (Null) i = Now() Do DoEvents Loop Until xmlHttp.ReadyState = 4 Or j = DateDiff("s", i, Now()) > 2 If j = 0 Then If xmlHttp.Responsetext = "" Or IsNull(xmlHttp.Responsetext) Then islink_fun = False Else islink_fun = True End If Else islink_fun = False End If End Function ’vb调用判断联网代码是 If islink_fun("http://www.baidu.com") Then MsgBox "连接" Else MsgBox "没有连接" End If ’该方法简单好用,非常推荐 |