StateChanged Event

Visual Basic: Internet Control

Visual Studio 6.0

StateChanged Event

See Also   Example   Applies To

Occurs whenever there is a state change in the connection.


object_StateChanged(ByVal State As Integer)

The StateChanged event syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
State Integer. Specifies the state, as shown in Settings below.


The settings for State are:

Constant Value Description
icNone 0 No state to report.
icHostResolvingHost 1 The control is looking up the IP address of the specified host computer.
icHostResolved 2 The control successfully found the IP address of the specified host computer.
icConnecting 3 The control is connecting to the host computer.
icConnected 4 The control successfully connected to the host computer.
icRequesting 5 The control is sending a request to the host computer.
icRequestSent 6 The control successfully sent the request.
icReceivingResponse 7 The control is receiving a response from the host computer.
icResponseReceived 8 The control successfully received a response from the host computer.
icDisconnecting 9 The control is disconnecting from the host computer.
icDisconnected 10 The control successfully disconnected from the host computer.
icError 11 An error occurred in communicating with the host computer.
icResponseCompleted 12 The request has completed and all data has been received.


In general, you will use the StateChanged event to determine when to retrieve data using the GetChunk method. To do this, use a Select Case statement and test for icResponseReceived (8) or icResponseCompleted (12).

Note, however, that the icResponseReceived state may occur when the control has completed an operation that hasn't resulted in any data in the buffer. For example, when connecting to an FTP site, the control will perform a "handshake" with the site that doesn't result in any data transfer, yet the icResponseReceived state will occur.

On the other hand, the icResponseCompleted state occurs after an operation has completed in its entirety. For example, if you are using the Execute method with the GET operation to retrieve a file, the icResponseCompleted event will occur only once after the file has been totally retrieved.

In practice, using the icResponseReceived state allows you to parse the data until you have retrieved only the information you need (for example, when retrieving an HTML file, retrieving only the headers). Once you have the information, you can cancel the retrieval. On the other hand, if you are intent on retrieving the whole file, the icResponseCompleted state will notify you that the transfer is completed, allowing you to proceed.

© 2016 Microsoft