Function Character Types Class

CapitalizeLike

Capitalize vString according to how corresponding characters in vPattern are capitalized.

Signature (Visual Basic / VBA)

Public Function CapitalizeLike( _
      ByVal vString As Variant _
    , ByVal vPattern As Variant _
    ) As Variant

Code Example

    CapitalizeLike("attaboy", "AbCdEfGhIj") = "AtTaBoY"
    CapitalizeLike("attaboy", "ABCD") = "ATTAboy"
    CapitalizeLike("attaboy", "ABC123ABC") = "ATTaboY"
    CapitalizeLike("ATTABOY", "abc123abc") = "attABOy"

Parameters

Parameter Description
vString The string whose capitalization is to be changed to correspond to that of vPattern. Function returns Null if vString is Null or cannot be fixed up to a String.
vPattern The string whose capitalization is to be mimicked within the other string. Function returns Null if vPattern is Null or cannot be fixed up to a String.

Notes & Version History

Note Function only works for characters in the ANSI Windows character set because it uses the built-in Visual Basic UCase$() and LCase$() functions.
Note If the string vString is longer than the pattern, then the characters in vString positions beyond the length of the pattern remain unchanged, as in example #2.