<!-- 1.counter.aspが存在する場所にcounterフォルダを作成します。 --> <!-- 2.その中に、0a.gif,1a.gif,2a.gif,3a.gif....9a.gifのGIFファイルを作成してください。--> <HTML> <HEAD> <TITLE>Gifカウンター</TITLE> </HEAD> <FONT SIZE=+2><B>Gifカウンター</B></FONT><br> <% sGIFPass ="counter/" On Error Resume Next Set objFile = Server.CreateObject("Scripting.FileSystemObject") sPathCountFile = Server.MapPath("/userid/_exc\count.txt") Set strmFile = objFile.OpenTextFile(sPathCountFile, 1, FALSE)
If Err <> 0 Then Select Case Err Case 53 Set strmFile = objFile.CreateTextFile(sPathCountFile,False,False) strmFile.WriteLine 0 strmFile.Close Set strmFile = objFile.OpenTextFile(sPathCountFile, 1, FALSE) Err.Clear Case Else Response.Write("エラー元: " & Err.Source & "<BR>") Response.Write("エラー番号: " & Err.Number & "<BR>") Response.Write("エラーの説明: " & Err.Description & "<BR>") Err.Clear End Select End if
If Err.Number > 0 Then iCount = 0 Else iCount = strmFile.ReadLine End If iCount = iCount + 1 strmFile.Close Set strmFile = objFile.OpenTextFile(sPathCountFile, 2, TRUE) strmFile.WriteLine iCount strmFile.Close sCount = right("000000" & CSTR(iCount), 6) buf = "" For i = 1 to Len(sCount) buf = buf + "<IMG SRC=" & chr(34) & sGIFPass & Mid(sCount, i, 1) & "a.gif" & chr(34) & ">" Next Response.Write buf %> </HTML>