We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Download File/Show INET Speed

thaburner asked
Medium Priority
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
Watch Question

Software Tead Lead / Business Analyst / System Analyst / Data Engineer
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.