日期:2014-05-16 浏览次数:20848 次
arra="15,19,210,22,45,6,55"
arrb="368,111,20,501,22,66,90,55,10"
'比较2个 相同的数字就清除掉 就是把不同的列出 ,区分的格式 用数组也行
'要的结果是: 15,19,210,45,6,368,111,20,501,66,90,10
2个变量里都出现过的话 清除掉
<%
arra = "15,19,210,22,45,6,55"
arrb = "368,111,20,501,22,66,90,55,10"
arra = Split(arra, ",")
arrb = Split(arrb, ",")
Set dic = CreateObject("Scripting.Dictionary")
For i = 0 To UBound(arra)
If dic.Exists(arra(i)) Then
dic.Remove arra(i)
Else
dic.Add arra(i), arra(i)
End If
Next
For i = 0 To UBound(arrb)
If dic.Exists(arrb(i)) Then
dic.Remove arrb(i)
Else
dic.Add arrb(i), arrb(i)
End If
Next
arr = dic.Items
Set dic = Nothing
Response.Write Join(arr, ",")
%>
<%
dim a,b,ar,d,i
a = "15,19,210,22,45,6,55"
b = "368,111,20,501,22,66,90,55,10"
ar = split(a & "," & b, ",")
set d = CreateObject("Scripting.Dictionary")
For i = 0 to UBound(ar)
If d.exists(ar(i)) Then
d.remove ar(i)
Else
d.add ar(i), ar(i)
End If
Next
ar = d.items
set d = nothing
response.write join(ar, ",")
%>
dim arra,arrb,arr,str,i
arra = "15,19,210,22,45,6,55"
arrb = "368,111,20,501,22,66,90,55,10"
arr = Split(arra,",") '转成数组
arra = ","&arra&","
str = ","&arrb&","
For i=0 To UBound(arr)
If InStr(str,","&arr(i)&",")<>0 Then
str = Replace(str,","&arr(i)&",",",")
arra = Replace(arra,","&arr(i)&",",",")
End If
Next
Response.write Replace(arra&str,",,",",") '前后的,自行处理