窗体 上有command1,text1,在text1中输入 一个QQ号,点command1的时候,msgbox 出这个QQ号的昵称,在线等 !!!

解决方案 »

  1.   

    首先建立一个模块:
    Function GetPage(Url, LG)
    On Error GoTo Exittag:
    Dim Retrieval As Object
    Set Retrieval = CreateObject("Microsoft.XMLHTTP")
    With Retrieval
    .Open "GET", Url, False, "", ""
    .Send
    GetPage = BytesToBstr(.responseBody, LG)
    End With
    Set Retrieval = Nothing
    Exit Function
    Exittag:
    'MsgBox "对不起,查询超时,请确保您的网络或目标主机网络是否正常!"
    Err.Clear
    End Function
    Public Function BytesToBstr(body, Cset)
      Dim objstream
      Set objstream = CreateObject("adodb.stream")
      objstream.Type = 1
      objstream.Mode = 3
      objstream.Open
      objstream.Write body
      objstream.Position = 0
      objstream.Type = 2
      objstream.Charset = Cset
      BytesToBstr = objstream.ReadText
      objstream.Close
      Set objstream = Nothing
      End Function
    Function GetKey(HTML, Start, Last)
    Dim Filearray, Filearray2
    On Error Resume Next
    Filearray = Split(HTML, Start)
    Filearray2 = Split(Filearray(1), Last)
    GetKey = Filearray2(0)
    End Function
    窗口代码:
    Private Sub Command1_Click()
    MsgBox GetKey(GetPage("http://user.qbar.qq.com/" & text1.text & "/", "GB2312"),"<h3><strong>","<span>")
    End Sub
      

  2.   

    <h3><strong>之间没有空格呀
      

  3.   

    <span>前面也没有空格,发表时系统自动加上去的