在Collection怎样删除重复的项呢?这个算法一直没有想出来啊
谢谢

解决方案 »

  1.   

    dim i as integer
    dim j as integerfor i=lbound(str) to ubound(str)
       for j=Lbound(str)+1 to ubound(str)
            if str(i+j)=str(i) then
                str(i+j)=0
            end if
       next
    next给个数组的比较算法,不知道效率如何,召唤高效率比较算法~~~
      

  2.   

    优化一下
    dim i as integer
    dim j as integerfor i=0 to ubound(str)
       for j=i to ubound(str)
            if str(i+j)=str(i) then
                str(i+j)=0
            end if
       next
    next
      

  3.   

    很简单的啊,遍历比较就行了
    Dim col As New Collection
    col.Add 1
    col.Add 2
    col.Add 1Dim i As Integer, j As Integer, ColContext As String
    For i = 1 To col.Count
    ColContext = ColContext & " " & i & ":" & col.Item(i)
    Next i
    MsgBox ColContext
    For i = 1 To col.Count
      For j = i + 1 To col.Count
     If col.Item(i) = col.Item(j) Then
       col.Remove (j)
    End If
    Next j
       Next i
       
       
       ColContext = ""
       For i = 1 To col.Count
    ColContext = ColContext & " " & i & ":" & col.Item(i)
    Next i
    MsgBox ColContext