programmingsite : code , tutorials and scripts
Navigation

home


ASP
ASP.net
C
C++
C#
PHP
Java
JavaScript
Powershell
VB.net

Visual Basic


Resources
code
tutorials
training

Ads
Products

 

 

More accurate text counter




More accurate text counter

This is a more accurate counter than our previous example , in this example the count only gets incremented once per session . This means your count will be more accurate if you want it to be that is.

Create a txt file and put your starting number in it . Then copy the code snippet below where you want the counter to display on your page.

In the example below the counter.txt is placed in the same directory as this page , if you put the txt file elsewhere remember and alter the Server.MapPath part of the code.

Visitor number
<%
'create a FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'this is the path to our counter file
CounterFile = Server.MapPath("counter.txt")
Set objCount = objFSO.OpenTextFile(CounterFile)
visitorcount = CLng(objCount.ReadLine)
if Session("visitorcount") = "" then
Session("visitorcount") = visitorcount
visitorcount = visitorcount + 1
objCount.close
Set objCount = objFSO.CreateTextFile("counter.txt", True)
objCount.WriteLine(visitorcount)
end if
objCount.Close
'display count
Response.Write visitorcount
%>







Products
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals
Asp Studio 2005
Xtra PHP
Online PHP Script Encoder
Comparison

Links
Make money selling software
Uk shopping
UK price comparison
US price comparison
free articles
free stuff
Gambling resources
Software directory
XBox cheats and more
Sexy free wallpapers
Hosting resources
Nintendo Wii info
Beginners PHP
Health and fitness
Domain names
Dating site
Nintendo DS resources
Dropshippers
Maxi directory
Perfume and fragrances
PC shopping, tips and info
Magazine superstore

Ads