注册 登录
编程论坛 VFP论坛

求教,用VBA仿写了一段VFP代码,怎么得到返回的结果呢?

wanguhssheng 发布于 2021-12-24 07:47, 1379 次点击
病急乱投医,仿写了一段VBA代码,怎么得到返回的数据呢?
Sub zyl()
    Set http = CreateObject("MSXML2.XMLHTTP")
    URLNAME = "https://biz.
    lcRq = "2021.12.17"
    lcCode = "300415"
    response = http.Open("POST", URLNAME, False)
    response = http.SETREQUESTHEADER("Content-Type", "application/x-www-form-urlencoded")
    response = http.SEND("queryDate=" + lcRq + "&secCde=" + lcCode)
    Rem 可以运行到这里,下面出现错误
    Print (response.Status())
    Print (respons.RESPONSEBODY)
   
End Sub
本来想改写成python,怎么也不行,还是水平问题。
7 回复
#2
nbwww2021-12-24 08:09
    http = CreateObject("MSXML2.XMLHTTP")
    URLNAME = "https://biz.
    lcRq = "2021.12.17"
    lcCode = "300415"
    response = http.Open("POST", URLNAME, .F.)
    response = http.SETREQUESTHEADER("Content-Type", "application/x-www-form-urlencoded")
    response = http.SEND("queryDate=" + lcRq + "&secCde=" + lcCode)
   lcText=STRCONV(STRCONV(http.ResponseBody, 11), 2)
   ?lctext
#3
wanguhssheng2021-12-24 08:30
谢谢,主要是不知道VB写法 。
#4
吹水佬2021-12-24 09:13
Function zyl()
    .........
    zyl = respons.RESPONSEBODY
End Function
#5
wanguhssheng2021-12-24 10:14
谢谢吹老,不会处理返回值,也不知道成功没有
只有本站会员才能查看附件,请 登录
#6
吹水佬2021-12-24 10:49
Function zyl()
  http = CreateObject("MSXML2.XMLHTTP")
  URLNAME = "https://biz.
  lcRq = "2021.12.17"
  lcCode = "300415"
  http.Open("POST", URLNAME, .F.)
  http.SETREQUESTHEADER("Content-Type", "application/x-www-form-urlencoded")
  http.SEND("queryDate=" + lcRq + "&secCde=" + lcCode)
  zyl=http.ResponseText
End Function

在过程中调用返回的是网页文本,是否成功和想要的看看就清楚
str = zyl()
#7
wanguhssheng2021-12-24 10:56
感谢吹老,搜了个bytes2BSTR函数,问题可能解决了。
#8
wanguhssheng2021-12-24 11:18
感谢吹老,直接用了你的方法
只有本站会员才能查看附件,请 登录
1