GoodDay All.

I am trying to create a hit counter in vbscript on a HTML Page for specific client needs. I cannot use any hit counters available for free.
My problem is that my code only finds the text file on my notebook(Local C:\ drive) and not in the website even though the file does exist.
my other problem is that when the page code reaches the "server.creatobject" line, i get the error (Microsoft VBScript runtime error: Object required: 'server').
I write mostly in VB but the client wants a specific HTML page and NOT ASP/ASPX.
Can someone help me please. I have been trying for a while and cannot get a decent answer to my above questions.

Below is the code.

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

Dim fso
dim tso
dim FilObject
dim VisitorCount
dim strOutputName
dim objOutputfile
strfilename ="counter.txt"

set fso=server.createobject("scripting.filesystemobject")

set filobject=fso.getfile(strfilename)
set tso=filobject.openastextstream

visitorcount=clng(tso.readall)
visitorcount=visitorcount + 1
stroutputname=strfilename
set objoutputfile=fso.createtextfile(stroutputname,true)

objoutputfile.writeline visitorcount

document.write(visitorcount)
</script>

Member Avatar for LastMitch

I write mostly in VB but the client wants a specific HTML page and NOT ASP/ASPX.

The code you provide doesn't make any sense, you need another language to do that.

You want a Hit-Count in html which can be done by using php, javascript, asp.net.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.