asp 错误 '800a000d' 怎么解决

asp 错误 '800a000d' 怎么解决

<%

dim file,fileop
set file=server.createobject("scripting.filesystemobject")
set fileop=file.opentextfile(server.mappath("text.txt"),1,true)
count=fileop.readline()
fileop.close
 
set fileop=file.opentextfile(server.mappath("text.txt"),1)
count=count+1
fileop.write count
response.write count
fileop.close
%>

Microsoft VBScript 运行时错误 错误 '800a000d'
类型不匹配: 'count'
/计算器.asp,行 8

count=fileop.readline()这句读出的数据不是数字,自己加下判断不是数字初始化为0

<%
dim file,fileop
set file=server.createobject("scripting.filesystemobject")
set fileop=file.opentextfile(server.mappath("text.txt"),1,true)
count=fileop.readline()
fileop.close
if not isnumeric(count) then count=0'判断不是数字初始化为0
set fileop=file.opentextfile(server.mappath("text.txt"),2)'1只读,你要写回内容要用2,要不报错
count=count+1
fileop.write count
response.write count
fileop.close
%>

需要把 count转成字符串吧。比如 cstr(count)

<%
dim file,fileop
set file=server.createobject("scripting.filesystemobject")
set fileop=file.opentextfile(server.mappath("text.txt"),1,true)
count=fileop.readline()
fileop.close
if isnumeric(count) then
count=cint(count)
else'不是数字初始化为0
count=0
end if
set fileop=file.opentextfile(server.mappath("text.txt"),2)
count=count+1
fileop.write count
response.write count
fileop.close
%>

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632