For a Menu control, Caption is normally read/write at run time. But Caption is read-only for menus that are exposed or supplied by Visual Basic to add-ins, such as the MenuLine object.
Part | Description |
---|---|
Form | Determines the text displayed in the Form. |
Control | Determines the text displayed in or next to a control. |
object.Caption [= string]
The parts of the Caption property syntax are described in the following table.
Part | Description |
---|---|
object | An object expression that evaluates to an object. If object is omitted, the form associated with the active form module is assumed to be object. |
string | A string expression that evaluates to the text displayed as the caption. |
When you create a new object, its default caption is the default Name property setting. This default caption includes the object name and an integer, such as Command1 or Form1. For a more descriptive label, set the Caption property.
You can use the Caption property to assign an access key to a control. In the caption, include an ampersand (&) immediately preceding the character you want to designate as an access key. The character is underlined. Press the ALT key plus the underlined character to move the focus to that control. To include an ampersand in a caption without creating an access key, include two ampersands (&&). A single ampersand is displayed in the caption and no characters are underlined.
A Label control's caption size is unlimited. For forms and all other controls that have captions, the limit is 255 characters.
To display the caption for a form, set the BorderStyle property to Fixed Single (1 or vbFixedSingle). A caption that is too long for the form's title bar will be clipped.
Tip For a label, set the AutoSize property to True to automatically resize the control to fit its caption.