vb post 密码格式出错,求指点
Function HttpPost(Url As String, PostMsg As String) As String'自己写的发送Post的函数
'函数返回值是获得的返回信息(HTML)
'第一个参数是要发送的Url地址
'第二个参数是要发送的消息(键值对应,不必编码)
Dim XmlHttp As Object
Set XmlHttp = CreateObject("Msxml2.XMLHTTP")
If Not IsObject(XmlHttp) Then
Set XmlHttp = CreateObject("Microsoft.XMLHTTP")
If Not IsObject(XmlHttp) Then Exit Function
End If
XmlHttp.Open "POST", Url, False
XmlHttp.setRequestHeader "CONTENT-TYPE", "application/x-www-form-urlencoded"
XmlHttp.Send EnUrl(PostMsg)
Do While XmlHttp.readyState <> 4
DoEvents
Loop
'如果把下面一行(以及后面的End IF)的注释去除,即设置为仅当返回码是200时才返回页面内容
'If XmlHttp.Status = 200 Then
HttpPost = XmlHttp.responseText
'End If
End Function
Function EnUrl(Str)
EnUrl = ""
For i = 1 To Len(Str)
ThisChr = Mid(Str, i, 1)
If Abs(Asc(ThisChr)) < &HFF Then
EnUrl = EnUrl & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00) \ &HFF
Low8 = innerCode And &HFF
EnUrl = EnUrl & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
End Function
Private Sub Command1_Click()
UserNameVal = Text1.Text
UserPwdVal = Text2.Text
UserPwd2Val = Text2.Text
IdCardVal = Text3.Text
RealNameVal = Text4.Text
MsgBox HttpPost("http://www., "UserName:UserNameVal,UserPwd:UserPwdVal,UserPwd2:UserPwd2Val,IdCard:IdCardVal,RealName:RealNameVal")
End Sub
vb post 密码格式出错,求指点