Function String Extras Class

StringSimilarity

Returns a percentage characterizing the similarity of the two phrases based upon the number characters which they have in common.

Signature (Visual Basic / VBA)

Public Function StringSimilarity( _
      ByVal vPhraseOne As Variant _
    , ByVal vPhraseTwo As Variant _
    ) As Variant

Code Example

    StringSimilarity("This is a test.", "THIS IS A SAMPLE.") = 81
    StringSimilarity(Gettysburg, Mayflower) = 83
    StringSimilarity("Entisoft", "Tools") = 46

Parameters

Parameter Description
vPhraseOne First of two phrases which are to be compared to determine their similarity. Function returns Null if vPhraseOne is Null or cannot be fixed up to a String.
vPhraseTwo Second of two phrases which are to be compared to determine their similarity. Function returns Null if vPhraseTwo is Null or cannot be fixed up to a String.

Notes & Version History

Note Strings are first converted to upper-case so that, in effect, this function uses Text comparisons to determine if characters match.