Article ID: 174832
Article Last Modified on 11/5/2003
APPLIES TO
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
This article was previously published under Q174832
SUMMARY
Running the GetChunk example code from the Visual Basic 5.0 Help file generates a run-time error:
Instead of intercepting icResponseReceived notification in the StateChanged event as shown in the Help file for Internet Transfer Control GetChunk method, the correct code should intercept icResponseCompleted notification.
MORE INFORMATION
The following example shows the correct way to use Transfer Control GetChunk method.
Step-by-Step Example
- Start Visual Basic 5.0. If you are already running Visual Basic, choose New Project on the File menu. Create a Standard EXE project. Form1 is created by default.
- Add a CommandButton, Command1, to Form1.
- Add an Internet Transfer Control, Inet1, to Form1.
Add the following code to the Code window:
Private Sub Command1_Click() Inet1.Execute "http://www.microsoft.com", "GET" 'download the start page of microsoft.com End Sub 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 icResponseCompleted ' 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 = strData & vtData ' Get next chunk. vtData = Inet1.GetChunk(1024, icString) If Len(vtData) = 0 Then bDone = True End If Loop MsgBox strData End Select End Sub
Additional query words: msinet.ocx
Keywords: kberrmsg kbdocerr KB174832