Function File Names Class

SeparateDriveAndPath

Separate a path name like "C: \WINDOWS\USER.EXE" into its Drive ("C:") and Path ("\WINDOWS\USER.EXE") components. Function returns True upon success and False upon failure.

Signature (Visual Basic / VBA)

Public Function SeparateDriveAndPath( _
      ByRef rDrive As Variant _
    , ByRef rPath As Variant _
    , ByVal vPath As Variant _
    ) As Boolean

Code Examples

    Assuming
       Dim strDrive As String
       Dim strPath As String
    for example
       SeparateDriveAndPath(strDrive, strPath, "\\SJS4\Entisoft\Tools") = True
    leaves
       strDrive = "\\SJS4\Entisoft"
       strPath = "\Tools"
    vPath                  rDrive           rPath
    ---------------------  ---------------  -------------
    C:\                    C:               \
    C:\Temp                C:               \Temp
    C:\Temp\Win.Tmp        C:               \Temp\Win.Tmp
    \\SJS4\C\Temp\Win.Tmp  \\SJS4\C         \Temp\Win.Tmp
    \\SJS4\Entisoft        \\SJS4\Entisoft
    \\SJS4\Entisoft\       \\SJS4\Entisoft  \
    \\SJS4\Entisoft\Tools  \\SJS4\Entisoft  \Tools

Parameters

Parameter Description
rDrive String or Variant that will receive the drive portion of vPath.
rPath String or Variant that will receive the path and file name portion of vPath.
vPath The path name that will be separated into its drive and directory/file name portions. If vPath is Null or cannot be fixed-up to a string, this function sets both rDrive and rPath to an empty string then returns False.