• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

Download File/Show INET Speed

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
1 Solution
Ryan ChongCommented:
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
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
   DoFileDownload StrConv("http://www.allapi.net/", vbUnicode)
End Sub
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now