<% Function WebCounter() Dim CounterName, objFS, HitRate, imgName Dim objReadTS, objWriteTS 'On Error Resume Next CounterName = Server.MapPath("Count.cnt") Set objFS = CreateObject("Scripting.FileSystemObject") Set objReadTS = objFS.OpenTextFile(CounterName, 1, -1, 0) HitRate = objReadTS.ReadLine objReadTS.Close '如果該名網友尚未登錄這份網頁,或者已超出預設時間(20分鐘) 'If Not Session("On_line") Then HitRate = CLng(HitRate) + 1 '計數值加一 'Application.Lock '每有一人連線,CurrentUsers便加一 'Application("CurrentUsers") = Application("CurrentUsers") + 1 'Application.UnLock Session("On_line") = True '標記為已登錄狀態 On_line = "True" Set objWriteTS = objFS.CreateTextFile(CounterName, -1, 0) objWriteTS.WriteLine HitRate objWriteTS.Close 'Session("Hit") = HitRate '存放當時的計數值 'Hit = HitRate ' Else ' HitRate = Session("Hit") '還原當時的計數值 'End If WebCounter = HitRate ' For i=1 to CInt(Len(HitRate)) ' imgName = Mid(HitRate, i, 1) ' Response.Write("") ' Next End Function tot = WebCounter tmpInt = len(tot) Select Case tmpInt Case 1 totstr = "00000"& tot Case 2 totstr = "0000"& tot Case 3 totstr = "000"& tot Case 4 totstr = "00"& tot Case 5 totstr = "0"& tot Case 6 totstr = tot Case else totstr = tot End Select tmpInt = len(totstr) 'For i=1 to tmpInt ' pic=mid(totstr,i,1) ' tmpStr = tmpStr & ""& pic &"" 'Next tmpStr = ""& totstr &"" %> document.write("<%=tmpStr %>")