欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

asp数组中去掉重复的,写入一个新的数组中解决思路

更新时间: 2014-01-05 01:52:58 责任编辑: Author_N1

 

ASP数组中去掉重复的,写入一个新的数组中
有一个数据里面的很多重复的数据,现要去掉重复的,写入一个新的数组 ,怎么写?
如:aa = Array("11","22","33","11","112233","33","22","44","44","11","ff","22","22","去")

--参考方法--
VBScript code

<%
aa = Array("11","22","33","11","112233","33","22","44","44","11","ff","22","22","去")
Set dic = CreateObject("Scripting.Dictionary")
For i=0 To UBound(aa)
    If Not dic.Exists("_" & aa(i)) Then
        dic.Add "_" & aa(i), aa(i)
    End If
Next
bb = dic.Items()
Set dic = Nothing

Response.Write Join(bb,",")

%>

--参考方法--
VBScript code
aa = Array("11","22","33","11","112233","33","22","44","44","11","ff","22","22","È¥")

k = -1
For i = 0 To UBound(aa)
    b = True
    For j = 0 To k
        If aa(i) = r(j) Then
            b = False
            Exit For
        End If
    Next
    If b Then
        k = k + 1
        ReDim Preserve r(k)
        r(k) = aa(i)
    End If
Next

s = Join(r, ",")

--参考方法--
VBScript code
aa = Array("11","22","33","11","112233","33","22","44","44","11","ff","22","22","去")
a = "," & Join(aa,",") & ","
For i = 0 To UBound(aa)
    b = "," & aa(i) & ","
    b2 = ",XXXX" & aa(i) & "XXXX,"
    a = Replace(a, b, b2 ,1,1)
    a = Replace(a, b, ",")
    a = Replace(a, b2, b)
Next 
Response.Write  Mid(a,2,Len(a)-2)

--参考方法--
LS思路不错,不过太不通用,对于XXXXYYXXXX之类的会无视。
VBScript code

On Error Resume Next
aa = Array("11","22","33","11","112233","33","22","44","44","11","ff","22","22","去")

Set oRecordSet = CreateObject("Adodb.RecordSet")
    With oRecordSet
        For Each item In aa
            .Fields.Append item,200,32
        Next
    End With
    
    
    For Each item In oRecordSet.Fields
        WScript.Echo item.Name
    Next
    
Set oRecordSet = Nothing 			
			
		
上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 01:52:58
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/2484/
本文WWW.DOC100.NET DOC100.NET版权所有。