超时代码应该怎么写
XmlHttp.Send
stime = Now
While XmlHttp.ReadyState <>2
DoEvents
ntime = Now
If DateDiff("s", stime, ntime) > 1 Then GetHtml = "响应超时": Exit Function
Wend
这样有个致命的BUG,占用CPU太高了。。
XmlHttp.Send stime = Now While XmlHttp.ReadyState <>2 MyDoEvents 50 '数字自己调整~ ntime = Now If DateDiff("s", stime, ntime) > 1 Then GetHtml = "响应超时": Exit Function Wend Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Function MyDoEvents(Optional ByVal dwMilliseconds As Long = 1) MyDoEvents = DoEvents() Sleep dwMilliseconds End Function