一个简略的赋值语句引来的不解。【穷人,分少。望赐教】
一个简单的赋值语句引来的不解。【穷人,分少。望赐教】以下源码中,我定义了一个变量xmlmessage,VB.NET codeDim
一个简单的赋值语句引来的不解。【穷人,分少。望赐教】
以下源码中,我定义了一个变量xmlmessage,
VB.NET code Dim strurl As String Dim username Dim password Dim xmlmessage As String' 存储post数据值 Dim retval As String pHttp = CreateObject("Msxml2.XMLHTTP.5.0") username = "543534" password = "111111" strurl = "http://www.zxxx.com/user/User_ChkLogin.asp" pHttp.Open("POST", strurl, False) pHttp.setrequestheader("CONTENT-TYPE", "application/x-www-form-urlencoded") pHttp.setrequestheader("Referer", "http://www.zxxx.com/user/user_login.asp") xmlmessage = ("UserName=" & username & "&UserPassword=" & password & "&CookieDate=0" & "&ComeUrl=index.asp").ToStringpHttp.send(xmlmessage)
xmlmessage = ("UserName=" & username & "&UserPassword=" & password & "&CookieDate=0" & "&ComeUrl=index.asp").ToString
(奇怪的就是上面的这个普通赋值语句)下面我要把上述xmlmessage发送到服务端
用以下语句发送分显示错误
pHttp.send(xmlmessage)
把xmlmessage替换成其中的值,然后发送会成功,即以下语句。
pHttp.send("UserName=" & username & "&UserPassword=" & password & "&CookieDate=0" & "&ComeUrl=index.asp")
难道一个普通的赋值语句,会上字串的编码发生变化吗?这是为什么?大家来探讨。
[解决办法] xmlmessage ="UserName=" & username & "&UserPassword=" & password & "&CookieDate=0" & "&ComeUrl=index.asp"
[解决办法]xmlmessage = ("UserName=" & username & "&UserPassword=" & password & "&CookieDate=0" & "&ComeUrl=index.asp").ToString
为什么还要ToString呢,字符串连接本来就是字符串了
直接这样不行吗?
xmlmessage = "UserName=" & username & "&UserPassword=" & password & "&CookieDate=0" & "&ComeUrl=index.asp"