请教vb使用inet控件post数据的方法

来源:百度知道 编辑:UC知道 时间:2024/05/21 00:16:09
做了个简单的测试程序
目的是用inet的execute方法把text1.text用post方式发送到指定的url去
再由那个url返回web输出内容
然后把这个输出的内容输出到label1.caption上
代码如下::
Private Sub Command1_Click()
Dim myurl As String, send_data As String, myhead As String
myurl = "http://ceshi.hzoko.com/php/inet/post.php"
send_data = "txt=" + Trim(Text1.Text)
my_head = "Content-Type: application/x-www-form-urlencoded"
Inet1.Execute myurl, "POST", send_data, myhead
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim get_data As String
Do Until Inet1.StillExecuting = False
Loop
If State = 12 Then
get_data = Inet1.GetChunk(1024)
Label1.Caption = get_data
End If
End Sub

错误提示
实时错误:-2147417848(80010108)
对象'execute'的方法'iinet'失败

按调试键

Inet1.Execute myurl, &q

我调试了一下,作了如下更改:
测试没有问题
返回“您的输入为:text1"

Private Sub Command1_Click()

Dim myurl As String, send_data As String, my_head As String

myurl = "http://ceshi.hzoko.com/php/inet/post.php"

send_data = "txt=" + Trim(Text1.Text)

my_head = "Content-Type: application/x-www-form-urlencoded"

Inet1.Execute myurl, "POST", send_data, my_head

End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)

Dim get_data As String

' Do Until Inet1.StillExecuting = False
'
' Loop

If State = 12 Then
get_data = Inet1.GetChunk(1024)
Label1.Caption = get_data
End If
End Sub

inet控件很麻烦的啊,用MSXML的xmlhttp多好