導航:首頁 > 文件教程 > 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教程相關的資料

熱點內容
核桃編程如何退錢 瀏覽:17
如何查看預約app 瀏覽:774
數控哪個編程軟體速度最快 瀏覽:135
qq表情白眼是哪個 瀏覽:965
shell循環文件名 瀏覽:602
照片3d建模源代碼 瀏覽:434
西安iPhone6升級內存 瀏覽:84
小學生的編程的課是學什麼的 瀏覽:114
就業下載什麼app 瀏覽:191
個人配置文件重定向到D盤 瀏覽:22
js屏幕寬度 瀏覽:312
sql查找某列重復資料庫 瀏覽:48
智行火車票用微信支付 瀏覽:262
網路定價過程哪些內容發生變化 瀏覽:200
dubbo服務提供者的配置文件 瀏覽:182
win8系統如何壓縮文件 瀏覽:875
網站怎麼上傳代碼 瀏覽:4
java日誌的好處 瀏覽:103
武漢奇米網路怎麼樣 瀏覽:689
筆記本如何恢復原來數據 瀏覽:76

友情鏈接