See Also Example
Form, MDI form, check box , command button , data control , frame , label , menu , option button .
Formdetermines the text displayed in the form's title bar . When the form is minimized, this text is displayed below the form's icon .
Controlsdetermines the text displayed in or next to a control.
[form.][control.]Caption[ = stringexpression ]
When you create a new object, its default caption is the same as the default Name This default caption includes the object name and an integer, such as Command1 or Form1. For a more descriptive label, set the Caption property. for both forms and controls.
You can use the Caption property to assign an access key In the caption, include an ampersand (&) immediately preceding the character you want for an access key. The character will be underlined. Press Alt plus the underlined character to move the focus to that control. To include an ampersand in a caption without creating an access key, type a double ampersand (&&). A single ampersand will appear in the caption and no characters will be underlined. to a control.
For labels, the caption is limited to 2048 characters. For forms and all other controls that have captions, the limit is 255 characters.
To display a form caption, set the BorderStyle A caption too long for the form's title bar will be clipped. property to either 1, 2, or 3.
When an MDI child form is maximized within an MDI form, the child form's caption is included with the parent form's caption.
Note For a label, set the AutoSize property to True to automatically resize the control to fit its caption.
Chapter 3, "Creating and Using Controls"
Caption Property Example
The example changes the caption on a command button each time the user clicks the button. To try this example, paste the code into the Declarations section of a form containing a command button named Command1. Then press F5 and click the button.
Sub Command1_Click ()
' Check caption, then change it.
If Command1.Caption = "Clicked" Then
Command1.Caption = "OK"
Command1.Caption = "Clicked"