Function String Extras Class

WriteCodeBlock

Creates a block of text by substituting each of a series of alphanumeric keywords into a "template."

Signature (Visual Basic / VBA)

Public Function WriteCodeBlock( _
      ByVal vTemplate As Variant _
    , ByVal vKeywords As Variant _
    ) As Variant

Code Examples

    ? WriteCodeBlock("Print \% \\ 40 ' \Div.", "XPos")
    Print XPos \ 40 ' Div.
    ? WriteCodeBlock("Dim \% As Integer\n", "XPos YPos")
    Dim XPos As Integer
    Dim YPos As Integer
    ? WriteCodeBlock("Property Get \%() As Integer\n   \% = g\%\nEnd Property\n\n", ClipboardToString)
    \n   Replaced by carriage return and new line characters.
    \\   Replaced by a single slash character.
    \%   Replaced by the current keyword.

Parameters

Parameter Description
vTemplate String containing the "template" or "boilerplate" text which is to be repeated for each keyword in vKeywords. Function returns Null if vTemplate is Null or cannot be fixed up to a String.
vKeywords String containing the alphanumeric keywords which are each to be substituted into the "template" as the appropriate place. Function returns Null if vKeywords is Null or cannot be fixed up to a String.

Notes & Version History

Note Within the template string, certain character sequences have special meanings: Any other pair of characters which begins with a slash will have the slash character removed.