See Also Example
Applies To
Form, MDI form
Description
Form
determines the text displayed in the form's title bar . When the form is minimized, this text is displayed below the form's icon .
Controls
determines the text displayed in or next to a control.
Usage
[form.][control.]Caption[ = stringexpression ]
Remarks
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.
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.
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.
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
Data Type
String
Programmer's Guide:
Chapter 3, "Creating and Using Controls"
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"
Else
Command1.Caption = "Clicked"
End If
End Sub