Function Co Decs Class

EnTabTable

"Compress Spaces To Tabs" Replaces sequences of space characters which overlap tab stop positions with tab characters (Chr$(9)) thereby reducing the space required to store strings which contain many spaces. Function assumes that there is a tab stop after every character position mentioned within array vTabStops.

Signature (Visual Basic / VBA)

Public Function EnTabTable( _
      ByVal vValue As Variant _
    , ByRef vTabStops() As Variant _
    ) As Variant

Code Example

    Assuming
       Dim avarTabs() As Variant
       ReDim avarTabs(0 to 5)
       avarTabs(1) = 8
       avarTabs(2) = 16
       avarTabs(3) = 24
       avarTabs(4) = 32
    for example
       EntabTable("12      345     6789", avarTabs()) = "12" + Chr$(9) + "345" + Chr$(9) + "6789"
       EntabTable("12 345 6789", avarTabs()) = "12 345 6789"

Parameters

Parameter Description
vValue String whose runs of space characters are to be selectively replaced with tab characters. Function returns Null if vValue is Null or cannot be fixed up to a String.
vTabStops One-dimensional array of Variants in which elements 1 (one) through UBound(vTabStops) each contain the number of column which is followed by a tab stop. Typical values for the elements of this array might be 8, 16, 24, 32, etc. With those example values, it could be said that there is a tab stop at columns 9, 17, 25, 33, etc.

Notes & Version History

Note This function will not replace individual space characters with a tab character if that space happens to fall on a tab stop; it will only replace runs of two or more spaces with a tab.