<% ' declaring variables, arrays Dim x Dim FSObject Dim GetTotals Dim WriteTotals Dim PageEntry Dim PageHits() Dim PageName() Dim ThisPage 'What page are we on? ThisPage = Request.ServerVariables("URL") ' Open a FileSystemObject and fetch data from the text file containing our page counts Set FSObject = CreateObject("Scripting.FileSystemObject") Set GetTotals = FSObject.OpenTextFile("d:\Inetpub\wwwroot\PageTotals.txt",1,0) ' Now read each line in our text file and load the data into the PageName and PageHits arrays x=0 While Not GetTotals.AtEndOfStream ' Loop until last line ReDim preserve PageName(x) ' Append PageName array PageName(x) = GetTotals.ReadLine ' Put first named page into PageName array If PageName(x) = ThisPage Then ' Check to see if this page name is current page ReDim preserve PageHits(x) ' Append PageHit array PageHits(x) = GetTotals.ReadLine + 1 ' If this is proper page, add 1 to total and put into PageHits array DisplayCount = PageHits(x) ' DisplayCount now contains this page's counter total x = x + 1 ' Increment the index number for our arrays Else ReDim preserve PageHits(x) ' If this page is NOT the current page... PageHits(x) = GetTotals.ReadLine ' we still load it into our array, but without adjuting total x = x + 1 ' Increment the index number for our arrays End If Wend ' Loop through rest of PageTotals.txt GetTotals.Close ' Clean up Set GetTotals = Nothing ' Now that we have our arrays loaded, we write a "new" PageTotals.txt file Set WriteTotals = FSObject.CreateTextFile("d:\Inetpub\wwwroot\PageTotals.txt") x = 0 ' Reset our array index to 0 For Each PageEntry In PageName ' Looping through our PageName array WriteTotals.WriteLine PageName(x) ' Write the PageName to the text file WriteTotals.WriteLine PageHits(x) ' Next line is the page's hits total x = x + 1 ' Increment our array index number Next WriteTotals.Close ' Clean up Set WriteTotals = Nothing Set FSObject = Nothing ' Now just drop the page count wherever we want in our page Response.Write("<font size=3><b>You are " & ThisPage & " Page visitor number...</b></font><br>" & DisplayCount & "</font>") %>