道招

asp计算文件下载时间函数

如果您发现本文排版有问题,可以先点击下面的链接切换至老版进行查看!!!

asp计算文件下载时间函数

我们经常看到网站上面显示文件下载时间的估算,你知道是怎么实现的吗 我们用到这样一个函数

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)
“year maths added 1/4 of a day. 1 exact orbit of the sub is 365.25 days.
If (Int(TimeInSeconds / 31471200) <> 0) Then intYears = Int(TimeInSeconds / 31449600)
If ((Int(TimeInSeconds / 604800) Mod 52) <> 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 >= 60 Then intMinutes = Int(TimeInSeconds / 60) Mod 60
If TimeInSeconds >= 0 Then intSeconds = Int(TimeInSeconds) Mod 60
If intYears <> 0 Then
If intYears = 1 Then AppendString = "" Else AppendString = "s"
strDownloadTime = strDownloadTime & intYears & " year" & AppendString & ", "
End If
If intWeeks <> 0 Then
If intWeeks = 1 Then AppendString = "" Else AppendString = "s"
strDownloadTime = strDownloadTime & intWeeks & " week" & AppendString & ", "
End If
If intDays <> 0 Then
If intDays = 1 Then AppendString = "" Else AppendString = "s"
strDownloadTime = strDownloadTime & intDays & " day" & AppendString & ", "
End If
If intHours <> 0 Then
If intHours = 1 Then AppendString = "" Else AppendString = "s"
strDownloadTime = strDownloadTime & intHours & " hour" & AppendString & ", "
End If
If intMinutes <> 0 Then
If intMinutes = 1 Then AppendString = "" Else AppendString = "s"
strDownloadTime = strDownloadTime & intMinutes & " minute" & AppendString
End If
If ((intYears = 0) And (intWeeks = 0) And (intDays = 0) And (intHours = 0)) Then
If intSeconds = 1 Then AppendString = "" Else AppendString = "s"
If intMinutes > 0 Then
strDownloadTime = strDownloadTime & ", " & intSeconds & " second" & AppendString
Else
strDownloadTime = strDownloadTime & intSeconds & " second" & AppendString
End If
End If
DownloadTime = strDownloadTime
End Function[

我们可以这样调用这个函数

<html>
<body>
It is going to take about
<%=DownloadTime(123456,Cable)%> to download this file.
</body>
</html>
更新时间:
上一篇:推荐一个在线制作透明背景favicon.ico网站下一篇:asp调用远程xml文件数据

相关文章

asp获取指定网页指定内容的函数

我们把函数名命名为GetMyContent Function GetMyContent(ConStr,StartStr,OverStr,IncluL,IncluR) If Con 阅读更多…

asp函数InStrB讲解

asp有个函数是instr,而instrb和这个函数相似 instrb判断第二个字符串是否包含在第一个字符串中,如果存在则返回第二个字符串在第一个中的位置。 instrb([开始位置],第一个字 阅读更多…

asp指定格式显示系统日期和时间FormatDateTime函数

获取当前系统日期和时间,ASP输出可以这样写:[code lang="vb"]&lt;%=now()%&gt;[/code] Year(now()) 获取年份, ASP输出:[code lang 阅读更多…

asp获取当前准确域名的代码

以下代码可以很简单的获取当前页面的准确域名 &lt;% call chaxun sub chaxun()&#039;定义函数chaxun yuming=Request.ServerVariab 阅读更多…

道招网建立ftp服务器 ftp://daozhaocom.gicp.net

本人用自己的电脑建立的ftp,动态dns结合花生壳实现的,相信通过gicp.net这个域名有经验的同志都能懂的。 ftp服务器地址: ftp://daozhaocom.gicp.net 本人设置的 阅读更多…

关注道招网公众帐号
道招开发者二群