Function String Manipulations Class

TruncateLeftWithEllipse

Truncate/remove the left part of the string vLine if it is longer than vMaxLen, If the string is truncated, replace the leading characters with "..." to indicate the removal.

Signature (Visual Basic / VBA)

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

Code Example

    TruncateLeftWithEllipse("This is a test.", 20) = "This is a test."
    TruncateLeftWithEllipse("This is a test.", 11) = "... a test."
    TruncateLeftWithEllipse("This is another test.", 11) = "... test."

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.