<% option explicit dim fs,filename,txt,content,total,counter_lenth counter_lenth=1 '設置顯示數據的最小長度,如果小于實際長度則以實際長度為準 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 '如不存在保存數據的文件則創建新文件并寫入數據0 set fs=nothing end if
set txt=fs.OpenTextFile(filename) If txt.AtEndOfStream Then Application("Counter")=0 '如果文件中沒有數據,則初始化Application("Counter")的值(為了容錯) else Application("Counter")=txt.readline end if
Function save_ '保存計數函數 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_ '調用保存函數保存數據
Function Digital ( counter ) '顯示數據函數 Dim i,MyStr,sCounter sCounter = CStr(counter) For i = 1 To counter_lenth - Len(sCounter) MyStr = MyStr & "0" 'MyStr = MyStr & "<IMG SRC=改成你自己的圖片存放的相對目錄/0.gif>" '如有圖片,可用此語句調用 Next For i = 1 To Len(sCounter) MyStr = MyStr & Mid(sCounter, i, 1) 'MyStr = MyStr & "<IMG SRC=改成你自己的圖片存放的相對目錄/" & Mid(sCounter, i, 1) & ".gif>" '如有圖片,可用此語句調用 Next Digital = MyStr End Function