| Author |
Topic Search Topic Options
|
kasl_33
Groupie
Joined: 15 June 2003
Location: United States
Status: Offline
Points: 86
|
Post Options
Thanks(0)
Quote Reply
Topic: Help with putting comma’s in hit counter Posted: 17 January 2005 at 9:22pm |
I have a hit counter on my site (www.kistech.com) and have over 200000
hits. I like how Web Wiz Guide has commas in the number of hits
at the bottom of the page.
Can somebody tell me what code I would need to modify (and how it
should be) from the tutorial
at
this link?
Edited by kasl_33 - 19 January 2005 at 9:11pm
|
|
|
 |
ljamal
Mod Builder Group
Joined: 16 April 2003
Status: Offline
Points: 888
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 January 2005 at 10:24pm |
|
Use the FormatNumber function
|
|
|
 |
kasl_33
Groupie
Joined: 15 June 2003
Location: United States
Status: Offline
Points: 86
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 January 2005 at 10:33pm |
|
I am an asp noob... so I don't know what you mean - let alone where to
put it. If it is a quick mod, would you be willing to post the
modifications?
Thanks in advance!
|
|
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 January 2005 at 11:30pm |
Wherever you output the counter value ( I guess it is something like Response.Write(varcounter) or something like that)
Write this as Response.Write(FormatNumber(varcounter,0,True,False,True) )
The last true indicates that numbers are to be grouped based on the settings in the servers CP.
|
|
|
 |
kasl_33
Groupie
Joined: 15 June 2003
Location: United States
Status: Offline
Points: 86
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 January 2005 at 11:37pm |
Okay, I think we're getting somewhere, but, again, I am still an asp noob.
Here is the code. Please copy it and mark the changes in red if you would :)
<%
' Every time we count a user we will put the
' latest count value in the session variable "TotalCount"
' If Session Variable TotalCount is empty
' that mean this user is new and session variable
' But if Session Variable already has the value
' Then we will not count this user again.
If IsEmpty(Session("TotalCount")) Then
Call CountThisUser
End If
' It is good practice to use Functions and Sub procedure
' Because all the variables being used in sub or function
' are automatically destroyed when Sub or Function finish
' processing the code.
' So you can use these Variables again in other functions
Sub CountThisUser()
Dim objFSO ' FileSystemObject
Dim objTS ' TextStreamObject
Dim strFileName ' Counter text File Name
Dim intOldCount
Dim intNewCount
' Specify the Text file to store count value
' Because We Set Create = True
' File will be Created if it does not exist
strFileName = Server.MapPath("Counter.txt")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFileName) Then
Set objTS = objFSO.OpenTextFile(strFileName, 1)
Else
Set objTS = objFSO.CreateTextFile(strFileName, True)
End If
If Not objTS.AtEndOfStream Then
intoldCount = objTS.ReadAll
Else
intoldCount = 0
End If
objTS.Close
intNewCount = intOldCount + 1
' Store the value of intNewCount in Session Variable
' So you can use it on different pages
Session("TotalCount")= intNewCount
' Write intNewCount value back to text file
Set objTS = objFSO.CreateTextFile(strFileName, True)
objTS.Write intNewCount
objTS.Close
Set objFSO = Nothing
Set objTS = Nothing
End Sub
%>
|
|
|
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 18 January 2005 at 9:05pm |
No red today, but add it at
objTS.Write intNewCount doing the FormatDateTime(intNewCount,......)
|
|
|
 |
kasl_33
Groupie
Joined: 15 June 2003
Location: United States
Status: Offline
Points: 86
|
Post Options
Thanks(0)
Quote Reply
Posted: 19 January 2005 at 9:11pm |
michael wrote:
No red today, but add it at
objTS.Write intNewCount doing the FormatDateTime(intNewCount,......) |
I'm not sure exactly what you mean... how would that look in the actual code?
|
|
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 19 January 2005 at 10:16pm |
objTS.Write FormatNumber(intNewCount,0,True,False,True) )
|
|
|
 |