Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Download File/Show INET Speed

Posted on 2006-04-03
1
Medium Priority
?
291 Views
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
                    lblProgress.Refresh
                    DoEvents
                    Put #FreeNr, , vtData()          
                    If UBound(vtData) = -1 Then
                        bDone = True
                    Else
                        DoEvents      
                    End If
                Loop
               
                Close FreeNr        
               
                    'MsgBox "File downloaded"
                    cmdStart.Caption = "&Start"
                    'CheckFiles
                    prgPercentDone.Value = 0    
            End If
    End Select
End Sub
0
Comment
Question by:thaburner
1 Comment
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 1000 total points
ID: 16367581
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
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 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