导航:首页 > 文件教程 > vbpost教程

vbpost教程

发布时间:2023-06-11 23:59:56

1. vb6如何post json数据

PublicFunctionAjax_Post(ByValStrUrlAsString,OptionalByValStrDataAsString,OptionalByValIndexAsLong)AsVariant
OnErrorGoToMyError:
DimObjectAsObject,SAsString,B()AsByte
SetObject=CreateObject("Microsoft.XMLHTTP")
Object.Open"POST",StrUrl,True
Object.setRequestHeader"Content-Length",Len(Ajax_Post)
Object.setRequestHeader"Content-Type","application/x-www-form-urlencoded"
Object.send(StrData)
DoUntilObject.readyState=4
DoEvents
Loop
SelectCaseIndex
Case1:S=Object.responseText:Ajax_Post=S'返回字符串
Case2:B=Object.responseBody:Ajax_Post=B'返回二进制
Case3:S=BytesToStr(Object.responseBody):Ajax_Post=S'二进制转字符串[直接返回字串出现乱码时尝试]
CaseElse:Ajax_Post=vbNullString'无效的返回
EndSelect
SetObject=Nothing'释放空间
ExitFunction
MyError:
Ajax_Post=vbNullString'出错返回空
EndFunction
FunctionBytesToStr(ByValvIn)AsString
DimstrReturnAsString,ThisCharCodeAsString,NextCharCodeAsString,IAsLong
ForI=1ToLenB(vIn)
ThisCharCode=AscB(MidB(vIn,I,1))
IfThisCharCode<&H80Then
strReturn=strReturn&Chr(ThisCharCode)
Else
NextCharCode=AscB(MidB(vIn,I+1,1))
strReturn=strReturn&Chr(CLng(ThisCharCode)*&H100+CInt(NextCharCode))
I=I+1
EndIf
Next
BytesToStr=strReturn
EndFunction
PrivateSubCommand1_Click()
DimUrlAsString,KeyAsVariant,JsonKeyAsString
Url="https://www..com/"
Key=Array("wd=123","aa=456","bb=789","cc=901")
JsonKey=Join(Key,"&")
MsgBoxAjax_Post(Url,JsonKey,1)
EndSub

2. 如何用vb.net上传post数据给服务器

图有点模糊。
服务器端要有方法接收,接收的参数要看方法的定义。
Controller A里面假设有这个get Action
<httppost>
function get(frm as formcollection) as actionresult
dim a as string=frm("keyword")
return content(a)

end function

页面View 中
@Using FormBegin("get","A","POST")
@<div>
<input name="keyword" type="text"/>
<Input type="submit" value="提交"/>
end using

你在页面上点击按钮“提交”后,就会把表单的中keyword文本框的内容赋值给a.
这里我用的是MVC..前端用的VB Razor.

3. VB如何实现发送POST请求

参考一下吧

Private Function ShowIe(ByVal url As String, ByVal user As String, ByVal sn As String)
On Error GoTo ex
'edtPostData.Text = "" ' Initialize an edit box for testing
ReDim aByte(0) As Byte ' Array of bytes to hold data to post
' Extract the URL encoded data from the UI,
' and pack it into an array of bytes
' cFlavor = cboFlavor.List(cboFlavor.ListIndex)
cParamName = "user="
cParamFlavor = "SN="
cSeparator = "&"
cPostData = cParamName & user _
& cSeparator & cParamFlavor & sn
PackBytes aByte(), cPostData
' For testing, rebuild the POST data and stuff
' it into an edit box
For i = LBound(aByte) To UBound(aByte)
edtPostData = edtPostData + Chr(aByte(i))
Next
Dim vPost As Variant
vPost = aByte ' Assign the byte array to a VARIANT
Dim vFlags As Variant
Dim vTarget As Variant
Dim vHeaders As Variant
vHeaders = _
"Content-Type: application/x-www-form-urlencoded" _
+ Chr(10) + Chr(13)
Dim objExplorer As Object
Set objExplorer = CreateObject("InternetExplorer.Application")

objExplorer.Navigate url, _
vFlags, vTarget, vPost, vHeaders objExplorer.Visible = True
Exit Function
ex:
End Function

4. 【VB】vb如何post提交

vb的inet、webbrowser、winsock控件都可以post
你可以在网络中搜索相应控件的post
一般要先用抓包工具得到post数据,再在程序中按样post

阅读全文

与vbpost教程相关的资料

热点内容
ps3文件分割视频 浏览:280
微信图片一键转发软件 浏览:331
如何判断s200plc编程电缆 浏览:691
太原编程培训班哪个好 浏览:171
树叶吹奏教程 浏览:6
社交app带来了哪些社会问题 浏览:394
如何安装爱宝8800数据采集器 浏览:712
文件保存了怎么找不到了 浏览:476
彩票网站怎么辨真假 浏览:840
pr找不到该文件 浏览:963
java移除panel 浏览:354
jsp填充jsp 浏览:166
海关外贸大数据在哪里查 浏览:381
思特奇java笔试题 浏览:121
葫芦侠在手机中的文件名 浏览:813
plc编程应该怎么收钱 浏览:584
c语言中源文件由什么组成 浏览:890
linuxhttpdphp配置文件 浏览:607
拆单数据要怎么保存 浏览:17
mac电脑怎样压缩文件到100m 浏览:645

友情链接