Function Character Arrays Class

CharacterCountsToVariantVector

Fill the elements of an Integer array so that they each represent the number of occurrences of the character with that ASCII value in string vString.

Signature (Visual Basic / VBA)

Public Function CharacterCountsToVariantVector( _
      ByRef rCounts() As Variant _
    , ByVal vString As Variant _
    ) As Boolean

Code Example

    Assuming
       Dim avarCounts() As Variant
    for example
       CharacterCountsToVariantVector avarCounts(), "ABBCCC"
    leaves
       LBound(avarCounts) = 0
       UBound(avarCounts) = 255
       avarCounts(X) = 0
    except for
       avarCounts(Asc("A")) = avarCounts(65) = 1
       avarCounts(Asc("B")) = avarCounts(66) = 2
       avarCounts(Asc("C")) = avarCounts(67) = 3

Parameters

Parameter Description
rCounts The dynamic array of Variants in which the character counts will be stored.
vString The strings whose character counts are to be determined. Function returns False and leaves rCounts uninitialized if vString is Null or cannot be fixed up to a String. Function returns True upon success.