的同时也激活了Inet1_StateChang ed事件,进程可以根据捕获到的状态进行动作。
object_StateChanged(ByVal State As Integer)
State:整数类型Integer
下面是状态的说明。
常数值 描述icNone
0 未报告状态icHostResolvingHost
1 控件正在寻找指定主机的IP地址icHostResolved
2 控件已成功找到指定主机的IP地址icConnecting
3 控件正在与指定主机进行连接icConnected
4 控件已成功与指定主机连接icRequesting
5 控件正在向主机发出请求icRequestSent
6 控件已成功向主机发出请求icReceivingResponse
7 控件正在从主机接收反馈信息icResponseReceived
8 控件已成功从主机接受反馈信息icDisconnecting
9 控件正在与主机断开icDisconnected
10 控件已与主机断开icError
11 在与主机通信的过程中发生了错误icResponseComp leted
12 请求结束且数据已经接收到
下面是一个例子。
Private Sub Inet1_StateChanged(ByVal State As Integer)
'' Retrieve server response using the GetChunk
'' method when State = 12. This example assumes the
'' data is text.
Select Case State
'' Other cases not shown.
Case icResponseReceived '' 12
Dim vtData As Variant '' Data variable.
Dim strData As String: strData = ""
Dim bDone As Boolean: bDone = False
'' Get first chunk.
vtData = Inet1.GetChunk(1024, icString)
Do While Not bDone
strData = Data & vtData
'' Get next chunk.
vtData = Inet1.GetChunk(1024, icString)
If Len(vtData) = 0 Then
bDone = True
End If
Loop
txtData.Text = strData
End Select
End Sub