Sub String Manipulations Class

StrIns

"String Insert" Insert one string into the middle of another string. vSource is inserted into vDest before character position vInsertPosition. Similar to the InsertString function, except that this is a Subroutine which modifies its first argument instead of returning a value.

Signature (Visual Basic / VBA)

Public Sub StrIns( _
      ByRef rDest As Variant _
    , ByVal vSource As Variant _
    , Optional ByVal vInsertPosition As Variant _
    )

Code Example

    Assuming
       Dim S As String
       S = "ABCDEF"
    for example
       StrIns S, "GHI", 4
    leaves
       S = "ABCGHIDEF"

Parameters

Parameter Description
rDest The string into which vSource is to be inserted. rDest defaults to an empty string if it is Null or cannot be fixed up to a String.
vSource The string which is to be inserted into rDest. vSource defaults to an empty string if it is Null or cannot be fixed up to a String.
vInsertPosition The character position within vDest before which vSource will be inserted. vInsertPosition defaults to 1 (one) if it is missing or Null or cannot be fixed up to a number. vSource is inserted at the beginning of vDest if vInsertPosition is < 1 (less than one). vSource is inserted after the end of vDest if vInsertPosition is greater than the length of vDest.

Notes & Version History

Details Subroutine does nothing if both strings (vDest and vSource) are Null.