Public Function urlbodytxt(urlstr As String) As String
Dim httpobj As New MSXML2.XMLHTTP50
Dim thetimeout As Long
httpobj.Open "get", urlstr, True httpobj.send
thetimeout = GetTickCount()
Do
If httpobj.readyState = 4 Then
If httpobj.Status = 200 Then
urlbodytxt = BytesToBstr(httpobj.responseBody, "GB2312")
Else
urlbodytxt = ""
End If Exit Do
End If If GetTickCount() - thetimeout > 6000 Then
urlbodytxt = "" Exit Do
End If
DoEvents
Sleep 200
Loop
Set httpobj = Nothing
End Function
我是用来测试是否能在6秒内打开我要打开的地址,由于是循环运行这个过程,只要运行后有一次readystate值达到了4(即成功访问到目标地址)后,那以后再运行到这里时,readystate的值就是一下子就到4了,运行open之前是0,open后是1,只要一运行send,那就直接到4
我在公司的电脑里调试完全没有问题,可回到家里同样是XP系统,为什么就会出现以上的问题
Dim httpobj As New MSXML2.XMLHTTP50
Dim thetimeout As Long
httpobj.Open "get", urlstr, True httpobj.send
thetimeout = GetTickCount()
Do
If httpobj.readyState = 4 Then
If httpobj.Status = 200 Then
urlbodytxt = BytesToBstr(httpobj.responseBody, "GB2312")
Else
urlbodytxt = ""
End If Exit Do
End If If GetTickCount() - thetimeout > 6000 Then
urlbodytxt = "" Exit Do
End If
DoEvents
Sleep 200
Loop
Set httpobj = Nothing
End Function
我是用来测试是否能在6秒内打开我要打开的地址,由于是循环运行这个过程,只要运行后有一次readystate值达到了4(即成功访问到目标地址)后,那以后再运行到这里时,readystate的值就是一下子就到4了,运行open之前是0,open后是1,只要一运行send,那就直接到4
我在公司的电脑里调试完全没有问题,可回到家里同样是XP系统,为什么就会出现以上的问题
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货