Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Visit Counter II

Thread Tools

Visit Counter II

Paul W Smith
Posts: n/a
The code below works as a page counter for me, counting how many visits my
web site has per week (Sunday - Saturday). This works fine - it write the
date and the count to a text file e.g.


When the new week arrives the old information is just overwritten, however
what I would like to do is keep the old information but starting the new
week with two new lines appended to the top of the existing information so
maintaining the historical data.


I actually can write the code that appends the two new lines when the new
week starts. However I do not have sufficient knowledge to be able to write
the ASP required to either amend the top two lines of the textstream (for
when the total should be added).

Any help or references gratefully received.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~

strCountFileName = Server.MapPath(Request.ServerVariables("SCRIPT_NAM E") &

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

Set objCountFile = objFSO.OpenTextFile(strCountFileName, 1, True)

If Not objCountFile.AtEndOfStream Then
dtDate = CDate(objCountFile.ReadLine)
iCount = CLng(objCountFile.ReadLine)
dtDate = Date
iCount = 0
End If

Set objCountFile = Nothing

If IsEmpty(Session("TotalCount")) Then

If Weekday(Date(),vbSunday) = 1 And dtDate <> Date then
iCount = 1
iCount = iCount + 1
End If
dtDate = Date

End If

Session("TotalCount")= iCount

Set objCountFile = objFSO.CreateTextFile(strCountFileName, True)

objCountFile.WriteLine dtDate

objCountFile.WriteLine iCount

Set objCountFile = Nothing

Set objFSO = Nothing

Response.Write iCount

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Page File counter and Private Bytes Counter George2 C++ 1 01-31-2008 09:27 AM
Website visit counter in JavaScript TomCat Javascript 6 05-18-2005 10:38 PM
Session("counter") vs. ViewState("counter")...a newbie question The Eeediot ASP .Net 3 12-22-2004 09:31 PM
how to binding 3 DDN form different ISP for visit Internet in one Router Benny Su Cisco 0 03-05-2004 03:27 PM
Why doesn't the COUNTER show up everytime I visit the site? Nicole Kidman Computer Support 6 08-03-2003 09:47 AM