Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inet1.OpenURL response problem
Message
General information
Forum:
Visual Basic
Category:
Internet applications
Miscellaneous
Thread ID:
00340944
Message ID:
00341264
Views:
22
>This is for "small" HTTP ascii files, retrieval for local archiving of a portion of each file. I can't use any of each file until I have retrieved all of it. I would like to be able to restart the retrieval process if a link error has occurred, so I will need to know the eventual completion codes.
>
>By the way, this error occurred on a W98 platform which is also up to date on Microsoft patches.

This code should start as a base:

Dim strData() As Variant
Sub Command1_Click()
strURL = "http://www.microsoft.com/index.html"
Inet1.Execute (strURL), "GET"
End Sub


Private Sub Inet1_StateChanged(ByVal State As Integer)
' Retrieve server response using the GetChunk
' method when State = 12.

Select Case State

Case icError ' Error
cCurrentStatus = "Connection Error"

Case icConnecting
cCurrentStatus = "Connecting.."

Case icResponseReceived ' 8
cCurrentStatus = "Retrieving " & Trim(cSaveAsFile)

Case icResponseCompleted ' 12
nChunkSize = 128
nCurChunk = 1
' Get first chunk.
ReDim Preserve strData(nCurChunk) As Variant
strData(nCurChunk) = Inet1.GetChunk(nChunkSize, icByteArray)

Do While Not bDone
' Get next chunk.
nCurChunk = nCurChunk + 1
ReDim Preserve strData(nCurChunk)
strData(nCurChunk) = Inet1.GetChunk(nChunkSize, icByteArray)
If Len(strData(nCurChunk)) = 0 Then
Call DownloadComplete
bDone = True
Exit Do
End If
Loop
End Select
End Sub

Sub DownloadComplete
Dim cCurByte() as Byte

Open (cSaveAsFile) For Binary Access Write As #intFile
nMax = UBound(strData)
For nCnt = 1 To nMax - 1
ReDim CurByte(UBound(strData(nCnt))) As Byte
CurByte() = strData(nCnt) ' Convert to byte array; or file contents will be corrupted
Put #intFile, , CurByte()
Next nCnt
Close #intFile

End Sub
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform