Function String Manipulations Class

StripRightNCharacters

Return the string vString with vNumChars characters removed from the right side of it.

Signature (Visual Basic / VBA)

Public Function StripRightNCharacters( _
      ByVal vString As Variant _
    , ByVal vNumChars As Variant _
    ) As Variant

Code Example

    StripRightNCharacters("123456789", 3) = "123456"
    StripRightNCharacters("123456789", 10) = ""
    StripRightNCharacters("123456789", -5) = "123456789"
    StripRightNCharacters(12345, 3) = "12"

Parameters

Parameter Description
vString The string whose right-most characters are to be removed. Function returns Null if vString is Null or cannot be fixed up to a String.
vNumChars The number of characters to be removed. Function returns Null if vNumChars is Null or cannot be fixed up to a number. Function returns vString unchanged if vNumChars is <= 0 (less than or equal to zero). Function returns an empty string if vNumChars is greater than length of the string vString.

Notes & Version History

Note Similar to the ShiftStringRight function, except negative values for vNumChars cause this function to return the entire string, and values of vNumChars greater than the length of vString cause this function to return an empty string.