<% option explicit dim fs,filename,txt,content,total,counter_lenth counter_lenth=1 '設(shè)置顯示數(shù)據(jù)的最小長(zhǎng)度,如果小于實(shí)際長(zhǎng)度則以實(shí)際長(zhǎng)度為準(zhǔn) set fs=Server.CreateObject("Scripting.FileSystemObject") filename=server.MapPath("count.txt") if not fs.FileExists(filename) then fs.CreateTextFile filename,True,True set txt=fs.OpenTextFile(filename,2,true) txt.write 0 '如不存在保存數(shù)據(jù)的文件則創(chuàng)建新文件并寫入數(shù)據(jù)0 set fs=nothing end if
set txt=fs.OpenTextFile(filename) If txt.AtEndOfStream Then Application("Counter")=0 '如果文件中沒有數(shù)據(jù),則初始化Application("Counter")的值(為了容錯(cuò)) else Application("Counter")=txt.readline end if
Function save_ '保存計(jì)數(shù)函數(shù) set fs=Server.CreateObject("Scripting.FileSystemObject") filename=server.MapPath("count.txt") content=Application("Counter") set txt=fs.OpenTextFile(filename,2,true) txt.write content set fs=nothing End Function
save_ '調(diào)用保存函數(shù)保存數(shù)據(jù)
Function Digital ( counter ) '顯示數(shù)據(jù)函數(shù) Dim i,MyStr,sCounter sCounter = CStr(counter) For i = 1 To counter_lenth - Len(sCounter) MyStr = MyStr & "0" 'MyStr = MyStr & "<IMG SRC=改成你自己的圖片存放的相對(duì)目錄/0.gif>" '如有圖片,可用此語(yǔ)句調(diào)用 Next For i = 1 To Len(sCounter) MyStr = MyStr & Mid(sCounter, i, 1) 'MyStr = MyStr & "<IMG SRC=改成你自己的圖片存放的相對(duì)目錄/" & Mid(sCounter, i, 1) & ".gif>" '如有圖片,可用此語(yǔ)句調(diào)用 Next Digital = MyStr End Function