Function File Names Class

UniquePathNamesVariantVector

Function converts the path names in an array to absolute path names them removes the duplicates. Function returns True upon success and False upon failure.

Signature (Visual Basic / VBA)

Public Function UniquePathNamesVariantVector( _
      ByRef rPaths() As Variant _
    , ByRef vPaths() As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Boolean

Code Example

    Assuming
       CurDir$ = "C:\Windows"
       Dim avarIn() As Variant
       ReDim avarIn(0 to 3)
       avarIn(1) = "C:\Temp"
       avarIn(2) = "System"  ' Relative to CurDir$
       avarIn(3) = "..\Temp" ' Same as avarIn(1)
       Dim avarOut() As Variant
    for example
       UniquePathNamesVariantVector(avarOut(), avarIn()) = True
    leaves
       LBound(avarOut) = 0
       UBound(avarOut) = 2
       IsEmpty(avarOut(0)) = True
       avarOut(1) = "C:\Temp"
       avarOut(2) = "C:\Windows\System"

Parameters

Parameter Description
rPaths Dynamic, one-dimensional array of Variants that will receive the unique, absolute path names. rPaths will be re-dimensioned from 0 (zero) to the upper bound of vPaths, and the path names are placed in elements 1 (one) through the upper bound.
vPaths One-dimensional array of Variants that contains the path names to be processed. Function examines elements 1 (one) through the upper bound of vPaths.
vCompare Type of string comparisons used to determine if absolute path names match. vCompare defaults to Text Comparisons (vbTextCompare) if it is missing or Null or cannot be fixed-up to a number.

Notes & Version History

v1.1 Change Function renamed from UniqueDirectoryVariantVector to UniquePathNamesVariantVector. Argument names were changed and the vCompare argument was added.