Function String Manipulations Class

TruncateRightWithEllipse

Truncate the left of a string if it is longer than MaxLen, If the string is truncated, replace the leading characters with "..." to indicate the removal.

Signature (Visual Basic / VBA)

Public Function TruncateRightWithEllipse( _
      ByVal vLine As Variant _
    , ByVal vMaxLen As Variant _
    ) As Variant

Code Example

    TruncateRightWithEllipse("This is a test.", 20) = "This is a test."
    TruncateRightWithEllipse("This is a test.", 11) = "This is ..."
    TruncateRightWithEllipse("This is a test.", 10) = "This ..."

Parameters

Parameter Description
vLine The string value which is a candidate for truncation. Function returns Null if vLine is Null or cannot be fixed up to a String.
vMaxLen The maximum length of the string, above which size the string vLine will be truncated. Function returns Null if vMaxLen if Null or cannot be fixed up to a number. Function returns an empty string if vMaxLen is <= 0 (less than or equal to zero). Fully remove any partial word which would be left where the oversized part of the string is truncated.