<%dim visitorswhichfile=server.mappath("counter/counter.txt")set fs=server.createobject("Scripting.FileSystemObject")set thisfile=fs.opentextfile(whichfile)visitors=thisfile.readlinethisfile.closecountlen=len(visitors)for i=1 to 5-countlenresponse.write "<img src=counter/0.gif>"nextfor i=1 to countlenresponse.write "<img src=counter/" & mid(visitors,i,1) & ".gif></img>"nextvisitors=visitors+1set out=fs.createtextfile(whichfile)out.writeline(visitors)out.closeset fs=nothing%>或加我QQ:***********谢谢了
參考答案:<%
//创建一个文件对象
dim visitors
whichfile=server.mappath("counter/counter.txt")
set fs=server.createobject("Scripting.FileSystemObject")
set thisfile=fs.opentextfile(whichfile)
//从counter.txt里面读一行字符串出来
visitors=thisfile.readline
thisfile.close
//获取visitors字符串的长度
countlen=len(visitors)
//前面的空白位都为0图片 列如00123
for i=1 to 5-countlen
response.write "<img src=counter/0.gif>"
next
//有数字值的位都显示相应的图片
for i=1 to countlen
response.write "<img src=counter/" & mid(visitors,i,1) & ".gif></img>"
next
//被浏览了一次 访问量加1
visitors=visitors+1
//创建输出文件对象并写入数值
set out=fs.createtextfile(whichfile)
out.writeline(visitors)
out.close
//关闭对象
set fs=nothing
%>