Function String Manipulations Class

OverlayString

Overlays the string vFm on top of string vTo at an offset of vOffset. Any portion of vFm which, when overlaid onto vTo at an offset of vOffset, would be before the beginning of vTo or past its end is ignored/truncated.

Signature (Visual Basic / VBA)

Public Function OverlayString( _
      ByVal vTo As Variant _
    , ByVal vFm As Variant _
    , Optional ByVal vOffset As Variant _
    ) As Variant

Code Example

    OverlayString("123456789", "ABC", 4) = "123ABC789"
    OverlayString("123456789", "ABC", -2) = "C23456789"
    OverlayString("123456789", "ABC", 8) = "12345678A"

Parameters

Parameter Description
vTo The string onto which vFm is to be overlaid. Function returns Null if vTo is Null or cannot be fixed up to a String.
vFm The string which is to be overlaid onto vTo. Function returns Null if vFm is Null or cannot be fixed up to a String.
vOffset The starting character position with vTo at which vFm is to be overlaid. vOffset defaults to 0 (zero) if it is missing or Null or cannot be fixed up to a number.

Notes & Version History

Note vOffset is an offset which is one less than what the starting position would be.