编程论坛
注册
登录
编程论坛
→
ASP技术论坛
循环得到的数组问题
35maoe
发布于 2008-05-31 09:56, 710 次点击
一个多选的变量i得到结果如下;
i=1,2,3,,5,6,,8
说明第4和第7个没选中。
用哪个函数可以将i结果变为;
i=1,2,3,5,6,8
不知表达的对不对,对这些不是太了解,请帮忙,谢谢!!
9 回复
#2
35maoe
2008-05-31 10:42
请帮忙,谢谢,急事...
#3
madpbpl
2008-05-31 12:35
<%
i="1,2,3,,5,6,,8"
i=Replace(i,",,",",")
Response.Write(i)
%>
#4
35maoe
2008-05-31 13:47
如果是多个呢,并不一定是两个啊,
#5
madpbpl
2008-05-31 14:05
<%
i="1,2,3,,5,6,,,9,,11,,,,15"
for n=1 to len(i)
if instr(i,",,") then
i=Replace(i,",,",",")
end if
next
Response.Write(i)
%>
#6
35maoe
2008-05-31 14:19
哈哈,谢谢楼上的,这样可以了
如果左边或右边的第一个字符是,号
要把他替换成空怎么写啊..
谢谢madpbpl,这个再解决就OK了
#7
35maoe
2008-05-31 14:29
好了,晕,刚才中间有个空格,现在可以了,谢谢..
#8
multiple1902
2008-05-31 14:37
while instr(str,",,")
str=replace(st,",,",",")
wend
if left(str,1)="," then str=right(str,len(str)-1)
#9
35maoe
2008-05-31 14:43
[bo][un]multiple1902[/un] 在 2008-5-31 14:37 的发言:[/bo]
while instr(str,",,")
str=replace(st,",,",",")
wend
if left(str,1)="," then str=right(str,len(str)-1)
谢谢multiple1902..你这方法好..
#10
yms123
2008-05-31 23:24
Dim Str,tStr,TAry,i
Str="1,2,3,,5,6,,8"
tStr=Replace(Str,",,",",Null,")
TAry=Split(tStr,",")
For i=0 To UBound(TAry)
IF TAry(i)=="Null" Then
Response.Write "第"&i&"道题没有选中"
End IF
Next
1