473,704 Members | 2,347 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom Hit Counter

I decide to put a custom Hit Counter on my page (below). Then I won't be
reliant on the standard FrontPage one which uses webbots.

It is called by
<b>Hit Counter: </b><!--#include file="_fpclass/hit_count.inc"-->
The code it includes is below.

OK, it works - sort of.

If I go to Guestbook and then return via the Home button, the counter
increases by 3, not 1.

I can't see why this is happenning.

After returning, a refresh increases it by 2, then another refresh increases
it by 1 ??

I know that many say "Don't use them - it is a sign of an amateur", but I
would at least like to get it working even if I later decide not to use it.

I have thought to make it a conditional include, i.e. if document.referr er
is blank. Is that possible?

'Dimension variables
Dim fsoObject 'File System Object
Dim tsObject 'Text Stream Object
Dim filObject 'File Object
Dim lngVisitorNumbe r 'Holds the visitor number
Dim intWriteDigitLo opCount 'Loop counter to display the graphical hit count
Dim cntDigit 'Holds the digit displayed in the counter

'Create a File System Object variable
Set fsoObject = Server.CreateOb ject("Scripting .FileSystemObje ct")

'Initialise a File Object with the path and name of text file to open
Set filObject = fsoObject.GetFi le(Server.MapPa th("_private/index.asp.cnt") )

'Open the visitor counter text file
Set tsObject = filObject.OpenA sTextStream

'Read in the visitor number from the visitor counter file
lngVisitorNumbe r = CLng(tsObject.R eadAll)

'Increment the visitor counter number by 1
lngVisitorNumbe r = lngVisitorNumbe r + 1

'Create a new visitor counter text file over writing the previous one
Set tsObject =
fsoObject.Creat eTextFile(Serve r.MapPath("_pri vate/index.asp.cnt") )

'Write the new visitor number to the text file
tsObject.Write CStr(lngVisitor Number)

'Reset server objects
Set fsoObject = Nothing
Set tsObject = Nothing
Set filObject = Nothing

'Display the hit count as text
' Response.Write( lngVisitorNumbe r)

'Loop to display graphical digits
For intWriteDigitLo opCount = 1 to Len(lngVisitorN umber)
' Display the graphical hit count
cntDigit = Mid(lngVisitorN umber, intWriteDigitLo opCount, 1)
Response.Write( "<img src=""counter_i mages/")
Response.Write( cntDigit & ".gif""")
Response.Write( "alt=""" & cntDigit & """>")

Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/

Nov 25 '06 #1
0 1992

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: W1ld0ne74 | last post by:
I am implimenting Performance counters into a web application. I use the following code to create the counters during setup: private void SetupPerfCntrs() { System.Diagnostics.CounterCreationDataCollection CounterDatas = null; System.Diagnostics.CounterCreationData cdCounter4 = null; try { if(System.Diagnostics.PerformanceCounterCategory.Exists("LogisOnline"))
by: Navin Mishra | last post by:
Hi, I'm having problem adding custom performance counter INSTANCE in an ASP.NET web service whose miltiple instances could run hosted by different IIS AppPools on same machine. I can update my custom performance counters WITHOUT instances just fine but when I try to specify instance name then the counter is not updated at all and there is no error thrown also. I've followed MSDN example to specify instance name: // Assumes category...
by: Val Mazur (MVP) | last post by:
Hi guys, My application creates custom performance counter and it works fine. Now I am creating multiple instances of the same counter and increment value for each instance. This part work fine as well. But if I open Performance Monitor it does not show any instances of the counter and, of course, no information available for the counter. Am I missing something? Val
by: Ivan | last post by:
I have the SystemMonitor ActiveX control on a form and I try to register a custom performance counter. I expect that after registering the counter with the OS, the user would be able to add it through this System Monitor ActiveX control on the form. Yet, the Add dialog of this ActiveX does NOT contain the already registered counter. Does anyone know what might be wrong? Code snippet follows at the end. BTW if I have the code that registers...
by: Lee | last post by:
Hi all, I'm trying to programatically change the background color of lines of text and running into a few difficulties, anyone got any suggestions? my relevant code is as follows: public void colorLines() { //_Paint = false; //don't want to update while we are doing this //loop thru lines like addText() does
by: supreeth.bhat | last post by:
I created a new Performance Counter Category and added three new counters. Used InstallUtil.exe to create them on remote production server. I can see the custom counter category and counters. I have a web site built with Commerce Server 2002 and .NET 1.1. I am trying to increment and/or decrement counter values for every session start and
by: WEG | last post by:
I want to create a custom counter to act as the primary field in a table but am having trouble with it. What I would like is a counter that shows the last two digits of the year, a hyphen, then a counter that starts at one and goes up by one digit with each new record. Then, when a new year starts, would reset to one and start again. For instance, 07-001, 07-002 and so on until 08-001, 08-002. I've seen all kinds of great answers...
by: SachinSachin | last post by:
Hi All, I am implementing a custom gridview control, that emits some javascript to blink a row whenever a new row is added in gridview. The gridview is inside the <asp:updatepanel> for parital page rendering. The problem is when I put the gridview inside the updatepanel, I don't see the HTML table that is created as a result from rendering the gridviewcontrol and thus when new row is added, it does not blink, however when i just put the...
by: T-Co | last post by:
I have developed a custom plugin for authorizing streams. I fetch the URL from pPresentationCtx on WMS_EVENT_OPEN with WMS_PRESENT_REQUEST_NAME and go from there. My EnablePlugin() has plHeartbeatPeriod = 30000; My OnHeartBeat() has a function that increases a counter. Now, what I would like to do is, that when the counter reaches a certain point I would like to tell the server (or client or whatever) to disconnect the stream.
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.