techpreparation-homepage

Home  Interview Questions  Aptitude Questions  Tutorials  Placement Papers  Search  Resume Guide  Soft Skills  Video  Forum  Blog


Technical Interview Questions

Visual Basic Interview Question
.NET Web Interview Questions
.NET Interview Questions
C# Interview Questions
                              .........More

Source Codes
Asp .NET Source Codes
Asp VB Script Source Codes
                              .........More

Soft Skills
Communication Skills
Leadership Skills
                              .........More

Subscribe to our Newsletters
Name:
Email:

 

 

  

Asp/VB Script Source Codes

Simple Text Hit Counter

<P>This is a more accurate counter than our previous example , in this example the count only gets incremented once per session . This means your count will be more accurate if you want it to be that is.</P>
<P>Create a txt file and put your starting number in it . Then copy the code snippet below where you want the counter to display on your page. </P>
<P>In the example below the counter.txt is placed in the same directory as this page , if you put the txt file elsewhere remember and alter the Server.MapPath part of the code. </P>
<P>Visitor number<BR>&lt;%<BR>'create a FileSystemObject<BR>Set objFSO = CreateObject("Scripting.FileSystemObject")<BR>'this is the path to our counter file<BR>CounterFile = Server.MapPath("counter.txt")<BR>Set objCount = objFSO.OpenTextFile(CounterFile)<BR>visitorcount = CLng(objCount.ReadLine)<BR>if Session("visitorcount") = "" then<BR>Session("visitorcount") = visitorcount<BR>visitorcount = visitorcount + 1<BR>objCount.close<BR>Set objCount = objFSO.CreateTextFile("counter.txt", True)<BR>objCount.WriteLine(visitorcount)<BR>end if<BR>objCount.Close<BR>'display count<BR>Response.Write visitorcount<BR>%&gt;</P>


<<<----- Return to Asp/VB Script Source Code Questions Page.


Have a Question ? post your questions here. It will be answered as soon as possible.

Check Microsoft .Net Interview Questions for more Microsoft .Net Interview Questions with Answers.

Check .Net Database Interview Questions for more .Net Database Interview Questions with answers

Check Job Interview Questions for more Interview Questions with Answers