Function Co Decs Class

DeTab

"Expand Tabs To Spaces" Replaces tab characters (Chr$(9)) with the number of spaces required to advance the print position to the next tab stop. Function assumes that there is a tab stop every vTabWidth characters.

Signature (Visual Basic / VBA)

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

Code Example

    DeTab("12" + Chr$(9) + "345" + Chr$(9) + "6789") = "12      345     6789"
    DeTab("12" + Chr$(9) + "345" + Chr$(9) + "6789", 4) = "12  345 6789"
    DeTab("12 345 6789") = "12 345 6789"

Parameters

Parameter Description
vValue String whose tab characters are to be replaced by an appropriate number of space 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 after columns 8, 16, 24, 32, etc. vTabWidth is set to 1 (one) if it is less than 1 (one).

Notes & Version History

Note This function properly handles string containing carriage return and line feed characters. It assumes that carriage return characters reset the print position to column 1 (one) and that line feed characters have no effect upon the current print position.