<% Response.Write "
" ' If Session Variable TotalCount is empty ' then this is first time and user need to be counted ' But if Session Variable already has the value ' Then don't count this user again. Dim TotalCount If IsEmpty(Session("TotalCount")) Then TotalCount = Right("00000" & MakeCount(), 6) Else TotalCount = Right("00000" & Session("TotalCount"), 6) End If For i=1 To 6 Response.Write "" Next Response.Write "
" & Mid(TotalCount, i, 1) & "
" ' It is good practice to use Functions and Sub procedure ' Because all the variables being used in sub or function ' are automatically destroyed when Sub or Function finish process ' So you can use these Variables again in other functions Function MakeCount() Dim FSO ' FileSystemObject Dim TS ' TextStreamObject Dim MyCountFile ' Count File Name Dim HitCount ' Counting Variables ' Specify the Text file to store count value ' File will be Created if it does not exist MyCountFile = Server.MapPath(".") & "/Counter.txt" Set FSO = Server.CreateObject("Scripting.FileSystemObject") Set TS = FSO.OpenTextFile(MyCountFile, 1, True) IF Not TS.AtEndOfStream Then HitCount = TS.ReadAll Else HitCount = 1145 End If TS.Close ' Store the value of new count in Session Variable ' So you can use it on different pages HitCount = HitCount + 1 Session("TotalCount") = HitCount ' Write NewCount Value back to text file Set TS = FSO.CreateTextFile(MyCountFile, True) TS.Write HitCount TS.Close Set FSO = Nothing Set TS = Nothing MakeCount = HitCount End Function %>