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)
'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
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.