COUNTER Code [transfer]

Source: Internet
Author: User
Recently, many netizens have been discussing counter Issues. They occasionally see an article posted to address their urgent needs.
Paste the code on the first page.
<%
'Descare our vaiables
Dim objFSO, objCountFile 'object vars for FSO and File
Dim strCountFileName 'filename of count text file
Dim iCount 'Count variable
Dim bUseImages 'Boolean whether or not to use images
Dim I 'standard looping var
'Termine whether we use images or plain text
'You could just set this to True or False instead
BUseImages = CBool (Request. QueryString ("images "))
'Compute our count file's filename
'This is based on the file from which you call count. asp
'It basically takes that name and appends a. cnt so I don't
'Accidently overwrite any files. If for some reason you have
'A file named script_name.asp.cnt then change this or watch out!
StrCountFileName = Server. MapPath (Request. ServerVariables ("SCRIPT_NAME") & ". cnt ")
'Create FileSystemObject to deal with file access
Set objFSO = Server. CreateObject ("Scripting. FileSystemObject ")
'Open the file as a text stream (1 = ForReading, True = Create)
Set objCountFile = objFSO. OpenTextFile (strCountFileName, 1, True)
'Read the current count from the file
If Not objCountFile. AtEndOfStream Then
'Set value to contents of the file
ICount = CLng (objCountFile. ReadAll)
Else
'If no file exists or it's empty start at 0
ICount = 0
End If
'Close the file and destroy the object
ObjCountFile. Close
Set objCountFile = Nothing
'Crement the count
ICount = iCount + 1
'Overwrite existing file and get a text stream to new one
Set objCountFile = objFSO. CreateTextFile (strCountFileName, True)
'Write updated count
ObjCountFile. Write iCount
'Close the file and destroy the object
ObjCountFile. Close
Set objCountFile = Nothing
'Deststroy the FSO object
Set objFSO = Nothing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.