1.新建count.txt文件文档
<%
response.write "您是本页的第"&counter()&"位访客"
function counter()
whichfile=server.mappath("count.txt")
'打开文件并将其值读取,最后关闭连接释放资源
set fso=createobject("Scripting.FileSystemObject")
set openfile=fso.opentextfile(whichfile,1)
visitors=openfile.readline
openfile.close
'页面显示记数内容并做加1运算
visitors=visitors+1
'将新的数值添加写入到文本,最后关闭所有连接释放资源
set creatfile=fso.createtextfile(whichfile)
creatfile.writeLine(visitors)
creatfile.close
set fso=nothing
counter=visitors
end function
%>