WebCounter: A COM component used in counting number of visits of a ASP page. by Doris Duan

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 15
June 15, 2000
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

It has one property

strFileName: It will be the physical file storing the number of visits. When COM component is initialized, the property will be set to "MyCounter.txt".

It has three methods.

SetCounter(option lNum as Long = 0): This method will be used to reset counter. The default value is 0.

GetCurCounter(): This method will return the current value of the counter

Increment(): This method will increase the counter by One and return the updated value of the counter.

If an error happened in the COM component, an error will be raised with error number, name of the method caused the error and the description.

Dependency:

The COM component use FileSystemObject to handle file access.


Sample Usage:

Register the COM component either by regsvr32 or MTS.

Then in asp page, include following code

-------------------------------------------
<% response.write "This page has been accessed " & counter() & " times" %>


<script runat = server language = vbscript>
function counter()
dim obj
set obj = server.createobject("WebCounter.Counter")
dim iNum
obj.strFileName = "PageCounter.txt"
counter = obj.Increment ()
set obj = nothing
end function
</script>
---------------------------------------------


If you want to count the number of visit for each individual page, simply assign unique value for the "strFileName" property for each page.

blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 1 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials