Text Counter

Posted on March 4th, 2009 in ASP by admin

Now create a folder called counters or you can call it something else if you want just remember and change the code above . Now create a text file called counter1.txt and enter whatever you wish to start the count at.

<%@ Language=VBScript %>
<%
Dim fso
Set fso = Server.CreateObject(”Scripting.FileSystemObject”)
//this is the path to your counter1.txt file
counter = Server.MapPath(”/counters”) & “\counter1.txt”
//open the text file
Set InStream = fso.OpenTextFile(counter , 1, False)
oldCount = Trim(InStream.ReadLine)
//increment the oldcount by 1 and store in newcount
newCount = oldCount + 1
Set OutStream = fso.CreateTextFile(counter, True)
//copy newcount to the text file
OutStream.WriteLine(newCount)
%>

Now you would place the folllowing where you want the counter to appear on your site

<%= newCount%>

Related posts:

  1. More accurate text counter This is a more accurate counter than our previous example...
  2. Display a CSV file Display a CSV file CSV files are common formats to...
  3. Saving a CSV file to a database Create a database in access called stock.mdb . Now create...
  4. create a text file Private Sub Form_Load() Dim objFSO As New FileSystemObject Dim objFile...
  5. rndimage1 This is a simple random image script which is ideal...

Related posts brought to you by Yet Another Related Posts Plugin.

Post a comment