VBSCRIPT数组问题?

Ryancode 2004-04-02 04:52:12
我数组里有很多相同的值, 我想把这些相同的值变唯一


比如

(中国,中国,中国,英国,英国)-> (中国,英国)

先谢谢了!
...全文
54 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
若白师妹 2004-04-02
  • 打赏
  • 举报
回复
sorry,上面的不完整,要是str="中國,中國,中國,美國,美國,美國,英國,英國,英國,中國,中國"就會出現 中國,美國,英國,中國,
這個對了
<%
str="中國,中國,中國,美國,美國,美國,英國,英國,英國,中國,中國"
tmp=split(str,",")
str1=""
for i=0 to ubound(tmp)
if instr(str1,tmp(i))=0 then
str1=str1&tmp(i)&","
end if
next
response.write str1%>
jinhaiou 2004-04-02
  • 打赏
  • 举报
回复
用替代涵数循环
若白师妹 2004-04-02
  • 打赏
  • 举报
回复
先把數組拆,然後比較重組
<%
str="中国,中国,中国,英国,英国"
tmp=split(str,",")
tmp1=""
for i=0 to ubound(tmp)
if tmp(i)<>tmp1 then
str1=str1&tmp(i)&","
end if
tmp1=tmp(i)
next
response.write str1%>

28,409

社区成员

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

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