
Create a hit counter
Creating a hit counter is as easy as 1-2-3!
Step 1
You will need to know the page number of the page where the counter is to be displayed. For example, to put a counter on THIS page, your page number would be 1485.asp.
Step 2
Paste the following CODE into your document where you want the page counter to appear. Remember, you must paste it in CODE VIEW, not editing view.
The Code-- paste everything between the two lines
--------------------------------------------------------------
<P align=center><EM>You are visitor number <%
Dim fsoObject
Dim tsObject
Dim filObject
Dim lngVisitorNumber
Dim intWriteDigitLoopCount
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")
Set filObject = fsoObject.GetFile(Server.MapPath("hitcounters/count000.txt"))
Set tsObject = filObject.OpenAsTextStream
lngVisitorNumber = CLng(tsObject.ReadAll)
lngVisitorNumber = lngVisitorNumber + 1
Set tsObject = fsoObject.CreateTextFile(Server.MapPath("hitcounters/count000.txt"))
tsObject.Write CStr(lngVisitorNumber)
Set fsoObject = Nothing
Set tsObject = Nothing
Set filObject = Nothing
Response.Write(lngVisitorNumber)
%> since Month 00, 2000</EM></P>
--------------------------------------------------------------
Step 3
Edit the code to reflect YOUR counter file name. You will need to make THREE changes.
Change the MapPath to your counter number-- this will be the same as your page number. For example:
change: (Server.MapPath("hitcounters/count000.txt"))
To: (Server.MapPath("hitcounters/count1485.txt")) [for this page]
-- Do this in TWO places --
Next, change the 'since' date to the current month, day and year
since Month 00, 2000 becomes since December 06, 2006
------------------ Finished Result --------------------------------
You are visitor number 1831 since December 06, 2006
|