Function String Manipulations Class

MidString

"Middle String" Like the Visual Basic Mid function, except that the vStart can be negative.

Signature (Visual Basic / VBA)

Public Function MidString( _
      ByVal vString As Variant _
    , Optional ByVal vStart As Variant _
    , Optional ByVal vLength As Variant _
    ) As Variant

Code Example

       MidString("123456789", -1, 5) = "123"
    which is the same as
       Mid("123456789", 1, 3)

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.
vStart The starting character position within vString. vStart defaults to 1 (one) if it is missing or Null or cannot be fixed up to a number.
vLength The number of characters which are to be extracted from vString. Function returns the portion of vString from position vStart through the end of the string when vLength is missing or Null or cannot be fixed up to a number.