Function String Searches Class

StringBetweenStrings

Return the string between the first occurrences of vRight and vLeft.

Signature (Visual Basic / VBA)

Public Function StringBetweenStrings( _
      ByVal vSearch As Variant _
    , ByVal vLeft As Variant _
    , ByVal vRight As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Code Example

    StringBetweenStrings("Forms![Menu]![Close]", "[", "]") = "Menu"
    StringBetweenStrings("Forms![Menu]![Close]", "(", ")") = "" ' #2.
    StringBetweenStrings("Larry 'Bud' Melman", "'", "'") = "Bud"

Parameters

Parameter Description
vSearch The string which is to be searched for the appearance of vLeft followed by vRight. Function returns Null if vSearch is Null or cannot be fixed up to a String.
vLeft The string which delimits the left side of the string to be returned. Function returns Null if vLeft is Null or cannot be fixed up to a String.
vRight The string which delimits the right side of the string to be returned. Function returns Null if vRight is Null or cannot be fixed up to a String.
vCompare Specifies the type of comparison used to determine if strings match. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number. Function returns an empty string if either vLeft or vRight is an empty string. Function returns an empty string if vLeft does not appear within vSearch followed by vRight as in example #2.