Site designed by Barry Wright
Mirror Ten Ltd
Simple Image Page Counter
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 Image ASP Counter using the FSO
The ASP Code

This simple image page counter uses the File System Object to store the page count in a text file located on the server. The text file is then read by another function script and the corresponding image files are shown on the page.

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

'function for image collecton
Function GetImage(strCount)
For numberID = 1 to Len(strCount)
'write the image code, location is bw0.gif - bw9.gif in root folder
Response.Write "<img src=""bw" & Mid(strCount,numberID,1) & ".gif"" width=""18"" height=""23"" border=""0"" alt=""" & Mid(strCount,numberID,1) & """>"
Next
End Function
%>

The Page Code

Place following code where you want your counter to appear.

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

Extra Downloads

You can download a zip file of all the images here.

TradIndex
Share Dealing :)
Jacpotjoy