请问如何解决以下bug???

life360 2004-11-16 10:55:40
A:----------------------------------
<%
ab = "1,21,3"
a = 2
If instr(ab, a) Then
Response.Write("存在")
Else
Response.Write("不存在")
End If
%>
<br><br><br>
B:----------------------------------
<%
ab = "21,34,5,6,72,8"
aa="4,"
if instr(","&ab&",",aa)=0 then
Response.Write("不存在")
else
Response.Write("存在")
end if
%>
<br><br><br>
C:----------------------------------

<%
ab="1,21,31,4"
a="3"
if instr(1,ab,a)>0 then
response.write "存在"
else
response.write "不存在"
end if
%>

以上的结果是

A:---------------------------------- 存在


B:---------------------------------- 存在


C:---------------------------------- 存在

但实际是错误的。
A: 必须 a=21 才能提示存在

B: 必须 aa="34,"才能提示存在

C: 必须 a="31" 才能提示存在

以上怎么改了,这是我原来的问题那些人回答都存在bug 的
原来问题
http://community.csdn.net/Expert/topic/3514/3514817.xml?temp=.9959986
http://community.csdn.net/Expert/topic/3514/3514679.xml?temp=1.833743E-02
http://community.csdn.net/Expert/topic/3513/3513881.xml?temp=.8307154
...全文
151 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
meizz 2004-11-16
  • 打赏
  • 举报
回复
这个问题用正则表达式解决最为简便
yjbnew 2004-11-16
  • 打赏
  • 举报
回复
斑竹呢?
yjbnew 2004-11-16
  • 打赏
  • 举报
回复
真奇怪,已经结了,怎么没出现结帖的字呢。分数都没有显示,但管理那里有的
一个大BUG,太奇怪了!
life360 2004-11-16
  • 打赏
  • 举报
回复
真奇怪,已经结了,怎么没出现结帖的字呢。分数都没有显示,但管理那里有的
alianasia 2004-11-16
  • 打赏
  • 举报
回复
用你的方法判断,程序把你的比较全当做字符来比较了。

肯定会提示存在的,

A.要把它转成数字来进行比较。
tarray=split(ab,",")
for i=0 to ubound(tarray)
if a=Cint(tarray(i)) then
Response.write "存在"
end if
B.在A的基础上判断是不是最后一个就可以了。如果是就不存在

C.
 tarray=split(ab,",")
for i=0 to ubound(tarray)
if a=Cstr(tarray(i)) then
Response.write "存在"
end if

可以了。
stefli 2004-11-16
  • 打赏
  • 举报
回复
加上逗号判断
----------------------------------
1,21,3
2
所以存在

----------------------------------
,21,34,5,6,72,8,
4,
改进后
,21,34,5,6,72,8,
,4,
不存在

----------------------------------

1,21,31,4
3
改进后
,1,21,31,4,
,3,
不存在
life360 2004-11-16
  • 打赏
  • 举报
回复
baby97(雏雕已变成小雕) 已经变成反过来判断了
银狐被占用 2004-11-16
  • 打赏
  • 举报
回复
楼主你这几个问题的结果就是你列出来的那些。

这几个问题好解决。
楼主不就是想实现CHECKBOX的选中吗?!

以下面这个为例:
<%
ab = "1,21,3"
a = 2
str = split(ab,",")
for i = 0 to ubound(str)
If instr(str(i), a) Then
Response.Write("存在")
Else
Response.Write("不存在")
End If
next
%>
如果这样再不行的话再想办法。
yjbnew 2004-11-16
  • 打赏
  • 举报
回复
这个才是正解
yjbnew 2004-11-16
  • 打赏
  • 举报
回复
自己作个函数就可以了:
function isexists(a,ab)
isexists=false
dim i,tarray
tarray=split(ab,",")
for i=0 to ubound(tarray)
if a=tarray(i) then
isexists=true
exit function
end if
next
end function
OnlyVB 2004-11-16
  • 打赏
  • 举报
回复
instr("," & Str & "," & ,"," & Find_Str & ",")
awaysrain 2004-11-16
  • 打赏
  • 举报
回复
<%
ab="1,21,31,4"
a="3"
if instr(1,"," & ab & ",", "," & a & ",")>0 then
response.write "存在"
else
response.write "不存在"
end if
%>
life360 2004-11-16
  • 打赏
  • 举报
回复
是判断数值是否存在 ab 里面 是等于里面的一个数值。
life360 2004-11-16
  • 打赏
  • 举报
回复
楼上的,都没看问题,晕!!!!!!!!
guoweidong 2004-11-16
  • 打赏
  • 举报
回复
if len(a)<>2 then
response.write "不存在!"
end if
if len(aa)<>3 then
response.write "不存在!"
end if

alern_zyb 2004-11-16
  • 打赏
  • 举报
回复
判断有问题
If instr(ab, a)=0 Then 不存在
或者存在

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧