大智

快乐工作中生活

 

vb word

http://www.yesadmin.com/360/108991/index.html

 

Public Function GetCode(CodeBase, Url) '第一个参数是设置编码方式(GB2312或UTF-8)第二个参数是地址.
    Dim xmlHTTP1
    
Set xmlHTTP1 = CreateObject("Microsoft.XMLHTTP")
    xmlHTTP1.Open 
"get", Url, True
    xmlHTTP1.send
    
While xmlHTTP1.ReadyState <> 4
        DoEvents
    
Wend
    GetCode 
= xmlHTTP1.ResponseBody
    
If CStr(GetCode) <> "" Then GetCode = BytesToBstr(GetCode, CodeBase)
    
Set ObjXML = Nothing
End Function
   
Public Function BytesToBstr(strBody, CodeBase)
    
Dim ObjStream
    
Set ObjStream = CreateObject("Adodb.Stream")
    
With ObjStream
        .Type 
= 1
        .Mode 
= 3
        .Open
        .write strBody
        .Position 
= 0
        .Type 
= 2
        .Charset 
= CodeBase
        BytesToBstr 
= .ReadText
        .Close
    
End With
    
Set ObjStream = Nothing
End Function
responeText 为响应信息作为字符串返回
responseXML 将响应信息格式化为XMLDOM对象并返回
responseBody 将响应信息以unsigned byte数组的形式返回
responseStream 将响应信息以IStream对象的形式返回
 Object.CopyTo(destStream,[CharNumber])

   说明:将对像的数据复制,destStream指向要复制的对像,CharNumber为可选参数,指要复制的字节数,不选为全部复制。

AdoStream 使用说明:http://www.lihuasoft.net/article/show.php?id=5

posted on 2008-12-28 21:29  lgzh  阅读(259)  评论(0编辑  收藏  举报

导航