Function String Manipulations Class

DifferenceString

Returns a string with different characters describing the matching and non-matching portions of the two strings. The character at a specific position within the returned string describes whether characters at the same corresponding positions within vStringOne and vStringTwo match each other.

Signature (Visual Basic / VBA)

Public Function DifferenceString( _
      ByVal vStringOne As Variant _
    , ByVal vStringTwo As Variant _
    , Optional ByVal vCompare As Variant _
    , Optional ByVal vIfSame As Variant _
    , Optional ByVal vIfDiff As Variant _
    ) As Variant

Code Example

    DifferenceString("ABCDEF", "123DEF", vbBinaryCompare, "|", " ") = "   |||"

Parameters

Parameter Description
vStringOne One of the strings which is to be compared and contrasted with the other. Function returns Null if vStringOne is Null or cannot be fixed up to a String.
vStringTwo One of the strings which is to be compared and contrasted with the other. Function returns Null if vStringTwo is Null or cannot be fixed up to a String.
vCompare specifies the type of string comparison used to determine whether corresponding characters match. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number.
vIfSame Character used to indicate that the corresponding characters match. Note: Special argument fix-up code. If vIfSame is an empty string, then matches are indicated with a space (" ") character. If vIfSame is a non-empty string, then matches are indicated using its first character. If vIfSame is numeric (and not a numeric string), then matches are indicated using the character with the specified ASCII value. If vIfSame is missing or Null then matches are indicated with a space (" ") character.
vIfDiff Character used to indicate that the corresponding characters do NOT match. Note: Special argument fix-up code. If vIfDiff is an empty string, then non-matches are indicated with a space (" ") character. If vIfDiff is a non-empty string, then non-matches are indicated using its first character. If vIfDiff is numeric (and not a numeric string), then non-matches are indicated using the character with the specified ASCII value. If vIfDiff is missing or Null then non-matches are indicated with a space (" ") character.