Results 1 to 3 of 3

Thread: Determining Time Left In Donwload Process

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Posts
    14

    Post

    Ok ive been stumped on this for a while. Plus im not math wizard but I have made a program that will update all of my programs via the internet and I have the percent the two totals(amount downloaded, amount left) and I have the Kbps. I have all that info done but I cant figure out how to show the estimated amount of time left. If someone can help me I would greatly appreciate it!!
    Thanx

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    North Yorkshire
    Posts
    102

    Post

    Hi,
    The important thing here is that if you don't know the file size, there is no way that you can know how long it's going to take to download.
    So in pseudo code;

    ---START---

    dim StartTime
    dim CurrentTime
    dim EndTime
    dim FileSize
    dim AmountDownloaded

    StartTime = now()
    filesize = filelen(Myfile)

    'then at intervals which you choose, maybe every 1K or 10 seconds (whatever you want)

    Amountdownloaded = however much you've downloaded

    CurrentTime = now()

    'Therefore

    Duration = currenttime - starttime

    'You know the amount you've downloaded, so you know that the amount you've got left to download is;

    FileSize - AmountDownloaded

    'You know that to download the amount you've got so far took "Duration" therefore the download rate it;

    DownloadRate = Amountdownloaded / Duration

    'So to download the remaining amount (assuming the same download rate) is going to be;

    (FileSize - Amountdownloaded) / Downloadrate

    Eg;

    StartTime = 10 (seconds)
    FileSize is 500bytes

    After 15 seconds of downloading, we've downloaded 125bytes so

    Duration = 15 (25-10)
    Amountdownloaded = 90
    Amount remainging to download = 375

    Download rate = 90/15 = 6 bytes per second

    So as we know we've got 500-90 bytes left to go;

    (500-90) / 6 = 410/6 = 68.333 seconds from the Current time, so

    End Time = Currenttime + 68.333, i.e., 25 + 68.333

    = 93.333 seconds

    Total duration will be 93.333-10 = 83.333

    which is also 500 / 6


    Hope that helps

    Cheers

    Andy


  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Try something like this
    Code:
        Dim dblTotKBs As Double ' Total KBs in the file
        Dim dblKBPS As Double ' Download speed
        Dim dblKBsDownloaded As Double ' KBs downloaded
        Dim dblSecsRemaining  As Double
        
    '    dblTotKBs = 350000
    '    dblKBPS = 14000
    '    dblKBsDownloaded = 2550
        
        dblSecsRemaining = (dblTotKBs - dblKBsDownloaded) / dblKBPS
        
        MsgBox dblKBsDownloaded & " of " & dblTotKBs & " downloaded" _
            & vbCrLf & vbCrLf _
            & Format(dblSecsRemaining, 0) & " Seconds left"
    ------------------
    Marty
    Why is it called lipstick if you can still move your lips?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width