Visual Basic Concepts

Displaying Text on Forms and Picture Boxes

See Also

To display text on a form or picture box, use the Print method, preceded by the name of the form or picture box. To send output text to a printer, use the Print method on the Printer object.

Using the Print Method

The Print method syntax is:

[object.]Print [outputlist] [{ ; | , }]

The object argument is optional; if omitted, the Print method applies to the current form.

For example, the following statements print messages to:

The outputlist argument is the text that appears on the form or picture box. Multiple items in the outputlist argument must be separated by commas or semicolons or both, as explained in "Displaying Different Items on a Single Line" later in this chapter.

Truncated Text

If the form or picture box is too small to display all the text, the text is cut off. Where the form or picture box cuts off the text depends on the coordinates of the location at which you began printing the text. You cannot scroll through a form or picture box.

Layering

When you print text to a form, the text appears in a layer behind any controls that have been placed on the form. So printing to a form usually works best on a form specifically created to hold the text. For more information about how text and graphics appear in layers on a form, see "Layering Graphics with AutoRedraw and ClipControls" later in this chapter.