Function Co Decs Class

EnTab

"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 every vTabWidth characters.

Signature (Visual Basic / VBA)

Public Function EnTab( _
      ByVal vValue As Variant _
    , Optional ByVal vTabWidth As Variant _
    ) As Variant

Code Example

    EnTab("12      345     6789") = "12" + Chr$(9) + "345" + Chr$(9) + "6789"
    EnTab("12  345 6789", 4) = "12" + Chr$(9) + "345 6789"
    EnTab("12 345 6789") = "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.
vTabWidth The number of positions between each tab stop. vTabWidth defaults to 8 (eight) if it is missing or Null or cannot be fixed up to a String. If vTabWidth is 8 (eight) for example, there will be a tab stop before columns 9, 17, 25, 33, etc. vTabWidth is set to 1 (one) if it is less than 1 (one).

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.