| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 876 人关注过本帖
标题:[求助]这里是一段读取记事本中的数,来统计访问数的代码。帮我看看哪里出错 ...
只看楼主 加入收藏
风中的承诺
Rank: 1
等 级:新手上路
帖 子:331
专家分:0
注 册:2004-10-31
收藏
 问题点数:0 回复次数:2 
[求助]这里是一段读取记事本中的数,来统计访问数的代码。帮我看看哪里出错了,谢谢
<%
 Application.Lock
 Set fs=Server.CreateObject("Scripting.FileSystemObject")
 counter_file=Server.MapPath("/counter.txt")
 Set txt=fs.OpenTextFile(counter_file)
 Application("counter")=txt.ReadLine
 txt.Close
 Application("counter")=Application("counter")+1
 Set txt=fs.CreateTextFile(counter_file,true)
 txt.WriteLine(Application("counter"))
 txt.Close
 Application.UnLock
%>
搜索更多相关主题的帖子: counter txt Application 记事本 Set 
2005-03-29 12:22
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 

<% on error resume next Application.Lock Set fs=Server.CreateObject("Scripting.FileSystemObject") counter_file=Server.MapPath("counter.txt") Set txt=fs.OpenTextFile(counter_file,1,true) '错误在于,如果开始没有这个counter.txt打开文件会出错,此时我们可以加上参数使其创建文件

Application("counter")=txt.ReadLine txt.Close if Application("counter")="" then Application("counter")=1 else Application("counter")=Application("counter")+1 end if Set txt=fs.CreateTextFile(counter_file,true) txt.WriteLine(Application("counter")) txt.Close Response.Write Application("counter") Application.UnLock

if err then response.write err.Description end if

%>

[此贴子已经被作者于2005-3-29 14:43:50编辑过]


天津网站建设 http://www./
2005-03-29 14:42
风中的承诺
Rank: 1
等 级:新手上路
帖 子:331
专家分:0
注 册:2004-10-31
收藏
得分:0 
哦,多谢哈

I love you not because of who you are, but because of who I am when I am with you!
2005-03-31 12:36
快速回复:[求助]这里是一段读取记事本中的数,来统计访问数的代码。帮我看看哪里 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014176 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved