VB XMLHTTP使用方法
更新时间:2008年07月15日 18:44:40 作者:
VB判断地址是否存在的XMLHTTP方法
Private Function IsHearOK(URL As String) As Boolean
Dim XMLObject As Object, ReturnType As String
Set XMLObject = 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
If XMLObject.Status = 200 Or XMLObject.Status = 206 Then
ReturnType = XMLObject.getResponseHeader("CONTENT-TYPE")
If UCase(ReturnType) <> "TEXT/HTML" Then
IsHearOK = True
Else
IsHearOK = False
End If
Else
IsHearOK = False
End If
Set XMLObject = Nothing
End Function
Private Sub Command1_Click()
If IsHearOK("https://www.jb51.net/test.exe") Then
MsgBox "ok"
Else
MsgBox "no"
End If
End Sub
Dim XMLObject As Object, ReturnType As String
Set XMLObject = 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
If XMLObject.Status = 200 Or XMLObject.Status = 206 Then
ReturnType = XMLObject.getResponseHeader("CONTENT-TYPE")
If UCase(ReturnType) <> "TEXT/HTML" Then
IsHearOK = True
Else
IsHearOK = False
End If
Else
IsHearOK = False
End If
Set XMLObject = Nothing
End Function
Private Sub Command1_Click()
If IsHearOK("https://www.jb51.net/test.exe") Then
MsgBox "ok"
Else
MsgBox "no"
End If
End Sub
最新评论