凹丫丫网络社区's Archiver

乖乖狗 发表于 2008-6-22 17:30

计算文件的下载时间

<STRONG><FONT color=red>&lt;%<BR>Function DownloadTime(intFileSize, strModemType)<BR>Dim TimeInSeconds, ModemSpeed, strDownloadTime, AppendString<BR>Dim intYears, intWeeks, intDays<BR>Dim intHours, intMinutes, intSeconds<BR>intYears = 0<BR>intWeeks = 0<BR>intDays = 0<BR>intHours = 0<BR>intMinutes = 0<BR>intSeconds = 0<BR>strDownloadTime = ""<BR>Select Case strModemType<BR>Case "Cable"<BR>ModemSpeed = 400000<BR>Case "56kbps"<BR>ModemSpeed = 7000<BR>Case "33.6kbps"<BR>ModemSpeed = 4200<BR>Case "28.8kbps"<BR>ModemSpeed = 3600<BR>End Select<BR>TimeInSeconds = int(intFileSize / ModemSpeed)<BR>'year maths added 1/4 of a day. 1 exact orbit of the sub is 365.25 days.<BR>If (Int(TimeInSeconds / 31471200) &lt;&gt; 0) Then intYears = Int(TimeInSeconds / 31449600)<BR>If ((Int(TimeInSeconds / 604800) Mod 52) &lt;&gt; 0) Then intWeeks = Int(TimeInSeconds / 604800) Mod 52<BR>If ((Int(TimeInSeconds / 86400) Mod 7) &lt;&gt; 0) Then intDays = Int(TimeInSeconds / 86400) Mod 7<BR>If TimeInSeconds &gt;= 3600 Then intHours = Int(TimeInSeconds / 3600) Mod 24<BR>If TimeInSeconds &gt;= 60 Then intMinutes = Int(TimeInSeconds / 60) Mod 60<BR>If TimeInSeconds &gt;= 0 Then intSeconds = Int(TimeInSeconds) Mod 60<BR>If intYears &lt;&gt; 0 Then<BR>If intYears = 1 Then AppendString = "" Else AppendString = "s"<BR>strDownloadTime = strDownloadTime &amp; intYears &amp; " year" &amp; AppendString &amp; ", "<BR>End If<BR>If intWeeks &lt;&gt; 0 Then<BR>If intWeeks = 1 Then AppendString = "" Else AppendString = "s"<BR>strDownloadTime = strDownloadTime &amp; intWeeks &amp; " week" &amp; AppendString &amp; ", "<BR>End If<BR>If intDays &lt;&gt; 0 Then<BR>If intDays = 1 Then AppendString = "" Else AppendString = "s"<BR>strDownloadTime = strDownloadTime &amp; intDays &amp; " day" &amp; AppendString &amp; ", "<BR>End If<BR>If intHours &lt;&gt; 0 Then<BR>If intHours = 1 Then AppendString = "" Else AppendString = "s"<BR>strDownloadTime = strDownloadTime &amp; intHours &amp; " hour" &amp; AppendString &amp; ", "<BR>End If<BR>If intMinutes &lt;&gt; 0 Then<BR>If intMinutes = 1 Then AppendString = "" Else AppendString = "s"<BR>strDownloadTime = strDownloadTime &amp; intMinutes &amp; " minute" &amp; AppendString<BR>End If<BR>If ((intYears = 0) And (intWeeks = 0) And (intDays = 0) And (intHours = 0)) Then<BR>If intSeconds = 1 Then AppendString = "" Else AppendString = "s"<BR>If intMinutes &gt; 0 Then<BR>strDownloadTime = strDownloadTime &amp; ", " &amp; intSeconds &amp; " second" &amp; AppendString<BR>Else<BR>strDownloadTime = strDownloadTime &amp; intSeconds &amp; " second" &amp; AppendString<BR>End If<BR>End If<BR>DownloadTime = strDownloadTime<BR>End Function<BR>%&gt;<BR>&lt;html&gt;<BR>&lt;body&gt;<BR>It is going to take about<BR>&lt;%=DownloadTime(1*1024*1024,"56kbps")%&gt; to download this file.<BR>&lt;/body&gt;<BR>&lt;/html&gt; </FONT></STRONG>

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.