![]() |
ASP Hit Counter
Hi guys,i got this code from the internet but i cannot run it. It gave me the error type mismatch: CLng. How do i resolve this? I used dreamweaver to do up my hit_count.txt which only contains the number zero and nothing else.
What's wrong?? 'Dimension variables Dim fsoObject 'File System Object Dim tsObject 'Text Stream Object Dim filObject 'File Object Dim lngVisitorNumber 'Holds the visitor number Dim intWriteDigitLoopCount 'Loop counter to display the graphical hit count 'Create a File System Object variable Set fsoObject = Server.CreateObject("Scripting.FileSystemObject") 'Initialise a File Object with the path and name of text file to open Set filObject = fsoObject.GetFile(Server.MapPath("hit_count.txt")) 'Open the visitor counter text file Set tsObject = filObject.OpenAsTextStream 'Read in the visitor number from the visitor counter file lngVisitorNumber = CLng(tsObject.ReadAll) 'Increment the visitor counter number by 1 lngVisitorNumber = lngVisitorNumber + 1 'Create a new visitor counter text file over writing the previous one Set tsObject = fsoObject.CreateTextFile(Server.MapPath("hit_count.txt")) 'Write the new visitor number to the text file tsObject.Write CStr(lngVisitorNumber) 'Reset server objects Set fsoObject = Nothing Set tsObject = Nothing Set filObject = Nothing 'Display the hit count as text 'Response.Write(lngVisitorNumber) |
Code tags.
|
It would be better if you use a Application object, for solving this problem of number of visitors...always a better option...
Alternatively, you can check the Page Counter Component at http://www.microsoft.com/windows2000...p/comp00vo.htm and use that!... |
| All times are GMT -5. The time now is 3:56 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC