Caption Property

Purpose

Determines the text displayed in the Ocx object.

Syntax

object.Caption [= string]

Description

For a 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.

For a control Caption determines the text displayed in or next to a control.

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.

Example

Ocx Command cmd = "OK", 10, 10, 80, 22

Do : Sleep : Until Me Is Nothing

 

Sub cmd_Click

cmd.Caption = (cmd.Caption = "OK" ? "Not OK" : "OK")

EndSub

Remarks

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.

See Also

Form, Text

{Created by Sjouke Hamstra; Last updated: 24/09/2014 by James Gaite}