Download File/Show INET Speed

Posted on 2006-04-03
Last Modified: 2008-02-01
This is the code i use to download a file off webserver how can i get it to tell me the downoad Speed?

Private Sub inet1_StateChanged(ByVal State As Integer)
'On Error Resume Next
    Dim vtData()  As Byte ' As Variant
    Dim FreeNr    As Integer
    Dim SizeDone  As Long
    Dim bDone     As Boolean
    Dim GetPerc   As Integer
    Dim dSizeDone As Double
    Dim dFileSize As Double
    Select Case State ' ... Other cases not shown.
        Case icError: ' 11
            If Inet1.ResponseCode = 12007 Then
                NoInternetConnection Inet1.ResponseCode, Inet1.ResponseInfo
            End If
        Case icResponseCompleted: ' 12
            If m_GettingFileSize = True Then
                Exit Sub
            End If
            'hier zijn we afbeeldingen aan het downloaden
            If m_DownloadingFile = True Then
                FreeNr = FreeFile
                Open m_LocalSaveFile For Binary Access Write As FreeNr
                Do While Not bDone
                    vtData = Inet1.GetChunk(1024, icByteArray) ' Get next chunk.
                    SizeDone = SizeDone + UBound(vtData)
                    GetPerc = (SizeDone / m_DownloadingFileSize) * 100
                    If GetPerc > 100 Then GetPerc = 100
                    If GetPerc < 0 Then GetPerc = 0
                    dFileSize = m_DownloadingFileSize
                    dSizeDone = SizeDone
                    prgPercentDone.Value = GetPerc
                    Me.Caption = "(%" & GetPerc & ") Downloading Updates"
                    lblProgress.Caption = "Progress: %" & GetPerc
                    Put #FreeNr, , vtData()          
                    If UBound(vtData) = -1 Then
                        bDone = True
                    End If
                Close FreeNr        
                    'MsgBox "File downloaded"
                    cmdStart.Caption = "&Start"
                    prgPercentDone.Value = 0    
            End If
    End Select
End Sub
Question by:thaburner
    1 Comment
    LVL 48

    Accepted Solution

    Not too sure but you may need DoFileDownload API? like:

    Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
    Private Sub Form_Load()
        'KPD-Team 2000
       DoFileDownload StrConv("", vbUnicode)
    End Sub

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now