查了一下 说是要用 Internet transfer控件,看了一下不太明白,这里要求我POST这个服务器,然后服务器会反馈一个字符串给我,不知道具体怎么实施啊

解决方案 »

  1.   

    我的是用winsock发的。Function WskPost() As Boolean
    Dim i As Long
    Dim PostSu As Boolean
    PostSu = False
    i = 0
    StrCommand = "" StrCommand = "POST /noticeCreate.jsp HTTP/1.1" + vbCrLf
        StrCommand = StrCommand + "Accept: */*" + vbCrLf
        StrCommand = StrCommand + "Accept-Language: zh-cn" + vbCrLf
        StrCommand = StrCommand + "Referer: http://119.185.1.182:8888/camion.html" + vbCrLf
        StrCommand = StrCommand + "x-requested-with: XMLHttpRequest" + vbCrLf
        StrCommand = StrCommand + "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" + vbCrLf
        StrCommand = StrCommand + "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; AskTbPTV2/5.9.1.14019; 360SE)" + vbCrLf
        StrCommand = StrCommand + "Host: 119.185.1.182:8888" + vbCrLf
        StrCommand = StrCommand + "Content-Length: " & Str(Len(SendMsg)) + vbCrLf
        StrCommand = StrCommand + "Connection: Keep-Alive" + vbCrLf
        StrCommand = StrCommand + "Cache-Control: no-cache" + vbCrLf
        'strCommand = strCommand + "Accept-Language: zh-CN, zh, *" + vbCrLf
        StrCommand = StrCommand + "Accept-Encoding: gzip, deflate" + vbCrLf
        StrCommand = StrCommand + vbCrLf
         StrCommand = StrCommand + SendMsg + vbCrLf
    If wsk1.State <> sckClosed Then wsk1.Close
    wsk1.RemoteHost = Text1.Text
    wsk1.RemotePort = Text2.Text
    wsk1.Connect
    Debug.Print StrCommand
    Do Until i >= 1000 And wsk1.State = sckOpen
    'MsgBox wsk1.State
    If wsk1.State = 9 Then
    'stat "错误", ""
    PostSu = False
    Exit Do
    End If
    If wsk1.State = sckConnected Then
    wsk1.SendData StrCommand
    PostSu = True
    Exit Do
    End If
    i = i + 1
    DoEvents
    Loop
    WskPost = PostSu
    End Function
      

  2.   

    用inet控件或者xmlhttp,更简单,自己google下。