Tab Function

See Also37U0GX5              ExampleGUAT6M>Low

Used with the Print # statement and the Print method to move the position at which the next character is printed.

Syntax

Tab(column)

Remarks

This function can be used only with the Print # statement or the Print method.

The argument column is an integer expression that is the column number of the new print position.

The leftmost print position on an output line is always 1.  When you use the Print # statement to print to files, the rightmost print position is the current width of the output file, which you can set using the Width # statement.

When you use Tab on a line with other arguments to either the Print # statement or the Print method and you place no separator (a semicolon or comma) after it, a semicolon (;) is assumed except when Tab appears at the end of a line.

When used with forms and files, Tab behaves in the following way:

         If the current print position on the current line is greater than column, Tab skips to column on the next output line.

         If column is less than 1, Tab moves the print position to column 1.

 

When used with files only, Tab displays the following behavior:

         If column is greater than the output-line width, Tab calculates
printposition = column Mod width

         If the column is less than the current print position, printing begins on the next line at the calculated print position.  If the calculated print position is greater than the current print position, printing begins at the calculated print position on the same line.

 

When you use the Tab function with the Print method, the print surface is divided into uniform, fixed-width columns.  The width of each column is an average of the width of all characters in the point size95MO9S3 for the chosen font.  However, there is no correlation between the number of characters printed and the number of fixed-width columns those characters occupy.  For example, the uppercase letter W occupies more than one fixed-width column and the lowercase letter I occupies less.  Make sure your tabular columns are wide enough to accommodate wider letters.


See Also

Print # Statement12JHDL9

Space, Space$ Function3TBE7D

Spc FunctionLANSPC

Width # StatementQ6GH4W


Tab Function Example

The example uses the Tab function to move the print position to column 40 in an output data file.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

 

Sub Form_Click ()

   Dim Msg                               ' Declare variable.

   Open "TESTFILE" For Output As #1      ' Create sample data file.

   Print #1, "This is a test of the "; Tab(40); "Tab function."

   Close #1                              ' Close file.

   Open "TESTFILE" For Input As #1       ' Reopen the file for input.

   Input #1, Msg                         ' Read the data.

   Close #1                              ' Close file.

   MsgBox Msg                            ' Display file contents.

   Kill "TESTFILE"                       ' Remove file from disk.

End Sub