Function Character Arrays Class

KeepRangeOfCharacters

Returns the characters in string vValue whose ASCII values fall within the specific range.

Signature (Visual Basic / VBA)

Public Function KeepRangeOfCharacters( _
      ByVal vValue As Variant _
    , ByVal vFromAsc As Variant _
    , ByVal vThruAsc As Variant _
    ) As Variant

Code Example

    KeepRangeOfCharacters("123 ABC 123", 0, 64) = "123 123"
    KeepRangeOfCharacters("123 ABC 123", Chr$(0), "@") = "123 123"

Parameters

Parameter Description
vValue String containing the characters which will be copied to the result string only if their ASCII value is within the specified range. Function returns Null if vValue is Null or cannot be fixed up to a String.
vFromAsc String character or numeric ASCII value describing the lower bound of the range of characters to be copied to the result string. Note: Special argument fix-up code. If vFromAsc is an empty string, then vValue is returned unchanged. If vFromAsc is a non-empty string, then the ASCII value of its first character is used as the lower bound. If vFromAsc is numeric (and not a numeric string), then that ASCII value will be used as the lower bound. Function returns vValue unchanged if vFromAsc is not string nor numeric.
vThruAsc String character or numeric ASCII value describing the upper bound of the range of characters to be copied to the result string. Note: Special argument fix-up code. If vThruAsc is an empty string, then vValue is returned unchanged. If vThruAsc is a non-empty string, then the ASCII value of its first character is used as the upper bound. If vThruAsc is numeric (and not a numeric string), then that ASCII value will be used as the upper bound. Function returns vValue unchanged if vThruAsc is not string nor numeric. Function returns vValue unchanged if vFromAsc is greater than vThruAsc.

Notes & Version History

Note Function uses the ASCII value of characters to determine if they fall within the range, which is in effect the same as using Binary comparisons.