用函数处理多个数组合并的问题

gdmm 2005-03-28 01:42:33
Str1 = "0,4,5,6,,9,10"
Str2 = "1,2,5,6,,9,10"
Str3 = "1,2,5,7,,9,10"

如果Str1,Str2,Str3组成新的数组,切去掉里面重复的值,
并按大小排列,那位兄弟手里有这个函数啊!

...全文
165 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
gdmm 2005-03-28
  • 打赏
  • 举报
回复
还是不成!
yongz_0 2005-03-28
  • 打赏
  • 举报
回复
信 誉 值: 45
yongz_0 2005-03-28
  • 打赏
  • 举报
回复
<%
Str1 = "0,4,5,6,,9,10"
Str2 = "1,2,5,6,,9,10"
Str3 = "1,2,5,7,,9,10"
str=str1&","&str2&","&str3
a=split(str,",")
b=ubound(a)
for i=0 to b
c=0
for j=0 to b
if a(i)=a(j) then
c=c+1
if c>1 then a(j)=""
end if
next
next
str4=""
for k=0 to ubound(a)
if a(k)<>"" then
str5=str5&a(k)&","
end if
str4=str4&a(k)&","
next
str5=left(str5,len(str5)-1)
str4=left(str4,len(str4)-1)
response.write str&"<br>"&str4&"<br>"&str5
%>

gdmm 2005-03-28
  • 打赏
  • 举报
回复
大家加油啊!我的也不成啊!
rockko 2005-03-28
  • 打赏
  • 举报
回复
难道全部数组里面都是小于10的数值?
gdmm 2005-03-28
  • 打赏
  • 举报
回复
<%
'*** build example array to show that this thing can sort
'*** alpha-numeric arrays
Dim MyArray
MyArray = Array(1,5,"shawn","says","hello",123,12,98,97)
MyArray = SortStr(MyArray)
For I = 0 to Ubound(MyArray)
Response.Write MyArray(I) & "" & vbCRLF
Next
Response.End


'*** Sorter Function that takes an array and sorts it
Function SortStr(ary)
KeepChecking = TRUE
Do Until KeepChecking = FALSE
KeepChecking = FALSE
For I = 0 to UBound(ary)
If I = UBound(ary) Then Exit For
If ary(I) > ary(I+1) Then
FirstValue = ary(I)
SecondValue = ary(I+1)
ary(I) = SecondValue
ary(I+1) = FirstValue
KeepChecking = TRUE
End If
Next
Loop
SortStr = ary
End Function
%>

我自己的方法!
hbhbhbhbhb1021 2005-03-28
  • 打赏
  • 举报
回复
还是不对
dim a
dim c
c="," & str1 & "," & str2 & "," & str3 & ","
dim d '象楼上那样会名称重定义的,呵呵
for i=1 to 10
d="," & i & ","
if instr(1,c,d)
a=a & i & ","
end if
next
dim strb
strb=left(a,len(a)-1)
hbhbhbhbhb1021 2005-03-28
  • 打赏
  • 举报
回复
sorry!少打了一句
dim a
dim c
c="," & str1 & "," & str2 & "," & str3 & ","
for i=1 to 10
dim d
d="," & i & ","
if instr(1,c,d)
a=a & i & ","
end if
next
dim strb
strb=left(a,len(a)-1)
hbhbhbhbhb1021 2005-03-28
  • 打赏
  • 举报
回复
如果只有你这几个数的话到是可以用instr
dim a
for i=1 to 10
if instr(1,str1,cstr(i))
a=a & i & ","
end if
next
dim strb
strb=left(a,len(a)-1)

28,406

社区成员

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

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