Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse the Internet Transfer Control's Execute method and GetChunk to download a file
KeywordsInet, Internet Transfer Control, GetChunk, download
CategoriesControls, Files and Directories, Utilities
 
Begin the download by calling the Internet Transfer Control's Execute method with the GET command.
 
Private Sub cmdGet_Click()
    Inet1.Execute txtFile.Text, "GET"
End Sub
 
In the control's StateChanged event handler, look for the icResponseCompleted state. Use GetChunk to retrieve the returned data.
 
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim var_data As Variant
Dim str_data As String

    If State = icResponseCompleted Then
        ' Get the first chunk.
        var_data = Inet1.GetChunk(1024, icString)
        str_data = str_data & var_data

        ' Get the rest of the chunks.
        Do
            DoEvents
            var_data = Inet1.GetChunk(1024, icString)
            If Len(var_data) = 0 Then Exit Do
            str_data = str_data & var_data
        Loop

        txtResults.Text = str_data
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated