Tab (function)




Prints the number of spaces necessary to reach a given column position.


This function can only be used with the Print and Print# statements.

The column parameter is an Integer specifying the desired column position to which to advance. It can be any value between 0 and 32767 inclusive.

Rule 1: If the current print position is less than or equal to column, then the number of spaces is calculated as:

  column – print_position


Rule 2: If the current print position is greater than column, then column – 1 spaces are printed on the next line.

If a line width is specified (using the Width statement), then the column position is adjusted as follows before applying the above two rules:

  column = column Mod width

The Tab function is useful for making sure that output begins at a given column position, regardless of the length of the data already printed on that line.


This example prints three column headers and three numbers aligned below the column headers.

Sub Main()
  Print "Column1";Tab(10);"Column2";Tab(20);"Column3"
  Print Tab(3);"1";Tab(14);"2";Tab(24);"3"
  Sleep(10000)    'Wait 10 seconds.
End Sub

See Also

Spc (function); Print (statement); Print# (statement).

More information