Just looking for a counter, because the site is too little traffic, put a counter in there is indeed a bit shabby, so the call can only make a simple point, you can visit once on the record to support Men Men first. Originally I had a, but depressed is incredibly can not find, in the Internet so a lap, finally is done, the specific program code as follows.
The count.asp code is:
Copy Code code as follows:
<%
Option Explicit
Dim fs,filename,txt,content,total,counter_lenth
Counter_lenth=1 ' Sets the minimum length of the data to display, if less than the actual length, whichever is the actual length
Set Fs=server.createobject ("Scripting.FileSystemObject")
Filename=server. MapPath ("Count.txt")
If not FS. FileExists (filename) Then
Fs. CreateTextFile Filename,true,true
Set TXT=FS. OpenTextFile (Filename,2,true)
Txt.write 0 ' If there is no file to save the data, create a new file and write to data 0
Set fs=nothing
End If
Set TXT=FS. OpenTextFile (filename)
If txt. AtEndOfStream Then
Application ("Counter") =0 ' if there is no data in the file, initialize the value of application (' Counter ') (for fault tolerance)
Else
Application ("Counter") =txt.readline
End If
Application.Lock
Application ("Counter") = Application ("Counter") + 1
Application.UnLock
function Save_ ' Save count functions
Set Fs=server.createobject ("Scripting.FileSystemObject")
Filename=server. MapPath ("Count.txt")
Content=application ("Counter")
Set TXT=FS. OpenTextFile (Filename,2,true)
Txt.write Content
Set fs=nothing
End Function
Save_ ' call save function to save data
function Digital (counter) ' Show data functions
Dim I,mystr,scounter
Scounter = CStr (counter)
For i = 1 to Counter_lenth-len (Scounter)
MyStr = mystr & "0"
' MyStr = mystr & ' "' If there is a picture, this statement can be invoked
Next
For i = 1 to Len (Scounter)
MyStr = mystr & Mid (Scounter, I, 1)
' MyStr = mystr & ' "' if there is a picture, can be invoked with this statement
Next
Digital = MyStr
End Function
function Count_show ' Read count functions
Set Fs=server.createobject ("Scripting.FileSystemObject")
Filename=server. MapPath ("Count.txt")
Set Txt=fs.opentextfile (filename,1,true)
Total=txt.readline
Total=cint (total)
' Response.Write Total
Response.Write Digital (total) calls the Display function
Set fs=nothing
End Function
%>
Then create a new count.txt (must be the same level as the count.asp), open the file and enter any number in it (don't be too ruthless), and then add the top of the page that needs to display the counter
Copy Code code as follows:
<!--#include file= "count.asp"-->
Finally, add the code where you want to display the counter
Copy Code code as follows:
It's OK.