Site designed by Barry Wright
Mirror Ten Ltd
Create a simple ASP Text Counter using the FSO
Free Web Page Counter
Page Counters
Simple Text Counter
Simple Image Counter
Active Visitor Counter
Recordset Counters
Records in Recordset
Form Counters
Counting Through Forms
Free Web Counter
Web Hit Counter
 
 
How to create a simple ASP Text Counter using the FSO
The ASP Code

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
%>

The Page Code

Place following code where you want your counter to appear.

<%
'Write the pagecount
Response.Write(strCount)
%>

You can surround the code with HTML formatting to change the appearance of the text counter. eg.

<font color="#FF0000"><strong><% Response.Write(strCount) %></strong></font>

Will give you a Red, Bold text counter

TradIndex
Share Dealing :)
Jacpotjoy