如何计算下载一个文件需要多长时间?

%Function DownloadTime(intFileSize, strModemType)Dim TimeInSeconds,
ModemSpeed, strDownloadTime, AppendStringDim intYears, intWeeks,
intDaysDim intHours, intMinutes, intSecondsintYears = 0intWeeks =
0intDays = 0intHours = 0intMinutes = 0intSeconds = 0strDownloadTime =
“”Select Case strModemTypeCase “Cable” ModemSpeed = 400000Case “56kbps”
ModemSpeed = 7000Case “33.6kbps” ModemSpeed = 4200Case “28.8kbps”
ModemSpeed = 3600End SelectTimeInSeconds = int(intFileSize /
ModemSpeed)’ 准确地说,1年=365.25天.If (Int(TimeInSeconds / 31471200) 0)
Then intYears = Int(TimeInSeconds / 31449600)If ((Int(TimeInSeconds /
604800) Mod 52) 0) Then intWeeks = Int(TimeInSeconds / 604800) Mod 52If
((Int(TimeInSeconds / 86400) Mod 7) 0) Then intDays = Int(TimeInSeconds
/ 86400) Mod 7If TimeInSeconds = 3600 Then intHours = Int(TimeInSeconds
/ 3600) Mod 24If TimeInSeconds = 60 Then intMinutes = Int(TimeInSeconds
/ 60) Mod 60If TimeInSeconds = 0 Then intSeconds = Int(TimeInSeconds)
Mod 60If intYears 0 Then strDownloadTime = strDownloadTime & intYears &
“年” & AppendString & “, “End IfIf intWeeks 0 Then strDownloadTime =
strDownloadTime & intWeeks & “周” & AppendString & “, “End IfIf intDays
0 Then strDownloadTime = strDownloadTime & intDays & “日” & AppendString
& “, “End IfIf intHours 0 Then strDownloadTime = strDownloadTime &
intHours & “小时” & AppendString & “, “End IfIf intMinutes 0 Then
strDownloadTime = strDownloadTime & intMinutes & “分” & AppendStringEnd
IfIf ((intYears = 0) And (intWeeks = 0) And (intDays = 0) And (intHours
= 0)) Then If intMinutes 0 Then strDownloadTime = strDownloadTime & “, ”
& intSeconds & “秒” & AppendString Else strDownloadTime =
strDownloadTime & intSeconds & “秒” & AppendString End IfEnd
IfDownloadTime = strDownloadTimeEnd
Function%htmlbody撼雪喷云提示:您下载这个文件一共花费了%=DownloadTime(123456,Cable)%./body/html

<%
Class ImgWHInfo ‘获取图片宽度和高度的类,支持JPG,GIF,PNG,BMP
    Dim ASO 
    
    Private Sub Class_Initialize 
        Set ASO=Server.CreateObject(“ADODB.Stream”) 
        ASO.Mode=3 
        ASO.Type=1 
        ASO.Open 
    End Sub 
    
    Private Sub Class_Terminate 
        Err.Clear 
        Set ASO=Nothing 
    End Sub 
   

[1]

    Private Function Bin2Str(Bin) 
        Dim I, Str 
        For I=1 To LenB(Bin) 
            clow=MidB(Bin,I,1) 
            If ASCB(clow)<128 Then 
                Str = Str & Chr(ASCB(clow)) 
            Else 
                I=I+1 
                If I <= LenB(Bin) Then Str = Str &
Chr(ASCW(MidB(Bin,I,1)&clow)) 
            End If 
        Next 
        Bin2Str = Str 
    End Function 
   

    Private Function Num2Str(Num,Base,Lens) 
        Dim Ret 
        Ret = “” 
        While(Num>=Base) 
            Ret = (Num Mod Base) & Ret 
            Num = (Num – Num Mod Base)/Base 
        Wend 
        
        Num2Str = Right(String(Lens,”0″) & Num & Ret,Lens) 
    End Function

    
    Private Function Str2Num(Str,Base) 
        Dim Ret,I 
        Ret = 0 
        For I=1 To Len(Str) 
            Ret = Ret *base + Cint(Mid(Str,I,1)) 
        Next 
        Str2Num=Ret 
    End Function 
   

    Private Function BinVal(Bin) 
        Dim Ret,I 
        Ret = 0 
        For I = LenB(Bin) To 1 Step -1 
            Ret = Ret *256 + AscB(MidB(Bin,I,1)) 
        Next 
        BinVal=Ret 
    End Function

    
    Private Function BinVal2(Bin) 
        Dim Ret,I 
        Ret = 0 
        For I = 1 To LenB(Bin) 
            Ret = Ret *256 + AscB(MidB(Bin,I,1)) 
        Next 
        BinVal2=Ret 
    End Function 
   

    Private Function GetImageSize(filespec) 
        Dim bFlag 
        Dim Ret(3) 
        ASO.LoadFromFile(filespec) 
        bFlag=ASO.Read(3) 
        Select Case Hex(binVal(bFlag)) 
        Case “4E5089”: 
        ASO.Read(15) 
        ret(0)=”PNG” 
        ret(1)=BinVal2(ASO.Read(2)) 
        ASO.Read(2) 
        ret(2)=BinVal2(ASO.Read(2)) 
        Case “464947”: 
            ASO.read(3) 
            ret(0)=”gif” 
            ret(1)=BinVal(ASO.Read(2)) 
            ret(2)=BinVal(ASO.Read(2)) 
        Case “535746”: 
            ASO.read(5) 
            binData=ASO.Read(1) 
            sConv=Num2Str(ascb(binData),2 ,8) 
            nBits=Str2Num(left(sConv,5),2) 
            sConv=mid(sConv,6) 
            While(len(sConv)<nBits*4) 
                binData=ASO.Read(1) 
                sConv=sConv&Num2Str(AscB(binData),2 ,8) 
            Wend 
            ret(0)=”SWF” 
           
ret(1)=Int(Abs(Str2Num(Mid(sConv,1*nBits+1,nBits),2)-           
Str2Num(Mid(sConv,0*nBits+1,nBits),2))/20) 
           
ret(2)=Int(Abs(Str2Num(Mid(sConv,3*nBits+1,nBits),2)-           
Str2Num(Mid(sConv,2*nBits+1,nBits),2))/20) 
        Case “FFD8FF”: 
            Do 
                Do: p1=binVal(ASO.Read(1)): Loop While p1=255 And Not
ASO.EOS 
                If p1>191 And p1<196 Then Exit Do Else
ASO.read(binval2(ASO.Read(2))-2) 
                Do:p1=binVal(ASO.Read(1)):Loop While p1<255 And Not
ASO.EOS 
            Loop While True 
            ASO.Read(3) 
            ret(0)=”JPG” 
            ret(2)=binval2(ASO.Read(2)) 
            ret(1)=binval2(ASO.Read(2)) 
        Case Else: 
            If left(Bin2Str(bFlag),2)=”BM” Then 
                ASO.Read(15) 
                ret(0)=”BMP” 
                ret(1)=binval(ASO.Read(4)) 
                ret(2)=binval(ASO.Read(4)) 
            Else 
澳门新葡亰3522平台游戏,                ret(0)=”” 
            End If 
        End Select 
        ret(3)=”width=””” & ret(1) &””” height=””” & ret(2) &”””” 
        getimagesize=ret 
    End Function