Function String Manipulations Class

MidReverse

"Middle String Reverse" Similar to the Visual Basic Mid function, except that the returned string is constructed by moving backwards through vString instead of forwards.

Signature (Visual Basic / VBA)

Public Function MidReverse( _
      ByVal vString As Variant _
    , ByVal vPos As Variant _
    , Optional ByVal vLength As Variant _
    ) As Variant

Code Example

       MidReverse("123456789", 4) = MidReverse("123456789", 4, 4) = "4321" ' #1
       MidReverse("123456789", 6, 4) = "6543"
    whereas
       Mid$("123456789", 6, 4) = "6789"

Parameters

Parameter Description
vString The string from which a portion is to be extracted. Function returns Null if vString is Null or cannot be fixed up to a String.
vPos The starting character position within vString. vPos defaults to the last position within vString if it is Null or cannot be fixed up to a number. Function returns an empty string if vPos is <= 0 (less than or equal to zero). Function returns an empty string if vPos is beyond the end of vString.
vLength The number of characters which are to be extracted from vString. vLength defaults to the starting position (vPos) if it is missing or Null or cannot be fixed up to a number, as in example #1. Function returns an empty string if vLength is <= 0 (less than or equal to zero). vLength defaults to the starting position (vPos) if it is greater than vPos.