争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

计数器代码[转]

时间:2024/6/20作者:未知来源:争怎路由网人气:

最近许多网友在讨论计数器的问题,偶尔看到一篇文章,贴出来以解大家燃眉之急

一下代码贴在第一页即可
<%
' Declare 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


' Determine 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


' Increment 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


' Destroy the FSO object
Set objFSO = Nothing


' We're all done with the hard part
' All that's left is to display the results
If bUseImages Then
' Loop through the count integer showing each digit
' You can grab the images one at a time or get the zip
' http://www.asp101.com/samples/download/counter_imgs.zip
For I = 1 to Len(iCount)
' Output the IMG tag using the right digit
Response.Write "<IMG SRC=""./images/digit_"
Response.Write Mid(iCount, I, 1)
Response.Write ".gif"" ALT="""
Response.Write Mid(iCount, I, 1)
Response.Write """ WIDTH=""20"" HEIGHT=""27"">"
Next 'I
Else
' No image wanted just show the variable
Response.Write iCount
End If
%>

关键词:计数器代码[转]




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版