How do I calculate how long it takes to download a file? _ Programming 10000 Q

Source: Internet
Author: User

<%
Function downloadtime (intfilesize, Strmodemtype)
Dim timeinseconds, Modemspeed, Strdownloadtime, appendstring
Dim Intyears, Intweeks, intdays
Dim inthours, Intminutes, Intseconds
Intyears = 0
Intweeks = 0
Intdays = 0
inthours = 0
Intminutes = 0
Intseconds = 0
Strdownloadtime = ""
Select Case Strmodemtype
Case "Cable"
Modemspeed = 400000
Case "56kbps"
Modemspeed = 7000
Case "33.6kbps"
Modemspeed = 4200
Case "28.8kbps"
Modemspeed = 3600
End Select
timeinseconds = Int (intfilesize/modemspeed)
'To be exact., 1years =365.25Days.
If (int (timeinseconds/31471200) <> 0) Then intyears = Int (timeinseconds/31449600)
If (Int (timeinseconds/604800) mod <> 0) Then intweeks = Int (timeinseconds/604800) MoD 52
If (Int (timeinseconds/86400) mod 7) <> 0) Then intdays = Int (timeinseconds/86400) MoD 7
If timeinseconds >= 3600 Then inthours = Int (timeinseconds/3600) Mod 24
If timeinseconds >= Then intminutes = Int (TIMEINSECONDS/60) Mod 60
If timeinseconds >= 0 Then intseconds = Int (timeinseconds) Mod 60
If intyears <> 0 Then
Strdownloadtime = strdownloadtime & Intyears & "Years"& AppendString &", "
End If
If intweeks <> 0 Then
Strdownloadtime = strdownloadtime & Intweeks & "Week"& AppendString &", "
End If
If intdays <> 0 Then
Strdownloadtime = strdownloadtime & Intdays & "Day"& AppendString &", "
End If
If inthours <> 0 Then
Strdownloadtime = strdownloadtime & inthours & "Hours"& AppendString &", "
End If
If intminutes <> 0 Then
Strdownloadtime = strdownloadtime & Intminutes & "Part"& AppendString
End If
If ((intyears = 0) and (intweeks = 0) and (intdays = 0) and (inthours = 0)) Then
If intminutes > 0 Then
Strdownloadtime = Strdownloadtime & "," & Intseconds & " sec " & appendstring
Else
Strdownloadtime = strdownloadtime & intseconds & " sec " & appendstring
End If
End If
Downloadtime = Strdownloadtime
End Function
%>
<body>
Shake snow Gush Cloud hint : you download this document to spend altogether <%=downloadtime (123456,cable)%>.
</body>

[1]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.