CorString: TrimEnd |
Removes all trailing occurrences of a set of characters specified in an array from the s parameter.
Public Function TrimEnd( ByRef s As String, Optional ByRef TrimChars As Variant ) As String
TrimChars can be either a String or an Integer(). If a String is passed in it will be treated as an Integer() and each character will be used separately.
The TrimEnd method removes from s all trailing characters that are in the TrimChars parameter. The trim operation stops when a character that is not in TrimChars is encountered. For example, if s is "123abc456xyz789" and TrimChars contains the digits from "1" through "9", the TrimEnd method returns "123abc456xyz".
Note |
---|
This method does not modify the s parameter. Instead, it returns a new string in which all trailing white-space characters found in s are removed. |
Exception | Condition |
---|---|
ArgumentException | TrimChars was not a String or Integer(). |
The following example demonstrates trimming the trailing characters defined by a String and an Integer().
Public Sub Main() Const Digits As String = "0123456789" Const Str As String = "324357abcx987234" Dim DigitChars() As Integer DigitChars = CorString.ToCharArray(Digits) Debug.Print CorString.TrimEnd(Str, Digits) Debug.Print CorString.TrimEnd(Str, DigitChars) End Sub ' The previous code outputs the following. ' ' 324357abcx ' 324357abcx