Displaying Different Items on a Single Line

See Also

The items you display or print can include property values, constants, and variables (either string or numeric). The Print method, discussed in "Displaying Text on Forms and Picture Boxes," prints the value of numeric items. Positive number values have a leading and a trailing space. Negative numeric values display their sign instead of a leading space.

Use a semicolon (;) or a comma (,) to separate one item from the next. If you use a semicolon, Visual Basic prints one item after another, without intervening spaces. If you use a comma, Visual Basic skips to the next tab column.

For example, the following statement prints to the current form:

Print "The value of X is "; X; "and the value of Y _
   is "; Y

If X contains the value 2 and Y contains the value 7, the statement produces this output:

The value of X is 2 and the value of Y is 7

By default, each Print method prints the text and moves to the next line. If there are no items, Print simply skips a line. A series of Print statements (in the following example, for a picture box named picLineCount) automatically uses separate lines:

picLineCount.Print "This is line 1."
picLineCount.Print "This is line 2."

By placing a semicolon (or comma) at the end of the first statement, however, you cause the output of the next Print statement to appear on the same line:

picLineCount.Print "This all appears ";
picLineCount.Print "on the same line."