
Originally Posted by
plenderj
I still believe this to be the fastest method of removing duplicated items available in Classic VB.
You don't need to believe anymore: it isn't 
This one is faster with strings by 10 - 20%
VB Code:
Public Sub strArrRemoveDuplicate(ByRef StringArray() As String)
Dim LowBound As Long, UpBound As Long
Dim TempArray() As String, Cur As Long
Dim A As Long, B As Long
'check for empty array
If (Not StringArray) = True Then Exit Sub
'we need these often
LowBound = LBound(StringArray)
UpBound = UBound(StringArray)
'reserve check buffer
ReDim TempArray(LowBound To UpBound)
'set first item
Cur = LowBound
TempArray(Cur) = StringArray(LowBound)
'loop through all items
For A = LowBound + 1 To UpBound
'make a comparison against all items
For B = LowBound To Cur
'if is a duplicate, exit array
If LenB(TempArray(B)) = LenB(StringArray(A)) Then
If InStrB(1, StringArray(A), TempArray(B), vbBinaryCompare) = 1 Then Exit For
End If
Next B
'check if the loop was exited: add new item to check buffer if not
If B > Cur Then Cur = B: TempArray(Cur) = StringArray(A)
Next A
'fix size
ReDim Preserve TempArray(LowBound To Cur)
'copy
StringArray = TempArray
End Sub
This works for Byte, Integer and Long datatypes and is four to five times faster:
VB Code:
Public Sub bArrRemoveDuplicate(ByRef ByteArray() As Byte)
Dim LowBound As Long, UpBound As Long
Dim TempArray() As Byte, TempByte As Byte, Cur As Long
Dim A As Long, B As Long
'check for empty array
If (Not ByteArray) = True Then Exit Sub
'we need these often
LowBound = LBound(ByteArray)
UpBound = UBound(ByteArray)
'reserve check buffer
ReDim TempArray(LowBound To UpBound)
'set first item
Cur = LowBound
TempArray(Cur) = ByteArray(LowBound)
'loop through all items
For A = LowBound + 1 To UpBound
TempByte = ByteArray(A)
'make a comparison against all items
For B = LowBound To Cur
'if is a duplicate, exit array
If (TempArray(B) Xor TempByte) = 0 Then Exit For
Next B
'check if the loop was exited: add new item to check buffer if not
If B > Cur Then Cur = B: TempArray(Cur) = ByteArray(A)
Next A
'fix size
ReDim Preserve TempArray(LowBound To Cur)
'copy
ByteArray = TempArray
End Sub
To convert it to use Long for example, just use VB's inbuilt replace from the edit menu and make it convert Byte to Long. And rename the function, of course 
What is the best thing with these functions: you don't need to add any extra reference to your project!