VB XMLHTTP使用方法
发布时间:2016-12-28 来源:查字典编辑
摘要:PrivateFunctionIsHearOK(URLAsString)AsBooleanDimXMLObjectAsObject,Retu...
PrivateFunctionIsHearOK(URLAsString)AsBoolean
DimXMLObjectAsObject,ReturnTypeAsString
SetXMLObject=CreateObject("Microsoft.XMLHTTP")
XMLObject.Open"GET",URL,False
XMLObject.setRequestHeader"CONTENT-TYPE","application/x-www-form-urlencoded"
XMLObject.setRequestHeader"Range","bytes=1-255"
XMLObject.Send
IfXMLObject.Status=200OrXMLObject.Status=206Then
ReturnType=XMLObject.getResponseHeader("CONTENT-TYPE")
IfUCase(ReturnType)<>"TEXT/HTML"Then
IsHearOK=True
Else
IsHearOK=False
EndIf
Else
IsHearOK=False
EndIf
SetXMLObject=Nothing
EndFunction
PrivateSubCommand1_Click()
IfIsHearOK("http://www.jb51.net/test.exe")Then
MsgBox"ok"
Else
MsgBox"no"
EndIf
EndSub