主题:  计数器的问题

yijiang

职务:普通成员
等级:1
金币:0.0
发贴:33
注册:2003/8/15 19:19:23
#12003/8/19 23:16:11
<%
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile("d:\test\aspcounter.txt")
counter= Clng(a.ReadLine)
counter = counter + 1
a.close
Set a = fs.OpenTextFile("d:\test\aspcounter.txt")
a.WriteLine(counter)
a.Close
Set a=nothing
Set fs=nothing
%>
现已点击: <% =ct %> 次

我运行这个代码,出问题a.WriteLine(counter)

请问为什么



大当家

职务:普通成员
等级:3
金币:1.0
发贴:767
注册:2001/12/8 20:02:19
#22003/8/19 23:28:03
这样试试~~

<%
CountFile=Server.MapPath("d:\test\aspcounter.txt")
Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
Set Out=FileObject.OpenTextFile(CountFile,1,FALSE,FALSE)
counter=Out.ReadLine
Out.Close
SET FileObject=Server.CreateObject("Scripting.FileSystemObject")
Set Out=FileObject.CreateTextFile(CountFile,TRUE,FALSE)
Application.lock
counter= counter + 1
Out.WriteLine(counter)
Application.unlock
Out.Close
%>

现已点击: <%=counter%> 次



yijiang

职务:普通成员
等级:1
金币:0.0
发贴:33
注册:2003/8/15 19:19:23
#32003/8/21 19:27:37
OK, 谢谢先,

调试了一下OK

只是需要的是虚拟路径, 其它没有问题.

请问一下, 我的程序倒底错在哪, 为什么我那样写不对呢.



skyfox

职务:普通成员
等级:1
金币:0.0
发贴:7
注册:2003/8/22 10:44:53
#42003/8/23 10:14:49
<%
Sub NumberAppend()
Set files=Server.CreateObject("Scripting.FileSystemObject")
Set numtxt=files.OpenTextFile(Server.MapPath("Num.txt"))
Application("Number")=numtxt.ReadLine
numtxt.Close
Application("Number")=0
Response.Write Application("Number")
Set numtxt=files.CreateTextFile(Server.MapPath("Num.txt"),True)
numtxt.WriteLine(Application("Number"))
numtxt.Close
End Sub
Application.Lock
NumberAppend
Application.UnLock
%>
我写了一个
你看看你的文本里有没有预设值,比如打个0