Help with putting comma’s in hit counter
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=13395
Printed Date: 30 March 2026 at 7:50pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Help with putting comma’s in hit counter
Posted By: kasl_33
Subject: Help with putting comma’s in hit counter
Date 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
http://www.kistech.com/forum/forum_posts.asp?TID=581&KW=hit+counter - at
this link?
------------- http://www.kasl.info - www.kasl.info
The PHP/MySql Web Development site
|
Replies:
Posted By: ljamal
Date Posted: 17 January 2005 at 10:24pm
Use the FormatNumber function
------------- L. Jamal Walton
http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming
|
Posted By: kasl_33
Date 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!
------------- http://www.kasl.info - www.kasl.info
The PHP/MySql Web Development site
|
Posted By: michael
Date 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.
------------- http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker
|
Posted By: kasl_33
Date 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
%>
|
------------- http://www.kasl.info - www.kasl.info
The PHP/MySql Web Development site
|
Posted By: michael
Date Posted: 18 January 2005 at 9:05pm
|
No red today, but add it at
objTS.Write intNewCount doing the FormatDateTime(intNewCount,......)
------------- http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker
|
Posted By: kasl_33
Date 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?
------------- http://www.kasl.info - www.kasl.info
The PHP/MySql Web Development site
|
Posted By: michael
Date Posted: 19 January 2005 at 10:16pm
|
objTS.Write FormatNumber(intNewCount,0,True,False,True) )
------------- http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker
|
Posted By: kasl_33
Date Posted: 19 January 2005 at 10:40pm
Well I tried it, and it didn't work. Thanks anyway :)
Any other suggestions? I think I've probably tried everything in the book.
------------- http://www.kasl.info - www.kasl.info
The PHP/MySql Web Development site
|
Posted By: michael
Date Posted: 20 January 2005 at 9:21am
Well "It did not work" is nothing anyone can help you on. Don't even know what kinda of hitcounter you are using...
------------- http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker
|
Posted By: kasl_33
Date Posted: 20 January 2005 at 10:00am
It is the same one in the link that I posted above:
http://www.kistech.com/forum/forum_posts.asp?TID=581&KW=hit+counter
------------- http://www.kasl.info - www.kasl.info
The PHP/MySql Web Development site
|
Posted By: Gullanian
Date Posted: 20 January 2005 at 12:21pm
|
Copy and paste the code here that actually print the counter onto the page.
|
Posted By: kasl_33
Date Posted: 20 January 2005 at 12:25pm
It is on the previous page of this topic.
------------- http://www.kasl.info - www.kasl.info
The PHP/MySql Web Development site
|
Posted By: Gullanian
Date Posted: 20 January 2005 at 1:05pm
|
None of that code prints the counter, it only calculates new
values. You need to find the line of code that displays the value.
|
Posted By: kasl_33
Date Posted: 20 January 2005 at 1:17pm
ahh... Here is the code that actually writes the count:
<%=Session("TotalCount")%>
------------- http://www.kasl.info - www.kasl.info
The PHP/MySql Web Development site
|
Posted By: Gullanian
Date Posted: 20 January 2005 at 1:33pm
Change to <%=FormatNumber(Session("TotalCount"),0)%>
A bit of information if your learning, FormatNumber() is a function
automatically built in to ASP that does what it says and formats a
number. ASP has lots of other build in functions such as lcase()
(converts characters to lowercase) and left() which takes characters
from the left of the string.
Writting simple functions is a good way to start learning ASP, take a look at w3schools.com for tutorials.
|
Posted By: kasl_33
Date Posted: 20 January 2005 at 3:07pm
Outstanding! It works and I appreciate your help. I will difinitely check out w3schools.com.
Thanks again :)
If there is anything i can ever do to help you, just let me know.
I can offer you free website space at webs.kaslwebs.com, gmail invites, or host your domain with MySql and php support.
Again, thanks :)
------------- http://www.kasl.info - www.kasl.info
The PHP/MySql Web Development site
|
Posted By: dj air
Date Posted: 20 January 2005 at 3:31pm
also a good site is www.devguru.com .. can help with asp, ado, fso, vbscript etc.
it has all the asp functions gullanian has said, and also gives examplles of using the functins, and real to use code.
|
|