|
-
Jan 25th, 2000, 03:26 AM
#1
Thread Starter
New Member
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
-
Jan 25th, 2000, 04:26 AM
#2
Lively Member
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
-
Jan 25th, 2000, 04:31 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|