Helping ordinary people create extraordinary websites!
Scripts Directory ASP Scripts Counters

Simple Text Display Web Page Counter

This simple page counter uses the File System Object to store the page count in a text file located on the server.



You must have the use of the File System Object and enable the server to read and write to the text file.



<%

'Simple asp page counter by Barry Wright

'Using the File System Object

'Create the FSO

Set bwoFSO = Server.CreateObject("Scripting.FileSystemObject")




'Location of text file to store page count.

Set bwoFile = bwoFSO.OpenTextFile("C:\wwwroot\count.txt")




'now we read the number in the file

oldNum = CLng(bwoFile.ReadLine)




'and we close

bwoFile.Close




'we add one to the number

newNum = oldNum + 1




'we open the file to overwrite the new number to it

Set bwoFile = bwoFSO.OpenTextFile("C:\wwwroot\count.txt",2,true)




'and we overwrite it here

bwoFile.WriteLine(newNum)




'and we close the file again

bwoFile.Close




'now we use the number for our display

strCount = newNum

%>




Place following code where you want your counter to appear.

<%

'Write the pagecount

Response.Write(strCount)

%>



Author: Barry Wright   Version: V1.01 Scripts
Price: Free   Demo: n/a
Platform(s): ASP   Download Script: Click here
 45 Votes

More ASP Counters Scripts: