S
State Troopers
Hi there,
I have a slight problem and cannot find where the "cause" of this problem
is. I am trying to remove duplicate values from an array. I have been trying
to use the dictionary way, but i am running in to problems.
Heres the code:
Dim strArray() As String
'ASSIGN VALUES TO ARRAY
If stDiff60 = 0 Then
strArray(intCount) = strDir
intCount = intCount + 1
rsMyRS.MoveNext
Else
rsMyRS.MoveNext
End If
removeDuplicates strArray
Private Sub removeDuplicates(ByRef arrName() As String)
Dim i As Long
Dim tempArr() As String
Dim d As New Dictionary
Dim n As Long
' This is the line where i get a "subscript out of range error
ReDim tempArr(0 To UBound(arrName))
For i = 0 To UBound(arrName)
If Not d.Exists(arrName(i)) Then
d.Add arrName(i), arrName(i)
tempArr(n) = arrName(i): n = n + 1
End If
Next
ReDim Preserve tempArr(n)
arrName = tempArr
End Sub
Thanks.
-State
I have a slight problem and cannot find where the "cause" of this problem
is. I am trying to remove duplicate values from an array. I have been trying
to use the dictionary way, but i am running in to problems.
Heres the code:
Dim strArray() As String
'ASSIGN VALUES TO ARRAY
If stDiff60 = 0 Then
strArray(intCount) = strDir
intCount = intCount + 1
rsMyRS.MoveNext
Else
rsMyRS.MoveNext
End If
removeDuplicates strArray
Private Sub removeDuplicates(ByRef arrName() As String)
Dim i As Long
Dim tempArr() As String
Dim d As New Dictionary
Dim n As Long
' This is the line where i get a "subscript out of range error
ReDim tempArr(0 To UBound(arrName))
For i = 0 To UBound(arrName)
If Not d.Exists(arrName(i)) Then
d.Add arrName(i), arrName(i)
tempArr(n) = arrName(i): n = n + 1
End If
Next
ReDim Preserve tempArr(n)
arrName = tempArr
End Sub
Thanks.
-State