Signature (Visual Basic / VBA)
Public Function StringsBetweenStrings( _
ByVal vSearch As Variant _
, ByVal vLeft As Variant _
, ByVal vRight As Variant _
, Optional ByVal vSeparator As Variant _
, Optional ByVal vCompare As Variant _
) As Variant
Code Example
StringsBetweenStrings("Forms![Menu]![Close]", "[", "]", "-") = "Menu-Close"
StringsBetweenStrings("Forms![Menu]![Close]", "(", ")", "-") = "" ' #2.
StringsBetweenStrings("Larry 'Bud' Melman", "'", "'", "-") = "Bud"
Parameters
| Parameter | Description |
|---|---|
| vSearch | The string which is to be searched for non-overlapping appearances 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 each sub-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 each sub-string to be returned. Function returns Null if vRight is Null or cannot be fixed up to a String. |
| vSeparator | The string which will be used to separate the matching strings within the result. Function returns Null if vSeparator 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 both vLeft or vRight is an empty string. If vLeft is an empty string and vRight is not, the function returns the sub-string of vSearch between the beginning of the string and the first occurrence of vRight. If vRight is an empty string and vLeft is not, the function returns the sub-string of vSearch between the first occurrence of vLeft and the end of the string. Function returns an empty string if vLeft does not appear within vSearch followed by vRight. |