3:58 pm Saturday, July 31, 2010
     
SERVER TRANSFER COMPLETE. UNDER CONSTRUCTION.
            Search About Contact Home
Hit Counter Tutorial
AaronOutpost : ASP / Tutorials / Counters / Hit Counter

Graphical Hit Counter Tutorial

Counters Tutorial
  1. Create a Text Hit Counter

  2. Create a Graphic Hit Counter

  3. Create a Text or Graphic Session Hit Counter

  4. Create an Active User Hit Counter using global.asa

Welcome to Part 2 of 4 Counter Tutorials. We are now going to take the counter from Step1: Create a Text Hit Counter and use graphics to display the hit count.

Create Number Images
    So, open your favorite photo editor and make some number files. Make as many test images as you want. Then create each individual number image. Then name them images the number which is in the picture. You can use any extension: gif, jpg, etc... This is the fun part and can be changed easily at anytime. But, it's your own design and you can make it fit your own site. I named my files: 0.gif ; 1.gif ; 2.gif ; etc... I then placed the images files into a folder in the directory at which I am going to place my Hit Counter Script.

 

 

Here we use a "For / Next" loop to display the graphics. Using the VBScript "Len" function we will get the length of the number in the text file. It will count how many numbers there are. 

1000 has 4 numbers        :          500 has 3 number          :          98542 has 5 numbers

First we have to define the loop count to be used. We want to go from 1 to the length of the number in the test file.

'----------------------------------------------------------
'Display the hit count as images using loop

'-----------------------------------------------------------

For LoopCount = 1 to Len(NumberVisitors) %>


I have it use the specific number .gif file to display by using the "Mid" function. I went on and included the ALT text for the image file. So if image does not display then the text will. Something that is wise for you to do with all images. Then it loops to the next number.

<img src="counter_images/<%= Mid(NumberVisitors, LoopCount, 1) %>.gif" alt="<%= Mid(NumberVisitors, LoopCount, 1) %>">

 

<% Next %>

 

 

Finally this finished project should look something like this! Make sure it is saved in .asp format as mentioned before and must be run on an ASP2 enabled server.

Don't want the count to only count each user once?
Visit Part 3
Create a Text or Graphic Session Hit Counter

<html>

<head>

<title>Hit Counter</title>

</head>

<body bgcolor="white" text="black">

<div align="center">

<h3>Hit Counter</h3>

 

<%

 

Dim FileSystemObject, TextStreamObject, FileObject, NumberVisitors, LoopCount

 

'-----------------------------------------------------------
' Get and open hit count file

'-----------------------------------------------------------

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

Set FileObject = FileSystemObject.GetFile(Server.MapPath("hit_counter.txt"))

Set TextStreamObject = FileObject.OpenAsTextStream

 

'-----------------------------------------------------------

' Increment count

'-----------------------------------------------------------

NumberVisitors = CLng(TextStreamObject.ReadAll)

NumberVisitors = NumberVisitors + 1

 

Set TextStreamObject = FileSystemObject.CreateTextFile(Server.MapPath("hit_counter.txt"))


TextStreamObject
.Write CStr(NumberVisitors)

 

 

Set FileSystemObject= Nothing

Set TextStreamObject = Nothing

Set FileObject = Nothing

 

'-----------------------------------------------------------
'Display the hit count as text

'-----------------------------------------------------------

%>

Text Version of Count <br>
<%=
NumberVisitors %>

<br>

<br>


'----------------------------------------------------------
'Display the hit count as images using loop

'-----------------------------------------------------------

For LoopCount = 1 to Len(NumberVisitors) %>

 

 

<img src="counter_images/<%= Mid(NumberVisitors, LoopCount, 1) %>.gif" alt="<%= Mid(NumberVisitors, LoopCount, 1) %>">

 

<% Next %>

 

<br>

</div>

</body>

</html>


AaronOutpost : ASP / Tutorials / Counters / Graphical Hit Counter
Random_Image
News & Updates

ASP Inline Calendar 3.9 (January 5, 2008)
Future Home of News & Updates (January 5, 2008)

 

Photo Special

Schedule an appointment

Available in & around:
Centreville VA, Spotsylvania VA,
Summersville WV, & Charleston WV
.

  • NAME YOUR PRICE
    • Email your:
    • Event
    • Hours Needed
    • Photos Needed
    • Disks or Prints
    • and Price You're Willing To Pay
ASP Inline Calendar

$100 Installation Special

PROFESSIONAL INSTALLATION OF YOUR ASP INLINE CALENDAR. REDUCE THE HASSLE, LET US INSTALL YOUR ASP INLINE CALENDAR. SEND A FORMAL REQUEST FOR INSTALLATION WITH SERVER ACCESS INFORMATION. WE WILL NEED FTP ACCESS ALONG WITH CONTROL PANEL ACCESS.

Purchase A Calendar
Information
Demo
Ask A Question

User must provide ftp access to server. Installations are not guaranteed. We work with your service provider to get your calendar installed.

 

Centreville, VA      -      Spotsylvania, VA      -      Charleston, WV      -      Summersville, WV

© Copyright AaronOutpost.com 2010. All rights reserved.