Copyright: Automated from the Object Model Database.


CheckBox Control

Displays the selection state of an item.

Remarks

Use a CheckBox to give the user a choice between two values such as Yes/No, True/False, or On/Off. When the user selects a CheckBox, it displays a special mark (such as an X) and its current setting is Yes, True, or On; if the user does not select the CheckBox, it is empty and its setting is No, False, or Off. Depending on the value of the TripleState property, a CheckBox can also have a null value.

If a CheckBox is bound to a data source, changing the setting changes the value of that source. A disabled CheckBox shows the current value, but is dimmed and does not allow changes to the value from the user interface.

You can also use check boxes inside a group box to select one or more of a group of related items. For example, you can create an order form that contains a list of available items, with a CheckBox preceding each item. The user can select a particular item or items by checking the corresponding CheckBox.

The default property of a CheckBox is the Value property.

The default event of a CheckBox is the Click event.

Note  The ListBox also lets you put a check mark by selected options. Depending on your application, you can use the ListBox instead of using a group of CheckBox controls.


ComboBox Control

Combines the features of a ListBox and a TextBox. The user can enter a new value, as with a TextBox, or the user can select an existing value as with a ListBox.

Remarks

If a ComboBox is bound to a data source, then the ComboBox inserts the value the user enters or selects into that data source. If a multicolumn combo box is bound, then the BoundColumn property determines which value is stored in the bound data source.

The list in a ComboBox consists of rows of data. Each row can have one or more columns, which can appear with or without headings. Some applications do not support column headings, others provide only limited support.

The default property of a ComboBox is the Value property.

The default event of a ComboBox is the Change event.

Note  If you want more than a single line of the list to appear at all times, you might want to use a ListBox instead of a ComboBox. If you want to use a ComboBox and limit values to those in the list, you can set the Style property of the ComboBox so the control looks like a drop-down list box.


CommandButton Control

Starts, ends, or interrupts an action or series of actions.

Remarks

The macro or event procedure assigned to the CommandButton's Click event determines what the CommandButton does. For example, you can create a CommandButton that opens another form. You can also display text, a picture, or both on a CommandButton.

The default property of a CommandButton is the Value property.

The default event for a CommandButton is the Click event.


Frame Control

Creates a functional and visual control group.

Remarks

All option buttons in a Frame are mutually exclusive, so you can use the Frame to create an option group. You can also use a Frame to group controls with closely related contents. For example, in an application that processes customer orders, you might use a Frame to group the name, address, and account number of customers.

You can also use a Frame to create a group of toggle buttons, but the toggle buttons are not mutually exclusive.

The default event for a Frame is the Click event.


Image Control

Displays a picture on a form.

Remarks

The Image lets you display a picture as part of the data in a form. For example, you might use an Image to display employee photographs in a personnel form.

The Image lets you crop, size, or zoom a picture, but does not allow you to edit the contents of the picture. For example, you cannot use the Image to change the colors in the picture, to make the picture transparent, or to refine the image of the picture. You must use image editing software for these purposes.

Note  You can also display a picture on a Label. However, a Label does not let you crop, size, or zoom the picture.

The default event for the Image is the Click event.


ListBox Control

Displays a list of values and lets you select one or more.

Remarks

If the ListBox is bound to a data source, then the ListBox stores the selected value in that data source.

The ListBox can either appear as a list or as a group of OptionButton controls or CheckBox controls.

The default property for a ListBox is the Value property.

The default event for a ListBox is the Click event.


MultiPage Control

Presents multiple screens of information as a single set.

Remarks

A MultiPage is useful when you work with a large amount of information that can be sorted into several categories. For example, use a MultiPage to display information from an employment application. One page might contain personal information such as name and address; another page might list previous employers; a third page might list references. The MultiPage lets you visually combine related information, while keeping the entire record readily accessible.

Note  The MultiPage is a container of a Pages collection, each of which contains one or more Page objects.

The default property for a MultiPage is the Value property, which returns the index of the currently active Page in the Pages collection of the MultiPage.

The default event for a MultiPage is the Change event.


OptionButton Control

Shows the selection status of one item in a group of choices.

Remarks

Use an OptionButton to show whether a single item in a group is selected. Note that each OptionButton in a Frame is mutually exclusive.

If an OptionButton is bound to a data source, the OptionButton can show the value of that data source as either Yes/No, True/False, or On/Off. If the user selects the OptionButton, the current setting is Yes, True, or On; if the user does not select the OptionButton, the setting is No, False, or Off. For example, an OptionButton in an inventory-tracking application might show whether an item is discontinued. If the OptionButton is bound to a data source, then changing the settings changes the value of that data source. A disabled OptionButton is dimmed and does not show a value.

Depending on the value of the TripleState property, an OptionButton can also have a null value.

You can also use an OptionButton inside a group box to select one or more of a group of related items. For example, you can create an order form with a list of available items, with an OptionButton preceding each item. The user can select a particular item by checking the corresponding OptionButton.

The default property for an OptionButton is the Value property.

The default event for an OptionButton is the Click event.


ScrollBar Control

Returns or sets the value of another control based on the position of the scroll box.

Remarks

A ScrollBar is a stand-alone control you can place on a form. It is visually like the scroll bar you see in certain objects such as a ListBox or the drop-down portion of a ComboBox. However, unlike the scroll bars in these examples, the stand-alone ScrollBar is not an integral part of any other control.

To use the ScrollBar to set or read the value of another control, you must write code for the ScrollBar’s events and methods. For example, to use the ScrollBar to update the value of a TextBox, you can write code that reads the Value property of the ScrollBar and then sets the Value property of the TextBox.

The default property for a ScrollBar is the Value property.

The default event for a ScrollBar is the Change event.

Note  To create a horizontal or vertical ScrollBar, drag the sizing handles of the ScrollBar horizontally or vertically on the form.


SpinButton Control

Increments and decrements numbers.

Remarks

Clicking a SpinButton changes only the value of the SpinButton. You can write code that uses the SpinButton to update the displayed value of another control. For example, you can use a SpinButton to change the month, the day, or the year shown on a date. You can also use a SpinButton to scroll through a range of values or a list of items, or to change the value displayed in a text box.

To display a value updated by a SpinButton, you must assign the value of the SpinButton to the displayed portion of a control, such as the Caption property of a Label or the Text property of a TextBox. To create a horizontal or vertical SpinButton, drag the sizing handles of the SpinButton horizontally or vertically on the form.

The default property for a SpinButton is the Value property.

The default event for a SpinButton is the Change event.


TabStrip Control

Presents a set of related controls as a visual group.

Remarks

You can use a TabStrip to view different sets of information for related controls.

For example, the controls might represent information about a daily schedule for a group of individuals, with each set of information corresponding to a different individual in the group. Set the title of each tab to show one individual's name. Then, you can write code that, when you click a tab, updates the controls to show information about the person identified on the tab.

Note  The TabStrip is implemented as a container of a Tabs collection, which in turn contains a group of Tab objects.

The default property for a TabStrip is the SelectedItem property.

The default event for a TabStrip is the Change event.


TextBox Control

Displays information from a user or from an organized set of data.

Remarks

A TextBox is the control most commonly used to display information entered by a user. Also, it can display a set of data, such as a table, query, worksheet, or a calculation result. If a TextBox is bound to a data source, then changing the contents of the TextBox also changes the value of the bound data source.

The default property for a TextBox is the Value property.

The default event for a TextBox is the Change event.


ToggleButton Control

Shows the selection state of an item.

Remarks

Use a ToggleButton to show whether an item is selected. If a ToggleButton is bound to a data source, the ToggleButton shows the current value of that data source as either Yes/No, True/False, On/Off, or some other choice of two settings. If the user selects the ToggleButton, the current setting is Yes, True, or On; if the user does not select the ToggleButton, the setting is No, False, or Off. If the ToggleButton is bound to a data source, changing the setting changes the value of that data source. A disabled ToggleButton shows a value, but is dimmed and does not allow changes from the user interface.

You can also use a ToggleButton inside a Frame to select one or more of a group of related items. For example, you can create an order form with a list of available items, with a ToggleButton preceding each item. The user can select a particular item by selecting the appropriate ToggleButton.

The default property of a ToggleButton is the Value property.

The default event of a ToggleButton is the Click event.


DataObject Object

A holding area for formatted text data used in transfer operations. Also holds a list of formats corresponding to the pieces of text stored in the DataObject.

Remarks

A DataObject can contain one piece of text for the Clipboard text format, and one piece of text for each additional text format, such as custom and user-defined formats.

A DataObject is distinct from the Clipboard. A DataObject supports commands that involve the Clipboard and drag-and-drop actions for text. When you start an operation involving the Clipboard (such as GetText) or a drag-and-drop operation, the data involved in that operation is moved to a DataObject.

The DataObject works like the Clipboard. If you copy a text string to a DataObject, the DataObject stores the text string. If you copy a second string of the same format to the DataObject, the DataObject discards the first text string and stores a copy of the second string. It stores one piece of text of a specified format and keeps the text from the most recent operation.


Font Object

Defines the characteristics of the text used by a control or form.

Remarks

Each control or form has its own Font object to let you set its text characteristics independently of the characteristics defined for other controls and forms. Use font properties to specify the font name, to set bold or underlined text, or to adjust the size of the text.

Note  The font properties of your form or container determine the default font attributes of controls you put on the form.

The default property for the Font object is the Name property. If the Name property contains a null string, the Font object uses the default system font.


Label Control

Displays descriptive text.

Remarks

A Label control on a form displays descriptive text such as titles, captions, pictures, or brief instructions. For example, labels for an address book might include a Label for a name, street, or city. A Label doesn't display values from data sources or expressions; it is always unbound and doesn't change as you move from record to record.

The default property for a Label is the Caption property.

The default event for a Label is the Click event.


Page Object

One page of a MultiPage and a single member of a Pages collection.

Remarks

Each Page object contains its own set of controls and does not necessarily rely on other pages in the collection for information. A Page inherits some properties from its container; the value of each inherited property is set by the container.

A Page has a unique name and index value within a Pages collection. You can reference a Page by either its name or its index value. The index of the first Page in a collection is 0; the index of the second Page is 1; and so on.

The default name for the first Page is Page1; the default name for the second Page is Page2.


Tab Object

A Tab is an individual member of a Tabs collection.

Remarks

Visually, a Tab object appears as a rectangle protruding from a larger rectangular area or as a button adjacent to a rectangular area.

In contrast to a Page, a Tab does not contain any controls. Controls that appear within the region bounded by a TabStrip are contained on the form, as is the TabStrip.

Each Tab has its own set of properties, but has no methods or events. You must use events from the appropriate TabStrip to initiate processing of an individual Tab.

Each Tab has a unique name and index value within the collection. You can reference a Tab by either its name or its index value. The index of the first Tab is 0; the index of the second Tab is 1; and so on.


Controls Collection

Includes all the controls contained in an object.

Remarks

Each control in the Controls collection of an object has a unique index whose value can be either an integer or a string. The index value for the first control in a collection is 0; the value for the second control is 1, and so on. This value indicates the order in which controls were added to the collection.

If the index is a string, it represents the name of the control. The Name property of a control also specifies a control's name.

You can use the Controls collection to enumerate or count individual controls, and to set their properties. For example, you can enumerate the Controls collection of a particular form and set the Height property of each control to a specified value.

Note  The For Each...Next statement is useful for enumerating a collection.


Pages Collection

A Pages collection includes all the pages of a MultiPage.

Remarks

Each Pages collection provides the features to manage the number of pages in the collection and to identify the page that is currently in use.

A Page object has a unique name and index value within a Pages collection. You can reference a Page either by its name or its index value. The index of the first Page in a collection is 0; the index of the second Page is 1; and so on. The default name for the first page is Page1; the default name for the second page is Page2.

The default value of a Pages collection identifies the current Page of a collection.


Tabs Collection

A Tabs collection includes all Tabs of a TabStrip.

Remarks

Each Tabs collection provides the features to manage the number of tabs in the collection and to identify the tab that is currently in use.

The default value of the Tabs collection identifies the current Tab of a collection.

A Tab object has a unique name and index value within a Tabs collection. You can reference a Tab either by its name or its index value. The index value reflects the ordinal position of the Tab within the collection. The index of the first Tab in a collection is 0; the index of the second Tab is 1; and so on.


Object Model Overview
Microsoft Forms Object Model Overview


AddControl Event

Occurs when a control is inserted onto a form, a Frame, or a Page of a MultiPage.

Syntax

For Frame
Private Sub object_AddControl( )

For MultiPage
Private Sub object_AddControl( index As Long, ctrl As Control)

The AddControl event syntax has these parts:

Part	Description
object	Required. A valid object.
index	Required. The index of the Page that will contain the new control.
ctrl	Required. The control to be added.
Remarks

The AddControl event occurs when a control is added at run time. This event is not initiated when you add a control at design time, nor is it initiated when a form is initially loaded and displayed at run time.

The default action of this event is to add a control to the specified form, Frame, or MultiPage.

The Add method initiates the AddControl event.


AfterUpdate Event

Occurs after data in a control is changed through the user interface.

Syntax

Private Sub object_AfterUpdate( )

The AfterUpdate event syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

The AfterUpdate event occurs regardless of whether the control is bound (that is, when the RowSource property specifies a data source for the control). This event cannot be canceled. If you want to cancel the update (to restore the previous value of the control), use the BeforeUpdate event and set the Cancel argument to True.

The AfterUpdate event occurs after the BeforeUpdate event and before the Exit event for the current control and before the Enter event for the next control in the tab order.


BeforeDragOver Event

Occurs when a drag-and-drop operation is in progress.

Syntax

For Frame
Private Sub object_BeforeDragOver( Cancel As Boolean, ctrl As Control, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As fmDragState, Effect As fmDropEffect, ByVal Shift As fmShiftState)

For MultiPage
Private Sub object_BeforeDragOver( index As Long, Cancel As Boolean, ctrl As Control, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As fmDragState, Effect As fmDropEffect, ByVal Shift As fmShiftState)

For TabStrip
Private Sub object_BeforeDragOver( index As Long, Cancel As Boolean, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As fmDragState, Effect As fmDropEffect, ByVal Shift As fmShiftState)

For other controls
Private Sub object_BeforeDragOver( Cancel As Boolean, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As fmDragState, Effect As fmDropEffect, ByVal Shift As fmShiftState)

The BeforeDragOver event syntax has these parts:

Part	Description
object	Required. A valid object name.
index	Required. The index of the Page in a MultiPage that the drag-and-drop operation will affect.
Cancel	Required. Event status. False indicates that the control should handle the event (default). True indicates the application handles the event.
Ctrl	Required. The control being dragged over.
Data	Required. Data that is dragged in a drag-and-drop operation. The data is packaged in a DataObject.
X, Y	Required. The horizontal and vertical coordinates of the control’s position. Both coordinates are measured in points. X is measured from the left edge of the control; Y is measured from the top of the control..
DragState	Required. Transition state of the data being dragged.
Effect	Required. Operations supported by the drop source.
Shift	Required. Specifies the state of SHIFT, CTRL, and ALT.
Settings

The settings for DragState are:

Constant	Value	Description
fmDragStateEnter	0	Mouse pointer is within range of a target.
fmDragStateLeave	1	Mouse pointer is outside the range of a target.
fmDragStateOver	2	Mouse pointer is at a new position, but remains within range of the same target.
The settings for Effect are:

Constant	Value	Description
fmDropEffectNone	0	Does not copy or move the drop source to the drop target.
fmDropEffectCopy	1	Copies the drop source to the drop target.
fmDropEffectMove	2	Moves the drop source to the drop target.
fmDropEffectCopyOrMove	3	Copies or moves the drop source to the drop target.
The settings for Shift are:

Constant	Value	Description
fmShiftMask	1	SHIFT was pressed.
fmCtrlMask	2	CTRL was pressed.
fmAltMask	4	ALT was pressed.
Remarks

Use this event to monitor the mouse pointer as it enters, leaves, or rests directly over a valid target. When a drag-and-drop operation is in progress, the system initiates this event when the user moves the mouse, or presses or releases the mouse buttons. The mouse pointer position determines the target object that receives this event. You can determine the state of the mouse pointer by examining the DragState argument.

When a control handles this event, you can use the Effect argument to identify the drag-and-drop action to perform. When Effect is set to fmDropEffectCopyOrMove, the drop source supports a copy (fmDropEffectCopy), move (fmDropEffectMove), or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectCopy, the drop source supports a copy or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectMove, the drop source supports a move or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectNone. the drop source supports a cancel operation.

You can cancel this event by setting Cancel to True.


BeforeDropOrPaste Event

Occurs when the user is about to drop or paste data onto an object.

Syntax

For Frame
Private Sub object_BeforeDropOrPaste( Cancel As Boolean, ctrl As Control, ByVal Action As fmAction, ByVal Data As DataObject, Effect As fmDropEffect, ByVal Shift As fmShiftState)

For MultiPage
Private Sub object_BeforeDropOrPaste( index As Long, Cancel As Boolean, ctrl As Control, ByVal Action As fmAction, ByVal Data As DataObject, Effect As fmDropEffect, ByVal Shift As fmShiftState)

For TabStrip
Private Sub object_BeforeDropOrPaste( index As Long, Cancel As Boolean, ByVal Action As fmAction, ByVal Data As DataObject, Effect As fmDropEffect, ByVal Shift As fmShiftState)

For other controls
Private Sub object_BeforeDropOrPaste( Cancel As Boolean, ByVal Action As fmAction, ByVal Data As DataObject, Effect As fmDropEffect, ByVal Shift As fmShiftState)

The BeforeDropOrPaste event syntax has these parts:

Part	Description
object	Required. A valid object name.
index	Required. The index of the Page in a MultiPage that the drop or paste operation will affect.
Cancel	Required. Event status. False indicates that the control should handle the event (default). True indicates the application handles the event.
ctrl	Required. The target control.
Action	Required. Indicates the result, based on the current keyboard settings, of the pending drag-and-drop operation.
Data	Required. Data that is dragged in a drag-and-drop operation. The data is packaged in a DataObject.
Effect	Required. Effect of the drag-and-drop operation on the target control.
Shift	Required. Specifies the state of SHIFT, CTRL, and ALT.
Settings

The settings for Action are:

Constant	Value	Description
fmActionPaste	2	Pastes the selected object into the drop target.
fmActionDragDrop	3	Indicates the user has dragged the object from its source to the drop target and dropped it on the drop target.
The settings for Effect are:

Constant	Value	Description
fmDropEffectNone	0	Does not copy or move the drop source to the drop target.
fmDropEffectCopy	1	Copies the drop source to the drop target.
fmDropEffectMove	2	Moves the drop source to the drop target.
fmDropEffectCopyOrMove	3	Copies or moves the drop source to the drop target.
The settings for Shift are:

Constant	Value	Description
fmShiftMask	1	SHIFT was pressed.
fmCtrlMask	2	CTRL was pressed.
fmAltMask	4	ALT was pressed.
Remarks

For a MultiPage or TabStrip, Visual Basic for Applications initiates this event when it transfers a data object to the control.

For other controls, the system initiates this event immediately prior to the drop or paste operation.

When a control handles this event, you can update the Action argument to identify the drag-and-drop action to perform. When Effect is set to fmDropEffectCopyOrMove, you can assign Action to fmDropEffectNone, fmDropEffectCopy, or fmDropEffectMove. When Effect is set to fmDropEffectCopy or fmDropEffectMove, you can reassign Action to fmDropEffectNone. You cannot reassign Action when Effect is set to fmDropEffectNone.


BeforeUpdate Event

Occurs before data in a control is changed.

Syntax

Private Sub object_BeforeUpdate( Cancel As Boolean)

The BeforeUpdate event syntax has these parts:

Part	Description
object	Required. A valid object.
Cancel	Required. Event status. False indicates that the control should handle the event (default). True cancels the update and indicates the application should handle the event.
Remarks

The BeforeUpdate event occurs regardless of whether the control is bound (that is, when the RowSource property specifies a data source for the control). This event occurs before the AfterUpdate and Exit events for the control (and before the Enter event for the next control in the tab order).

If you set the Cancel argument to True, the focus remains on the control and neither the AfterUpdate event nor the Exit event occurs.

Changing data in a control using programming statements doesn't initiate this event.


Change Event

Occurs when the Value property changes.

Syntax

Private Sub object_Change( )

The Change event syntax has these parts:

Part	Description
object	Required. A valid object.
Settings

The Change event occurs when the setting of the Value property changes, regardless of whether the change results from execution of code or a user action in the interface.

Here are some examples of actions that change the Value property:

•	Clicking a CheckBox, OptionButton, or ToggleButton..

•	Entering or selecting a new text value for a ComboBox, ListBox, or TextBox.

•	Selecting a different tab on a TabStrip.

•	Moving the scroll box in a ScrollBar.

•	Clicking the up arrow or down arrow on a SpinButton.

•	Selecting a different page on a MultiPage.

Remarks

The Change event procedure can synchronize or coordinate data displayed among controls. For example, you can use the Change event procedure of a ScrollBar to update the contents of a TextBox that displays the value of the ScrollBar. Or you can use a Change event procedure to display data and formulas in a work area and results in another area.

Note  In some cases, the Click event may also occur when the Value property changes. However, using the Change event is the preferred technique for detecting a new value for a property.


Click Event

Occurs in one of two cases:

•	The user clicks a control with the mouse.

•	The user definitively selects a value for a control with more than one possible value.

Syntax

For MultiPage, TabStrip
Private Sub object_Click( index As Long)

For all other controls
Private Sub object_Click( )

The Click event syntax has these parts:

Part	Description
object	Required. A valid object.
index	Required. The index of the page or tab in a MultiPage or TabStrip associated with this event.
Remarks

Of the two cases where the Click event occurs, the first case applies to the CommandButton, Frame, Image, Label, ScrollBar, and SpinButton. The second case applies to the CheckBox, ComboBox, ListBox, MultiPage, TabStrip, TextBox, and ToggleButton. It also applies to an OptionButton when the value changes to True.

The following are examples of actions that initiate the Click event:

•	Clicking a blank area of a form or a disabled control (other than a list box) on the form.

•	Clicking a CommandButton. If the command button doesn't already have the focus, the Enter event occurs before the Click event.

•	Pressing the SPACEBAR when a CommandButton has the focus.

•	Clicking a control with the left mouse button (left-clicking).

•	Pressing ENTER on a form that has a command button whose Default property is set to True, as long as no other command button has the focus.

•	Pressing ESC on a form that has a command button whose Cancel property is set to True, as long as no other command button has the focus.

•	Pressing a control's accelerator key.

When the Click event results from clicking a control, the sequence of events leading to the Click event is:

1.	MouseDown

2.	MouseUp

3.	Click

For some controls, the Click event occurs when the Value property changes. However, using the Change event is the preferred technique for detecting a new value for a property. The following are examples of actions that initiate the Click event due to assigning a new value to a control:

•	Clicking a different page or tab in a MultiPage or TabStrip. The Value property for these controls reflects the current Page or Tab. Clicking the current page or tab does not change the control’s value and does not initiate the Click event.

•	Clicking a CheckBox or ToggleButton, pressing the SPACEBAR when one of these controls has the focus, pressing the accelerator key for one of these controls, or changing the value of the control in code.

•	Changing the value of an OptionButton to True. Setting one OptionButton in a group to True sets all other buttons in the group to False, but the Click event occurs only for the button whose value changes to True.

•	Selecting a value for a ComboBox or ListBox so that it unquestionably matches an item in the control’s drop-down list. For example, if a list is not sorted, the first match for characters typed in the edit region may not be the only match in the list, so choosing such a value does not initiate the Click event. In a sorted list, you can use entry-matching to ensure that a selected value is a unique match for text the user types.

The Click event is not initiated when Value is set to Null.

Note  Left-clicking changes the value of a control, thus it initiates the Click event. Right-clicking does not change the value of the control, so it does not initiate the Click event.


DblClick Event

Occurs when the user points to an object and then clicks a mouse button twice.

Syntax

For MultiPage, TabStrip
Private Sub object_DblClick( index As Long, Cancel As Boolean)

For other controls
Private Sub object_DblClick( Cancel As Boolean)

The DblClick event syntax has these parts:

Part	Description
object	Required. A valid object.
index	Required. The position of a Page or Tab object within a Pages or Tabs collection.
Cancel	Required. Event status. False indicates that the control should handle the event (default). True indicates the application handles the event.
Remarks

For this event to occur, the two clicks must occur within the time span specified by the system's double-click speed setting.

For controls that support Click, the following sequence of events leads to the DblClick event:

1.	MouseDown

2.	MouseUp

3.	Click

4.	DblClick

If a control, such as TextBox, does not support Click, Click is omitted fom the order of events leading to the DblClick event.

If the return value of Cancel is True when the user clicks twice, the control ignores the second click. This is useful if the second click reverses the effect of the first, such as double-clicking a toggle button. The Cancel argument allows your form to ignore the second click, so that either clicking or double-clicking the button has the same effect.


DropButtonClick Event

Occurs whenever the drop-down list appears or disappears.

Syntax

Private Sub object_DropButtonClick( )

The DropButtonClick event syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

You can initiate the DropButtonClick event through code or by taking certain actions in the user interface.

In code, calling the DropDown method initiates the DropButtonClick event.

In the user interface, any of the following actions initiates the event:

•	Clicking the drop-down button on the control.

•	Pressing F4.

Any of the above actions, in code or in the interface, cause the drop-down box to appear on the control. The system initiates the DropButtonClick event when the drop-down box goes away.


Enter, Exit Events

Enter occurs before a control actually receives the focus from a control on the same form. Exit occurs immediately before a control loses the focus to another control on the same form.

Syntax

Private Sub object_Enter( )

Private Sub object_Exit( Cancel As Boolean)

The Enter and Exit event syntaxes have these parts:

Part	Description
object	Required. A valid object name.
Cancel	Required. Event status. False indicates that the control should handle the event (default). True indicates the application handles the event and the focus should remain at the current control.
Remarks

The Enter and Exit events are similar to the GotFocus and LostFocus events in Visual Basic. Unlike GotFocus and LostFocus, the Enter and Exit events don't occur when a form receives or loses the focus.

For example, suppose you select the check box that initiates the Enter event. If you then select another control in the same form, the Exit event is initiated for the check box (because focus is moving to a different object in the same form) and then the Enter event occurs for the second control on the form.

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains.

Note  To prevent the control from losing focus, assign True to the Cancel argument of the Exit event.


Error Event

Occurs when a control detects an error and cannot return the error information to a calling program.

Syntax

For MultiPage
Private Sub object_Error( index As Long, ByVal Number As Integer, Description As String, ByVal SCode As SCode, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

For other controls
Private Sub object_Error( ByVal Number As Integer, Description As String, ByVal SCode As SCode, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

The Error event syntax has these parts:

Part	Description
object	Required. A valid object name.
index	Required. The index of the page in a MultiPage associated with this event.
Number	Required. Specifies a unique value that the control uses to identify the error.
Description	Required. A textual description of the error.
SCode	Required. Specifies the OLE status code for the error. The low-order 16 bits specify a value that is identical to the Number argument.
Source	Required. The string that identifies the control which initiated the event.
HelpFile	Required. Specifies a fully qualified path name for the Help file that describes the error.
HelpContext	Required. Specifies the context ID of the Help file topic that contains a description of the error.
CancelDisplay	Required. Specifies whether to display the error string in a message box.
Remarks

The code written for the Error event determines how the control responds to the error condition.

The ability to handle error conditions varies from one application to another. The Error event is initiated when an error occurs that the application is not equipped to handle.


KeyDown, KeyUp Events

Occur in sequence when a user presses and releases a key. KeyDown occurs when the user presses a key. KeyUp occurs when the user releases a key.

Syntax

Private Sub object_KeyDown( KeyCode As Integer, ByVal Shift As fmShiftState)

Private Sub object_KeyUp( KeyCode As Integer, ByVal Shift As fmShiftState)

The KeyDown and KeyUp event syntaxes have these parts:

Part	Description
object	Required. A valid object name.
KeyCode	Required. The key code of the key that was pressed or released.
Shift	Required. The state of SHIFT, CTRL, and ALT.
Settings

The settings for Shift are:

Constant	Value	Description
fmShiftMask	1	SHIFT was pressed.
fmCtrlMask	2	CTRL was pressed.
fmAltMask	4	ALT was pressed.
Remarks

The KeyDown event occurs when the user presses a key on a running form while that form or a control on it has the focus. The KeyDown and KeyPress events alternate repeatedly until the user releases the key, at which time the KeyUp event occurs. The form or control with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

These events also occur if you send a keystroke to a form or control using either the SendKeys action in a macro or the SendKeys Statement in Visual Basic.

The KeyDown and KeyUp events are typically used to recognize or distinguish between:

•	Extended character keys, such as function keys.

•	Navigation keys, such as HOME, END, PAGEUP, PAGEDOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

•	Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT).

•	The numeric keypad and keyboard number keys.

The KeyDown and KeyUp events do not occur under the following circumstances:

•	The user presses enter on a form with a command button whose Default property is set to True.

•	The user presses esc on a form with a command button whose Cancel property is set to True.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

The sequence of keyboard-related events is:

1.	KeyDown

2.	KeyPress

3.	KeyUp

Note  The KeyDown and KeyUp events apply only to forms and controls on a form. To interpret ANSI characters or to find out the ANSI character corresponding to the key pressed, use the KeyPress event.


KeyPress Event

Occurs when the user presses an ANSI key.

Syntax

Private Sub object_KeyPress( KeyANSI As Integer)

The KeyPress event syntax has these parts:

Part	Description
object	Required. A valid object.
KeyANSI	Required. An integer value that represents a standard numeric ANSI keycode.
Remarks

The KeyPress event occurs when the user presses a key that produces a typeable character (an ANSI key) on a running form while the form or a control on it has the focus. The event can occur either before or after the key is released. This event also occurs if you send an ANSI keystroke to a form or control using either the SendKeys action in a macro or the SendKeys Statement in Visual Basic.

A KeyPress event can occur when any of the following keys are pressed:

•	Any printable keyboard character.

•	CTRL combined with a character from the standard alphabet.

•	CTRL combined with any special character.

•	BACKSPACE.

•	ESC.

A KeyPress event does not occur under the following conditions:

•	Pressing TAB.

•	Pressing ENTER.

•	Pressing an arrow key.

•	When a keystroke causes the focus to move from one control to another.

Note  BACKSPACE is part of the ANSI Character Set, but DELETE is not. Deleting a character in a control using BACKSPACE causes a KeyPress event; deleting a character using DELETE doesn't.

When a user holds down a key that produces an ANSI keycode, the KeyDown and KeyPress events alternate repeatedly. When the user releases the key, the KeyUp event occurs. The form or control with the focus receives all keystrokes. A form can have the focus only if it has no controls, or if all its visible controls are disabled.

The default action for the KeyPress event is to process the event code that corresponds to the key that was pressed. KeyANSI indicates the ANSI character that corresponds to the pressed key or key combination. The KeyPress event interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

To respond to the physical state of the keyboard, or to handle keystrokes not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL), use the KeyDown and KeyUp event procedures.

The sequence of keyboard-related events is:

1.	KeyDown

2.	KeyPress

3.	KeyUp


Layout Event

Occurs when a form, Frame, or MultiPage changes size.

Syntax

For MultiPage
Private Sub object_Layout( index As Long)

For all other controls
Private Sub object_Layout( )

The Layout event syntax has these parts:

Part	Description
object	Required. A valid object.
index	Required. The index of the page in a MultiPage that changed size.
Remarks

The default action of the layout event is to calculate new positions of controls and to repaint the screen.

A user can initiate the Layout event by changing the size of a control.

For controls that support the AutoSize property, the Layout event is initiated when AutoSize changes the size of the control. This occurs when the user changes the value of a property that affects the size of a control. For example, increasing the Font size of a TextBox or Label can significantly change the dimensions of the control and initiate a Layout event.


MouseDown, MouseUp Events

Occur when the user clicks a mouse button. MouseDown occurs when the user presses the mouse button; MouseUp occurs when the user releases the mouse button.

Syntax

For MultiPage, TabStrip
Private Sub object_MouseDown( index As Long, ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

Private Sub object_MouseUp( index As Long, ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

For other controls
Private Sub object_MouseDown( ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

Private Sub object_MouseUp( ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

The MouseDown and MouseUp event syntaxes have these parts:

Part	Description
object	Required. A valid object.
index	Required. The index of the page or tab in a MultiPage or TabStrip with the specified event.
Button	Required. An integer value that identifies which mouse button caused the event.
Shift	Required. The state of SHIFT, CTRL, and ALT.
X, Y	Required. The horizontal or vertical position, in points, from the left or top edge of the form, Frame, or Page.
Settings

The settings for Button are:

Constant	Value	Description
fmButtonLeft	1	The left button was pressed.
fmButtonRight	2	The right button was pressed.
fmButtonMiddle	4	The middle button was pressed.
The settings for Shift are:

Value	Description
1	SHIFT was pressed.
2	CTRL was pressed.
3	SHIFT and CTRL were pressed.
4	ALT was pressed.
5	ALT and SHIFT were pressed.
6	ALT and CTRL were pressed.
7	ALT, SHIFT, and CTRL were pressed.
You can identify individual keyboard modifiers by using the following constants:

Constant	Value	Description
fmShiftMask	1	Mask to detect SHIFT.
fmCtrlMask	2	Mask to detect CTRL.
fmAltMask	4	Mask to detect ALT.
Remarks

For a MultiPage, the MouseDown event occurs when the user presses a mouse button over the control.

For a TabStrip, the index argument identifies the tab where the user clicked. An index of –1 indicates the user did not click a tab. For example, if there are no tabs in the upper right corner of the control, clicking in the upper right corner sets the index to –1.

For a form, the user can generate MouseDown and MouseUp events by pressing and releasing a mouse button in a blank area, record selector, or scroll bar on the form.

The sequence of mouse-related events is:

1.	MouseDown

2.	MouseUp

3.	Click

4.	DblClick

5.	MouseUp

MouseDown or MouseUp event procedures specify actions that occur when a mouse button is pressed or released. MouseDown and MouseUp events enable you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keyboard modifiers.

If a mouse button is pressed while the pointer is over a form or control, that object "captures" the mouse and receives all mouse events up to and including the last MouseUp event. This implies that the X, Y mouse-pointer coordinates returned by a mouse event may not always be within the boundaries of the object that receives them.

If mouse buttons are pressed in succession, the object that captures the mouse receives all successive mouse events until all buttons are released.

Use the Shift argument to identify the state of SHIFT, CTRL, and ALT when the MouseDown or MouseUp event occurred. For example, if both CTRL and ALT are pressed, the value of Shift is 6.


MouseMove Event

Occurs when the user moves the mouse.

Syntax

For MultiPage, TabStrip
Private Sub object_MouseMove( index As Long, ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

For other controls
Private Sub object_MouseMove( ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

The MouseMove event syntax has these parts:

Part	Description
object	Required. A valid object name.
index	Required. The index of the page or tab in a MultiPage or TabStrip associated with this event.
Button	Required. An integer value that identifies the state of the mouse buttons.
Shift	Required. Specifies the state of SHIFT, CTRL, and ALT.
X, Y	Required. The horizontal or vertical position, measured in points, from the left or top edge of the control.
Settings

The index argument specifies which page or tab was clicked over. A –1 designates that the user did not click on any of the pages or tabs.

The settings for Button are:

Value	Description
0	No button is pressed.
1	The left button is pressed.
2	The right button is pressed.
3	The right and left buttons are pressed.
4	The middle button is pressed.
5	The middle and left buttons are pressed.
6	The middle and right buttons are pressed.
7	All three buttons are pressed.
The settings for Shift are:

Value	Description
1	SHIFT was pressed.
2	CTRL was pressed.
3	SHIFT and CTRL were pressed.
4	ALT was pressed.
5	ALT and SHIFT were pressed.
6	ALT and CTRL were pressed.
7	ALT, SHIFT, and CTRL were pressed.
You can identify individual keyboard modifiers by using the following constants:

Constant	Value	Description
fmShiftMask	1	Mask to detect SHIFT.
fmCtrlMask	2	Mask to detect CTRL.
fmAltMask	4	Mask to detect ALT.
Remarks

The MouseMove event applies to forms, controls on a form, and labels.

MouseMove events are generated continually as the mouse pointer moves across objects. Unless another object has captured the mouse, an object recognizes a MouseMove event whenever the mouse position is within its borders.

Moving a form can also generate a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can continually generate (cascade) MouseMove events.

If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event might not occur for that space. In such cases, you might need to respond to the MouseMove event in both controls.

You can use the value returned in the Button argument to identify the state of the mouse buttons.

Use the Shift argument to identify the state of SHIFT, CTRL, and ALT when the MouseMove event occurred. For example, if both CTRL and ALT are pressed, the value of Shift is 6.

Note  You can use MouseDown and MouseUp event procedures to respond to events caused by pressing and releasing mouse buttons.


RemoveControl Event

Occurs when a control is deleted from the container.

Syntax

For MultiPage
Private Sub object_RemoveControl( index As Long, ctrl As Control)

For all other controls
Private Sub object_RemoveControl( ctrl As Control)

The RemoveControl event syntax has these parts:

Part	Description
object	Required. A valid object name.
index	Required. The index of the page in a MultiPage that contained the deleted control.
ctrl	Required. The deleted control.
Remarks

This event occurs when a control is deleted from the form, not when a control is unloaded due to a form being closed.


Scroll Event

Occurs when the scroll box is repositioned.

Syntax

For ScrollBar
Private Sub object_Scroll( )

For MultiPage
Private Sub object_Scroll( index As Long, ActionX As fmScrollAction, ActionY As fmScrollAction, ByVal RequestDx As Single, ByVal RequestDy As Single, ActualDx As Single, ActualDy As Single)

For Frame
Private Sub object_Scroll( ActionX As fmScrollAction, ActionY As fmScrollAction, ByVal RequestDx As Single, ByVal RequestDy As Single, ActualDx As Single, ActualDy As Single)

The Scroll event syntax has these parts:

Part	Description
object	Required. A valid object name.
index	Required. The index of the page in a MultiPage associated with this event.
ActionX	Required. The action that occurred in the horizontal direction.
ActionY	Required. The action that occurred in the vertical direction.
RequestDx	Required. The distance, in points, you want the scroll bar to move in the horizontal direction.
RequestDy	Required. The distance, in points, you want the scroll bar to move in the vertical direction.
ActualDx	Required. The distance, in points, the scroll bar travelled in the horizontal direction.
ActualDy	Required. The distance, in points, the scroll bar travelled in the vertical direction.
Settings

The settings for ActionX and ActionY are:

Constant	Value	Description
fmScrollActionNoChange	0	No change occurred.
fmScrollActionLineUp	1	A small distance up on a vertical scroll bar; a small distance to the left on a horizontal scroll bar. Movement is equivalent to pressing the up or left arrow keys on the keyboard to move the scroll bar.
fmScrollActionLineDown	2	A small distance down on a vertical scroll bar; a small distance to the right on a horizontal scroll bar. Movement is equivalent to pressing the down or right arrow keys on the keyboard to move the scroll bar.
fmScrollActionPageUp	3	One page up on a vertical scroll bar; one page to the left on a horizontal scroll bar. Movement is equivalent to pressing PAGE UP on the keyboard to move the scroll bar.
fmScrollActionPageDown	4	One page down on a vertical scroll bar; one page to the right on a horizontal scroll bar. Movement is equivalent to pressing PAGE DOWN on the keyboard to move the scroll bar.
fmScrollActionBegin	5	The top of a vertical scroll bar; the left end of a horizontal scroll bar.
fmScrollActionEnd	6	The bottom of a vertical scroll bar; the right end of a horizontal scroll bar.
fmScrollActionPropertyChange	8	The value of either the ScrollTop or the ScrollLeft property changed. The direction and amount of movement depend on which property was changed and on the new property value.
fmScrollActionControlRequest	9	A control asked its container to scroll. The amount of movement depends on the specific control and container involved.
fmScrollActionFocusRequest	10	The user moved to a different control. The amount of movement depends on the placement of the selected control, and generally has the effect of moving the selected control so it is completely visible to the user.
Remarks

The Scroll events associated with a form, Frame, or Page return the following arguments: ActionX, ActionY, ActualX, and ActualY. ActionX and ActionY identify the action that occurred. ActualX and ActualY identify the distance that the scroll box traveled.

The default action is to calculate the new position of the scroll box and then scroll to that position.

You can initiate a Scroll event by issuing a Scroll method for a form, Frame, or Page. Users can generate Scroll events by moving the scroll box.

The Scroll event associated with the stand-alone ScrollBar indicates that the user moved the scroll box in either direction. This event is not initiated when the value of the ScrollBar changes by code or by the user clicking on parts of the ScrollBar other than the scroll box.


SpinDown, SpinUp Events

SpinDown occurs when the user clicks the lower or left spin-button arrow. SpinUp occurs when the user clicks the upper or right spin-button arrow.

Syntax

Private Sub object_SpinDown( )

Private Sub object_SpinUp( )

The SpinDown and SpinUp event syntaxes have these parts:

Part	Description
object	Required. A valid object.
Remarks

The SpinDown event decreases the Value property. The SpinUp event increases Value.


Zoom Event

Occurs when the value of the Zoom property changes.

Syntax

For Frame
Private Sub object_Zoom( Percent As Integer)

For MultiPage
Private Sub object_Zoom( index As Long, Percent As Integer)

The Zoom event syntax has these parts:

Part	Description
object	Required. A valid object name.
index	Required. The index of the page in a MultiPage associated with this event.
Percent	Required. The percentage the form is to be zoomed. Valid values range from 10 percent to 400 percent.
Remarks

The value of the Zoom property identifies how the size of the form or Page changes. The value of the property indicates how the size of the control should change relative to its current size. Values less than 100 reduce the displayed size of the form; values greater than 100 increase the displayed size of the form.

You can set this property to any integer from 10 to 400.


Add Method

Adds or inserts a Tab or Page in a TabStrip or MultiPage, or adds a control by its programmatic identifier (ProgID) to a page or form.

Syntax

For MultiPage, TabStrip
Set Object = object.Add( [ Name [,  Caption [,  index]]])

For other controls
Set Control = object.Add(  ProgID [,  Name [,  Visible]])

The Add method syntax has these parts:

Part	Description
object	Required. A valid object name.
Name	Optional. Specifies the name of the object being added. If a name is not specified, the system generates a default name based on the rules of the application where the form is used.
Caption	Optional. Specifies the caption to appear on a tab or a control. If a caption is not specified, the system generates a default caption based on the rules of the application where the form is used.
index	Optional. Identifies the position of a page or tab within a Pages or Tabs collection. If an index is not specified, the system appends the page or tab to the end of the Pages or Tabs collection and assigns the appropriate index value.
ProgID	Required. Programmatic identifier. A text string with no spaces that identifies an object class. The standard syntax for a ProgID is <Vendor>.<Component>.<Version>. A ProgID is mapped to a class identifier (CLSID).
Visible	Optional. True if the object is visible (default). False if the object is hidden.
Settings

ProgID values for individual controls are:

CheckBox	Forms.CheckBox.1
ComboBox	Forms.ComboBox.1
CommandButton	Forms.CommandButton.1
Frame	Forms.Frame.1
Image	Forms.Image.1
Label	Forms.Label.1
ListBox	Forms.ListBox.1
MultiPage	Forms.MultiPage.1
OptionButton	Forms.OptionButton.1
ScrollBar	Forms.ScrollBar.1
SpinButton	Forms.SpinButton.1
TabStrip	Forms.TabStrip.1
TextBox	Forms.TextBox.1
ToggleButton	Forms.ToggleButton.1
Remarks

For a MultiPage control, the Add method returns a Page object. For a TabStrip, it returns a Tab object. The index value for the first Page or Tab of a collection is 0, the value for the second Page or Tab is 1, and so on.

For the Controls collection of an object, the Add method returns a control corresponding to the specified ProgID. The AddControl event occurs after the control is added.

Note  You can change a control's Name property at run time only if you added that control at run time with the Add method.


AddItem Method

For a single-column list box or combo box, adds an item to the list. For a multicolumn list box or combo box, adds a row to the list.

Syntax

Variant = object.AddItem( [ item [,  varIndex]])

The AddItem method syntax has these parts:

Part	Description
object	Required. A valid object.
Item	Optional. Specifies the item or row to add. The number of the first item or row is 0; the number of the second item or row is 1, and so on.
varIndex	Optional. Integer specifying the position within the object where the new item or row is placed.
Remarks

If you supply a valid value for varIndex, the AddItem method places the item or row at that position within the list. If you omit varIndex, the method adds the item or row at the end of the list.

For a multicolumn ListBox or ComboBox, AddItem inserts an entire row, that is, it inserts an item for each column of the control. To assign values to an item beyond the first column, use the List or Column property and specify the row and column of the item.

Note  You can add more than one row at a time to a ComboBox or ListBox by using List.


Clear Method

Removes all objects from an object or collection.

Syntax

object.Clear

The Clear method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

For a MultiPage or TabStrip, the Clear method deletes individual pages or tabs.

For a ListBox or ComboBox, Clear removes all entries in the list.

For a Controls collection, Clear deletes controls that were created at run time with the Add method. Using Clear on controls created at design time causes an error.


Copy Method

Copies the contents of an object to the Clipboard.

Syntax

object.Copy

The Copy method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

The original content remains on the object.

The actual content that is copied depends on the object. For example, on a Page, the Copy method copies the currently selected control or controls. On a TextBox or ComboBox, it copies the currently selected text.

Using Copy for a form, Frame, or Page copies the currently-active control.


Cut Method

Removes selected information from an object and transfers it to the Clipboard.

Syntax

object.Cut

The Cut method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

For a ComboBox or TextBox, the Cut method removes currently selected text in the control to the Clipboard. This method does not require that the control have the focus.

On a Page, Frame, or form, Cut removes currently selected controls to the Clipboard. This method only removes controls created at run time.


DropDown Method

Displays the list portion of a ComboBox; or, if the list is currently displayed, dismisses it.

Syntax

object.DropDown

The DropDown method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

Use the DropDown method to open the list in a combo box.


GetFormat Method

Returns an integer value indicating whether a specific format is on the DataObject.

Syntax

Boolean = object.GetFormat( [ format])

The GetFormat method syntax has these parts:

Part	Description
object	Required. A valid object.
format	Optional. An integer or string specifying the data format to use when pasting the Clipboard contents.
Settings

The settings for format are:

Constant	Value	Description
fmCFText	1	Text format.
Remarks

The GetFormat method searches for a format in the current list of formats on the DataObject. If the format is on the DataObject, GetFormat returns 1; if not, GetFormat returns 0.

The DataObject currently supports only text formats.


GetFromClipboard, GetText Methods

GetFromClipboard moves data from the Clipboard to a DataObject. GetText retrieves a text string from the Clipboard using a specified format.

Syntax

String = object.GetFromClipboard( [ format])

String = object.GetText( [ format])

The GetText method syntax has these parts:

Part	Description
object	Required. A valid object name.
format	Optional. An integer specifying the data format to use when pasting the Clipboard contents.
Settings

The settings for format are:

Constant	Value	Description
fmCFText	1	Text format.
Remarks

The DataObject and the Clipboard support multiple formats, but only support one data item of a given format. For example, the DataObject might include one text item, but cannot include two text items of the type fmCFText.

If the DataObject contains data in the same format as new data, the new data replaces the existing data in the DataObject. If the new data is in a new format, the new data and the new format are both added to the DataObject.

If no format is specified, the GetText method returns the string associated with the standard text format.


Item Method

Returns a member of a collection, either by position or by name.

Syntax

Set Object = object.Item(  collectionindex)

The Item method syntax has these parts:

Part	Description
object	Required. A valid object.
collectionindex	Required. A member's position, or index, within a collection.
Settings

The collectionindex can be either a string or an integer. If it is a string, it must be a valid member name. If it is an integer, the minimum value is 0 and the maximum value is one less than the number of items in the collection.

Remarks

If an invalid index or name is specified, an error occurs.


Move Method

Moves a form or control, or moves all the controls in the Controls collection..

Syntax

For a form or control
object.Move( [Left [,  Top [,  Width [,  Height [,  Layout]]]]])

For the Controls collection
object.Move( X, Y)

The Move method syntax has these parts:

Part	Description
object	Required. A valid object name.
Left	Optional. Single-precision value, in points, indicating the horizontal coordinate for the left edge of the object.
Top	Optional. Single-precision value, in points, that specifies the vertical coordinate for the top edge of the object.
Width	Optional. Single-precision value, in points, indicating the width of the object.
Height	Optional. Single-precision value, in points, indicating the height of the object.
Layout	Optional. A Boolean value indicating whether the Layout event is initiated for the control's parent following this move. False is the default value.
X, Y	Required. Single-precision value, in points, that specifies the change from the current horizontal and vertical position for each control in the Controls collection.
Remarks

For a form or control, you can move a selection to a specific location relative to the edges of the form that contains the selection.

You can use named arguments, or you can enter the arguments by position. If you use named arguments, you can list the arguments in any order. If not, you must enter the arguments in the order shown, using commas to indicate the relative position of arguments you do not specify. Any unspecified arguments remain unchanged.

For the Controls collection, you can move all the controls in this collection a specific distance from their current positions on a form, Frame, or Page.


Paste Method

Transfers the contents of the Clipboard to an object.

Syntax

object.Paste

The Paste method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

Data pasted into a ComboBox or TextBox is treated as text.

When the paste method is used with a form, you can paste any OLE object onto the form.


PutInClipboard Method

Moves data from a DataObject to the Clipboard.

Syntax

object.PutInClipboard

The PutInClipboard method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

The DataObject and the Clipboard both support multiple formats, but only support one data item of a given format. For example, the DataObject might include one text item stored using the Clipboard format.

If the Clipboard contains data in the same format as new data, the new data replaces the existing data on the Clipboard. If the new data is in a new format, the new data and the new format are both added to the Clipboard.


RedoAction Method

Reverses the effect of the most recent Undo action.

Syntax

Boolean = object.RedoAction

The RedoAction method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

Redo reverses the last Undo, which is not necessarily the last action taken. Not all actions can be undone.

For example, after pasting text into a TextBox and then choosing the Undo command to remove the text, you can choose the Redo command to put the text back in.

Note  If the CanRedo property is False, the Redo command is not available in the user interface, and the RedoAction method is not valid in code.

RedoAction returns True if it was successful.


Remove Method

Removes a member from a collection; or, removes a control from a Frame, Page, or form.

Syntax

object.Remove(  collectionindex)

The Remove method syntax has these parts:

Part	Description
object	Required. A valid object.
collectionindex	Required. A member's position, or index, within a collection. Numeric as well as string values are acceptable. If the value is a number, the minimum value is zero, and the maximum value is one less than the number of members in the collection. If the value is a string, it must correspond to a valid member name.
Remarks

This method deletes any control that was added at run time. However, attempting to delete a control that was added at design time will result in an error.


RemoveItem Method

Removes a row from the list in a list box or combo box.

Syntax

Boolean = object.RemoveItem(  index)

The RemoveItem method syntax has these parts:

Part	Description
object	Required. A valid object.
index	Required. Specifies the row to delete. The number of the first row is 0; the number of the second row is 1, and so on.
This method will not remove a row from the list if the ListBox is data bound (that is, when the RowSource property specifies a data source for the ListBox).


Repaint Method

Updates the display by redrawing the form or page.

Syntax

Boolean = object.Repaint

The Repaint method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

The Repaint method is useful if the contents or appearance of an object changes significantly, and you don't want to wait until the system automatically repaints the area.


Scroll Method

Moves the scroll bar on an object.

Syntax

object.Scroll( [ ActionX [,  ActionY]])

The Scroll method syntax has these parts:

Part	Description
object	Required. A valid object name.
ActionX	Optional. Identifies the action to occur in the horizontal direction.
ActionY	Optional. Identifies the action to occur in the vertical direction.
Settings

The settings for ActionX and ActionY are:

Constant	Value	Description
fmScrollActionNoChange	0	Do not scroll in the specified direction.
fmScrollActionLineUp	1	Move up on a vertical scroll bar or left on a horizontal scroll bar. Movement is equivalent to pressing the up or left arrow key on the keyboard to move the scroll bar.
fmScrollActionLineDown	2	Move down on a vertical scroll bar or right on a horizontal scroll bar. Movement is equivalent to pressing the right or down arrow key on the keyboard to move the scroll bar.
fmScrollActionPageUp	3	Move one pageup on a vertical scroll bar or one page left on a horizontal scroll bar. Movement is equivalent to pressing PAGE UP on the keyboard to move the scroll bar.
fmScrollActionPageDown	4	Move one pagedown on a vertical scroll bar or one page right on a horizontal scroll bar. Movement is equivalent to pressing PAGE DOWN on the keyboard to move the scroll bar.
fmScrollActionBegin	5	Move to the top of a vertical scroll bar or to the left end of a horizontal scroll bar.
fmScrollActionEnd	6	Move to the bottom of a vertical scroll bar or to the right end of a horizontal scroll bar.
Remarks

The Scroll method applies scroll bars that appear on a form, Frame, or Page that is larger than its display area. This method does not apply to the stand-alone ScrollBar or to scroll bars that appear on a TextBox.


SetDefaultTabOrder Method

Sets the TabIndex property of each control on a form, using a default top-to-bottom, left-to-right tab order.

Syntax

object.SetDefaultTabOrder

The SetDefaultTabOrder method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

Microsoft Forms sets the tab order beginning with controls in the upper left corner of the form and moving to the right. It places controls closest to the left edge of the form earlier in the tab order. If more than one control is the same distance from the left edge of the form, tab order values are assigned from top to bottom.


SetFocus Method

Moves the focus to this instance of an object.

Syntax

object.SetFocus

The SetFocus method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

If setting the focus fails, the focus reverts to the previous object and an error is generated.

By default, setting the focus to a control does not activate the control's window or place it on top of other controls.

The SetFocus method is valid for an empty Frame as well as a Frame that contains other controls. An empty Frame will take the focus itself, and any subsequent keyboard events apply to the Frame. In a Frame that contains other controls, the focus moves to the first control in the Frame, and subsequent keyboard events apply to the control that has the focus.


SetText Method

Copies a text string to the Clipboard using a specified format.

Syntax

object.SetText(  StoreData [,  format])

The SetText method syntax has these parts:

Part	Description
object	Required. A valid object.
StoreData	Required. Defines the data to store on the Clipboard.
format	Optional. An integer or string specifying the data format to use when pasting the Clipboard contents.
Settings

The settings for format are:

Constant	Value	Description
fmCFText	1	Text format.
Remarks

The Clipboard stores data according to its format. When the user supplies a string, the Clipboard saves the text under the specified format.

If no format is specified, the SetText method assigns the standard text format to the text string. If a new format is specified, the Clipboard registers the new format with the system.


StartDrag Method

Initiates a drag-and-drop operation for a DataObject.

Syntax

fmDropEffect=Object.StartDrag([Effect as fmDropEffect])

The StartDrag method syntax has these parts:

Part	Description
Object	Required. A valid object.
Effect	Optional. Effect of the drop operation on the target control.
Settings

The settings for Effect are:

Constant	Value	Description
fmDropEffectNone	0	Does not copy or move the drop source to the drop target.
fmDropEffectCopy	1	Copies the drop source to the drop target.
fmDropEffectMove	2	Moves the drop source to the drop target.
fmDropEffectCopyOrMove	3	Copies or moves the drop source to the drop target.
Remarks

The drag action starts at the current mouse pointer position with the current keyboard state and ends when the user releases the mouse. The effect of the drag-and-drop operation depends on the effect chosen for the drop target.

For example, a control’s MouseMove event might include the StartDrag method. When the user clicks the control and moves the mouse, the mouse pointer changes to indicate whether Effect is valid for the drop target.


UndoAction Method

Reverses the most recent action that supports the Undo command.

Syntax

Boolean = object.UndoAction

The UndoAction method syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

The Undo command in the user interface uses the UndoAction method. For example, if you paste text into a TextBox, you can use UndoAction to remove that text and restore the previous contents of the TextBox.

Not all user actions can be undone. If an action cannot be undone, the Undo command is unavailable following the action.

Note  If the CanUndo property is False, the Undo command is not available in the user interface, and UndoAction is not valid in code.

If UndoAction is applied to a form, all changes to the current record are lost. If UndoAction is applied to a control, only the control itself is affected.

You must apply this method before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or a control's Change event.

UndoAction is an alternative to using the SendKeys Statement to send the value of ESC in an event procedure.


ZOrder Method

Places the object at the front or back of the z-order.

Syntax

object.ZOrder( [ zPosition])

The ZOrder method syntax has these parts:

Part	Description
object	Required. A valid object.
zPosition	Optional. A control's position, front or back, in the container's z-order.
Settings

The settings for zPosition are:

Constant	Value	Description
fmTop	0	Places the control at the front of the z-order. The control appears on top of other controls (default).
fmBottom	1	Places the control at the back of the z-order. The control appears underneath other controls.
Remarks

The z-order determines how windows and controls are stacked when they are presented to the user. Items at the back of the z-order are overlaid by closer items; items at the front of the z-order appear to be on top of items at the back. When the zPosition argument is omitted, the object is brought to the front.

In design mode, the Bring to Front or Send To Back commands set the z-order. Bring to Front is equivalent to using the ZOrder method and putting the object at the front of the z-order. Send to Back is equivalent to using ZOrder and putting the object at the back of the z-order.

This method does not affect content or sequence of the controls in the Controls collection.

Note   You can't Undo or Redo layering commands, such as Send to Back or Bring to Front. For example, if you select an object and click Move Backward on the shortcut menu, you won't be able to Undo or Redo that action.


Accelerator Property

Sets or retrieves the accelerator key for a control.

Syntax

object.Accelerator [= String]

The Accelerator property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. The character to use as the accelerator key.
Remarks

To designate an accelerator key, enter a single character for the Accelerator property. You can set Accelerator in the control's property sheet or in code. If the value of this property contains more than one character, the first character in the string becomes the value of Accelerator.

When an accelerator key is used, there is no visual feedback (other than focus) to indicate that the control initiated the Click event. For example, if the accelerator key applies to a CommandButton, the user will not see the button pressed in the interface. The button receives the focus, however, when the user presses the accelerator key.

If the accelerator applies to a Label, the control following the Label in the tab order, rather than the Label itself, receives the focus.


ActiveControl Property

Identifies and allows manipulation of the control that has the focus.

Syntax

object.ActiveControl

The ActiveControl property syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

The ActiveControl property is read-only and is set when you select a control in the interface. You can use ActiveControl as a substitute for the control name when setting properties or calling methods.


Alignment Property

Specifies the position of a control relative to its caption.

Syntax

object.Alignment [= fmAlignment]

The Alignment property syntax has these parts:

Part	Description
object	Required. A valid object.
fmAlignment	Optional. Caption position.
Settings

The settings for fmAlignment are:

Constant	Value	Description
fmAlignmentLeft	0	Places the caption to the left of the control.
fmAlignmentRight	1	Places the caption  to the right of the control (default).
Remarks

The caption text for a control is left-aligned.

Note   Although the ToggleButton supports the Alignment property, changing the property has no effect on the ToggleButton.


AutoSize Property

Specifies whether an object automatically resizes to display its entire contents.

Syntax

object.AutoSize [= Boolean]

The AutoSize property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the control is resized.
Settings

The settings for Boolean are:

Value	Description
True	Automatically resizes the control to display its entire contents.
False	Keeps the size of the control constant. Contents are clipped when they exceed the area of the control (default).
Remarks

For controls with captions, the AutoSize property specifies whether the control automatically adjusts to display the entire caption.

For controls without captions, this property specifies whether the control automatically adjusts to display the information stored in the control. In a ComboBox, for example, setting AutoSize to True automatically sets the width of the display area to match the length of the current text.

For a single-line text box, setting AutoSize to True automatically sets the width of the display area to the length of the text in the text box.

For a multiline text box that contains no text, setting AutoSize to True automatically displays the text as a column. The width of the text column is set to accommodate the widest letter of that font size. The height of the text column is set to display the entire text of the TextBox.

For a multiline text box that contains text, setting AutoSize to True automatically enlarges the TextBox vertically to display ithe entire text. The width of the TextBox does not change.


AutoTab Property

Specifies whether an automatic tab occurs when a user enters the maximum allowable number of characters into a TextBox or the text box portion of a ComboBox.

Syntax

object.AutoTab [= Boolean]

The AutoTab property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Specifies whether an automatic tab occurs.
Settings

The settings for Boolean are:

Value	Description
True	Tab occurs.
False	Tab does not occur (default).
Remarks

The MaxLength property specifies the maximum number of characters allowed in a TextBox or the text box portion of a ComboBox.

You can specify the AutoTab property for a TextBox or ComboBox on a form for which you usually enter a set number of characters. Once a user enters the maximum number of characters, the focus automatically moves to the next control in the tab order. For example, if a TextBox displays inventory stock numbers that are always five characters long, you can use MaxLength to specify the maximum number of characters to enter into the TextBox and AutoTab to automatically tab to the next control after the user enters five characters.

Support for AutoTab varies from one application to another. Not all containers support this property.


AutoWordSelect Property

Specifies whether a word or a character is the basic unit used to extend a selection.

Syntax

object.AutoWordSelect [= Boolean]

The AutoWordSelect property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Specifies the basic unit used to extend a selection.
Settings

The settings for Boolean are:

Value	Description
True	Uses a word as the basic unit (default).
False	Uses a character as the basic unit.
Remarks

The AutoWordSelect property specifies how the selection extends or contracts in the edit region of a TextBox or ComboBox.

If the user places the insertion point in the middle of a word and then extends the selection while AutoWordSelect is True, the selection includes the entire word.


BackColor Property

Specifies the background color of the object.

Syntax

object.BackColor [= Long]

The BackColor property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. A value or constant that determines the background color of an object.
Settings

You can use any integer that represents a valid color. You can also specify a color by using the RGB function with red, green, and blue color components. The value of each color component is an integer that ranges from zero to 255. For example, you can specify teal blue as the integer value 4966415 or as red, green, and blue color components 15, 200, 75.

Remarks

You can only see the background color of an object if the BackStyle property is set to fmBackStyleOpaque.


BackStyle Property

Returns or sets the background style for an object.

Syntax

object.BackStyle [= fmBackStyle]

The BackStyle property syntax has these parts:

Part	Description
object	Required. A valid object.
fmBackStyle	Optional. Specifies the control background.
Settings

The settings for fmBackStyle are:

Constant	Value	Description
fmBackStyleTransparent	0	The background is transparent.
fmBackStyleOpaque	1	The background is opaque (default).
Remarks

The BackStyle property determines whether a control is transparent. If BackStyle is fmBackStyleOpaque, the control is not transparent and you cannot see anything behind the control on a form. If BackStyle is fmBackStyleTransparent, you can see through the control and look at anything on the form located behind the control.

Note  BackStyle does not affect the transparency of bitmaps. You must use a picture editor such as Paintbrush to make a bitmap transparent. Not all controls support transparent bitmaps.


Bold, Italic, Size, StrikeThrough, Underline, Weight Properties

Specifies the visual attributes of text on a displayed or printed form.

Syntax

object.Bold [= Boolean]

object.Italic [= Boolean]

object.Size [= Currency]

object.StrikeThrough [= Boolean]

object.Underline [= Boolean]

object.Weight [= Integer]

The Bold, Italic, Size, StrikeThrough, Underline, and Weight property syntaxes have these parts:

Part	Description
object	Required. A valid object name.
Boolean	Optional. Specifies the font style.
Currency	Optional. A number indicating the font size.
Integer	Optional. Specifies the font style.
The settings for Boolean are:

Value	Description
True	The text has the specified attribute (that is bold, italic, size, strikethrough or underline marks, or weight).
False	The text does not have the specified attribute (default).
The Weight property accepts values from 0 to 1000. A value of zero allows the system to pick the most appropriate weight. A value from 1 to 1000 indicates a specific weight, where 1 represents the lightest type and 1000 represents the darkest type.

Remarks

These properties define the visual characteristics of text. The Bold property determines whether text is normal or bold. The Italic property determines whether text is normal or italic. The Size property determines the height, in points, of displayed text. The Underline property determines whether text is underlined. The StrikeThrough property determines whether the text appears with strikethrough marks. The Weight property determines the darkness of the type.

The font's appearance on screen and in print may differ, depending on your computer and printer. If you select a font that your system can't display with the specified attribute or that isn't installed, Windows substitutes a similar font. The substitute font will be as similar as possible to the font originally requested.

Changing the value of Bold also changes the value of Weight. Setting Bold to True sets Weight to 700; setting Bold to False sets Weight to 400. Conversely, setting Weight to anything over 550 sets Bold to True; setting Weight to 550 or less sets Bold to False.

The default point size is determined by the operating system.


BorderColor Property

Specifies the color of an object's border.

Syntax

object.BorderColor [= Long]

The BorderColor property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. A value or constant that determines the border color of an object.
Settings

You can use any integer that represents a valid color. You can also specify a color by using the RGB function with red, green, and blue color components. The value of each color component is an integer that ranges from zero to 255. For example, you can specify teal blue as the integer value 4966415 or as RGB color component values 15, 200, 75.

Remarks

To use the BorderColor property, the BorderStyle property must be set to a value other than fmBorderStyleNone.

BorderStyle uses BorderColor to define the border colors. The SpecialEffects property uses system colors exclusively to define its border colors. For Windows operating systems, System Color settings are stored in the Control Panel, either in the Desktop folder or the Color folder.


BorderStyle Property

Specifies the type of border used by a control or a form.

Syntax

object.BorderStyle [= fmBorderStyle]

The BorderStyle property syntax has these parts:

Part	Description
object	Required. A valid object.
fmBorderStyle	Optional. Specifies the border style.
Settings

The settings for fmBorderStyle are:

Constant	Value	Description
fmBorderStyleNone	0	The control has no visible border line.
fmBorderStyleSingle	1	The control has a single-line border (default).
The default value for a ComboBox, Frame, Label, ListBox or TextBox is 0 (None). The default value for an Image is 1 (Single).

Remarks

For a Frame, the BorderStyle property is ignored if the SpecialEffect property is None.

You can use either BorderStyle or SpecialEffect to specify the border for a control, but not both. If you specify a nonzero value for one of these properties, the system sets the value of the other property to zero. For example, if you set BorderStyle to fmBorderStyleSingle, the system sets SpecialEffect to zero (Flat). If you specify a nonzero value for SpecialEffect, the system sets BorderStyle to zero.

BorderStyle uses BorderColor to define the colors of its borders.


BoundColumn Property

Identifies the source of data in a multicolumn ComboBox or ListBox.

Syntax

object.BoundColumn [= Variant]

The BoundColumn property syntax has these parts:

Part	Description
object	Required. A valid object.
Variant	Optional. Indicates how the BoundColumn value is selected.
Settings

The settings for Variant are:

Value	Description
0	Assigns the value of the ListIndex property to the control.
1 or greater	Assigns the value from the specified column to the control. Columns are numbered from 1 when using this property (default).
Remarks

When the user chooses a row in a multicolumn ListBox or ComboBox, the BoundColumn property identifies which item from that row to store as the value of the control. For example, if each row contains 8 items and BoundColumn is 3, the system stores the information in the third column of the currently-selected row as the value of the object.

You can display one set of data to users but store different, associated values for the object by using the BoundColumn and the TextColumn properties. TextColumn identifies the column of data displayed in a ComboBox or ListBox; BoundColumn identifies the column of associated data values stored for the control. For example, you could set up a multicolumn ListBox that contains the names of holidays in one column and dates for the holidays in a second column. To present the holiday names to users, specify the first column as the TextColumn. To store the dates of the holidays, specify the second column as the BoundColumn.

If the control is bound to a data source, the value in the column specified by BoundColumn is stored in the data source named in the ControlSource property.

The ListIndex value retrieves the number of the selected row. For example, if you want to know the row of the selected item, set BoundColumn to 0 to assign the number of the selected row as the value of the control. Be sure to retrieve a current value, rather than relying on a previously saved value, if you are referencing a list whose contents might change.

The Column, List, and ListIndex properties all use zero-based numbering. That is, the value of the first item (column or row) is zero; the value of the second item is one, and so on. This means that if BoundColumn is set to 3, you could access the value stored in that column using the expression Column(2).


Cancel Property

Returns or sets a value indicating whether a command button is the Cancel button on a form.

Syntax

object.Cancel [= Boolean]

The Cancel property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the object is the Cancel button.
Settings

The settings for Boolean are:

Value	Description
True	The CommandButton is the Cancel button.
False	The CommandButton is not the Cancel button (default).
Remarks

A CommandButton or an object that acts like a command button can be designated as the default command button. For OLE container controls, the Cancel property is provided only for those objects that specifically behave as command buttons.

Only one CommandButton on a form can be the Cancel button. Setting Cancel to True for one command button automatically sets it to False for all other objects on the form. When a CommandButton's Cancel property is set to True and the form is the active form, the user can choose the command button by clicking it, pressing ESC, or pressing ENTER when the button has the focus.

Use Cancel to give the user the option of canceling uncommitted changes and returning the form to its previous state.

You should consider making the Cancel button the default button for forms that support operations that can’t be undone (such as delete). To do this, set both Cancel and the Default property to True.


CanPaste Property

Specifies whether the Clipboard contains data that the object supports.

Syntax

object.CanPaste [ =Boolean]

The CanPaste property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Specifies whether a paste operation can be performed.
Return Values

The CanPaste property return values are:

Value	Description
True	The object underneath the mouse pointer can receive information pasted from the Clipboard (default).
False	The object underneath the mouse pointer cannot receive information pasted from the Clipboard.
Remarks

If the Clipboard data is in a format that the current target object does not support, the CanPaste property is False. For example, if you try to paste a bitmap into an object that only supports text, CanPaste will be False.


CanRedo Property

Indicates whether the most recent Undo can be reversed.

Syntax

object.CanRedo [ =Boolean]

The CanRedo property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Specifies whether the most recent Undo can be canceled.
Return Values

The CanRedo property return values are:

Value	Description
True	The most recent Undo can be reversed.
False	The most recent Undo is irreversible.
Remarks

To Redo an action means to reverse an Undo; it does not necessarily mean to repeat the last user action.

The following user actions illustrate using Undo and Redo:

1.	Change the setting of an option button.

2.	Enter text into a text box.

3.	Click Undo. The text disappears from the text box.

4.	Click Undo. The option button reverts to its previous setting.

5.	Click Redo. The value of the option button changes.

6.	Click Redo. The text reappears in the text box.


CanUndo Property

Indicates whether the last user action can be undone.

Syntax

object.CanUndo [ =Boolean]

The CanUndo property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Specifies whether the most recent user action can be undone.
Return Values

The CanUndo property return values are:

Value	Description
True	The most recent user action can be undone.
False	The most recent user action cannot be undone.
Remarks

Many user actions can be undone with the Undo command. The CanUndo property indicates whether the most recent action can be undone.


Caption Property

Descriptive text that appears on an object to identify or describe it.

Syntax

object.Caption [= String]

The Caption property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. A string expression that evaluates to the text displayed as the caption.
Settings

The default setting for a control is a unique name based on the type of control. For example, CommandButton1 is the default caption for the first command button in a form.

Remarks

The text identifies or describes the object with which it is associated. For buttons and labels, the Caption property specifies the text that appears in the control. For Page and Tab objects, it specifies the text that appears on the tab.

If a control's caption is too long, the caption is truncated. If a form's caption is too long for the title bar, the title is displayed with an ellipsis.

The ForeColor property of the control determines the color of the text in the caption.

Tip  If a control has both the Caption and AutoSize properties, setting AutoSize to True automatically adjusts the size of the control to frame the entire caption.


ClientHeight, ClientLeft, ClientTop, ClientWidth Properties

Define the dimensions and location of the display area of a TabStrip.

Syntax

object.ClientHeight [ =Single]

object.ClientLeft [ =Single]

object.ClientTop [ =Single]

object.ClientWidth [ =Single]

The ClientHeight, ClientLeft, ClientTop, and ClientWidth property syntaxes have these parts:

Part	Description
object	Required. A valid object.
Single	Optional. For ClientHeight and ClientWidth, specifies the height or width, in points, of the display area. For ClientLeft and ClientTop, specifies the distance, in points, from the top or left edge of the TabStrip’s container.
Remarks

At run time, ClientLeft, ClientTop, ClientHeight, and ClientWidth automatically store the coordinates and dimensions of the TabStrip's internal area, which is shared by objects in the TabStrip.


Column Property

Specifies one or more items in a ListBox or ComboBox.

Syntax

object.Column( column, row ) [= Variant]

The Column property syntax has these parts:

Part	Description
object	Required. A valid object.
column	Optional. An integer with a range from 0 to one less than the total number of columns.
row	Optional. An integer with a range from 0 to one less than the total number of rows.
Variant	Optional. Specifies a single value, a column of values, or a two-dimensional array to load into a ListBox or ComboBox.
Settings

If you specify both the column and row values, Column reads or writes a specific item.

If you specify only the column value, the Column property reads or writes the specified column in the current row of the object. For example, MyListBox.Column (3) reads or writes the third column in MyListBox.

Column returns a Variant from the cursor. When a built-in cursor provides the value for Variant (such as when using the AddItem method), the value is a string. When an external cursor provides the value for Variant, formatting associated with the data is not included in the Variant.

Remarks

You can use Column to assign the contents of a combo box or list box to another control, such as a text box. For example, you can set the ControlSource property of a text box to the value in the second column of a list box.

If the user makes no selection when you refer to a column in a combo box or list box, the Column setting is Null. You can check for this condition by using the IsNull function.

You can also use Column to copy an entire two-dimensional array of values to a control. This syntax lets you quickly load a list of choices rather than individually loading each element of the list using AddItem.

Note  When copying data from a two-dimensional array, Column transposes the contents of the array in the control so that the contents of ListBox1.Column(X, Y) is the same as MyArray(Y, X). You can also use List to copy an array without transposing it.


ColumnCount Property

Specifies the number of columns to display in a list box or combo box.

Syntax

object.ColumnCount [= Long]

The ColumnCount property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. Specifies the number of columns to display.
Remarks

If you set the ColumnCount property for a list box to 3 on an employee form, one column can list last names, another can list first names, and the third can list employee ID numbers.

Setting ColumnCount to 0 displays zero columns, and setting it to -1 displays all the available columns. For an unbound data source, there is a 10-column limit (0 to 9).

You can use the ColumnWidths property to set the width of the columns displayed in the control.


ColumnHeads Property

Displays a single row of column headings for list boxes, combo boxes, and OLE objects that accept column headings.

Syntax

object.ColumnHeads [= Boolean]

The ColumnHeads property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Specifies whether the column headings are displayed.
Settings

The settings for Boolean are:

Value	Description
True	Display column headings.
False	Do not display column headings (default).
Headings in combo boxes appear only when the list drops down.

Remarks

When the system uses the first row of data items as column headings, they can't be selected.


ColumnWidths Property

Specifies the width of each column in a multicolumn combo box or list box.

Syntax

object.ColumnWidths [= String]

The ColumnWidths property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. Sets the column width in points. A setting of –1 or blank results in a calculated width. A width of 0 hides a column. To specify a different unit of measurement, include the unit of measure. A value greater than 0 explicitly specifies the width of the column.
Settings

To separate column entries, use semicolons (;) as list separators. Or use the list separator specified in the Regional Settings section of the Windows Control Panel.

Any or all of the ColumnWidths property settings can be blank. You create a blank setting by typing a list separator without a preceding value.

If you specify a –1 in the property page, the displayed value in the property page is a blank.

To calculate column widths when ColumnWidths is blank or –1, the width of the control is divided equally among all columns of the list. If the sum of the specified column widths exceeds the width of the control, the list is left-aligned within the control and one or more of the rightmost columns are not displayed. Users can scroll the list using the horizontal scroll bar to display the rightmost columns.

The minimum calculated column width is 72 points (1 inch). To produce columns narrower than this, you must specify the width explicitly.

Unless specified otherwise, column widths are measured in points. To specify another unit of measure, include the units as part of the values. The following examples specify column widths in several units of measure and describe how the various settings would fit in a three-column list box that is 4 inches wide.

Setting	Effect
90;72;90	The first column is 90 points (1.25 inch); the second column is 72 points (1 inch); the third column is 90 points.
6 cm;0;6 cm	The first column is 6 centimeters; the second column is hidden; the third column is 6 centimeters. Because part of the third column is visible, a horizontal scroll bar appears.
1.5 in;0;2.5 in	The first column is 1.5 inches, the second column is hidden, and the third column is 2.5 inches.
2 in;;2 in	The first column is 2 inches, the second column is 1 inch (default), and the third column is 2 inches. Because only half of the third column is visible, a horizontal scroll bar appears.
(Blank)	All three columns are the same width (1.33 inches).
Remarks

In a combo box, the system displays the column designated by the TextColumn property in the text box portion of the control.


ControlSource Property

Identifies the data location used to set or store the Value property of a control.

Syntax

object.ControlSource [= String]

The ControlSource property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. Specifies the worksheet cell linked to the Value property of a control.
Remarks

The ControlSource property identifies a cell or field; it does not contain the data stored in the cell or field. If you change the Value of the control, the change is automatically reflected in the linked cell or field. Similarly, if you change the value of the linked cell or field, the change is automatically reflected in the Value of the control.

The default value for ControlSource is an empty string. If ControlSource contains a value other than an empty string, it identifies a linked cell or field. The contents of that cell or field are automatically copied to the Value property when the control is loaded.

Note  If the Value property is Null, no value appears in the location identified by ControlSource.


ControlTipText Property

Specifies text that appears when the user briefly holds the mouse pointer over a control without clicking.

Syntax

object.ControlTipText [= String]

The ControlTipText property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. The text that appears when the user holds the mouse pointer over a control.
Remarks

The ControlTipText property lets you give users tips about a control in a running form. The property can be set during design time but only appears by the control during run time.

The default value of ControlTipText is an empty string. When the value of ControlTipText is set to an empty string, no tip is available for that control.


Count Property

Returns the number of objects in a collection.

Syntax

object.Count

The Count property syntax has these parts:

Part	Description
object	Required. A valid object.
Remarks

The Count property is read only.

Note that the index value for the first page or tab of a collection is zero, the value for the second page or tab is one, and so on. For example, if a MultiPage contains two pages, the indexes of the pages are 0 and 1, and the value of Count is 2.


CurLine Property

Specifies the current line of a control.

Syntax

object.CurLine [= Long]

The CurLine property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. Specifies the current line of a control.
Remarks

The current line of a control is the line that contains the insertion point. The number of the first line is zero.

The CurLine property is valid when the control has the focus.


CurTargetX Property

Retrieves the preferred horizontal position of the insertion point in a multiline TextBox or ComboBox.

Syntax

object.CurTargetX [ =Long]

The CurTargetX property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. Indicates the preferred position, measured in himetric units. A himetric is 0.0001 meter.
Remarks

The target position is relative to the left edge of the control. If the length of a line is less than the value of the CurTargetX property, you can place the insertion point at the end of the the line. The value of CurTargetX changes when the user sets the insertion point or when the CurX property is set. CurTargetX is read-only.

The return value is valid when the object has focus.

You can use CurTargetX and CurX to move the insertion point as the user scrolls through the contents of a multiline TextBox or ComboBox. When the user moves the insertion point to another line of text by scrolling the content of the object, CurTargetX specifies the preferred position for the insertion point. CurX is set to this value if the line of text is longer than the value of CurTargetX. Otherwise, CurX is set to the end of the line of text.


CurX Property

Specifies the current horizontal position of the insertion point in a multiline TextBox or ComboBox.

Syntax

object.CurX [= Long]

The CurX property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. Indicates the current position, measured in himetrics. A himetric is 0.0001 meter.
Remarks

The CurX property applies to a multiline TextBox or ComboBox. The return value is valid when the object has the focus.

You can use CurTargetX and CurX to position the insertion point as the user scrolls through the contents of a multiline TextBox or ComboBox. When the user moves the insertion point to another line of text by scrolling the content of the object, CurTargetX specifies the preferred position for the insertion point. CurX is set to this value if the line of text is longer than the value of CurTargetX. Otherwise, CurX is set to the end of the line of text.


Cycle Property

Specifies the action to take when the user leaves the last control on a Frame or Page.

Syntax

object.Cycle [= fmCycle]

The Cycle property syntax has these parts:

Part	Description
object	Required. A valid object.
fmCycle	Optional. Specifies whether cycling includes controls nested in a Frame or MultiPage.
Settings

The settings for fmCycle are:

Constant	Value	Description
fmCycleAllForms	0	Cycles through the controls on the form and the controls of the Frame and MultiPage controls that are currently displayed on the form.
fmCycleCurrentForm	2	Cycles through the controls on the form, Frame, or MultiPage. The focus stays within the form, Frame, or MultiPage until the focus is explicitly set to a control outside the form, Frame, or MultiPage.
Remarks

The tab order identifies the order in which controls receive the focus as the user tabs through a form or subform. The Cycle property determines the action to take when a user tabs from the last control in the tab order.

The fmCycleAllForms setting transfers the focus to the the first control of the next Frame or MultiPage on the form when the user tabs from the last control in the tab order.

The fmCycleCurrentForm setting transfers the focus to the the first control of the same form, Frame, or MultiPage when the user tabs from the last control in the tab order.


Default Property

Designates the default command button on a form.

Syntax

object.Default [= Boolean]

The Default property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the command button is the default.
Settings

The settings for Boolean are:

Value	Description
True	The CommandButton is the default button.
False	The CommandButton is not the default button (default).
Remarks

A CommandButton or an object that acts like a command button can be designated as the default command button. Only one object on a form can be the default command button. Setting the Default property to True for one object automatically sets it to False for all other objects on the form.

To choose the default command button on an active form, the user can click the button, or press ENTER when no other CommandButton has the focus. Either of these actions sends keyboard events (KeyDown, KeyPress, or KeyUp) to the default command button, unless the user has moved the focus to another command button on the same form.

Default is provided for OLE container controls that specifically act like CommandButton controls.

Tip  You should consider making the Cancel button the default button for forms that support operations that can’t be undone (such as delete). To do this, set both Default and the Cancel property to True.


Delay Property

Specifies the delay for the SpinUp, SpinDown, and Change events on a SpinButton or ScrollBar.

Syntax

object.Delay [= Long]

The Delay property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. The delay, in milliseconds, between events.
Remarks

The Delay property affects the amount of time between consecutive SpinUp, SpinDown, and Change events generated when the user clicks and holds down a button on a SpinButton or ScrollBar. The first event occurs immediately. The delay to the second occurrence of the event is five times the value of the specified Delay. This initial lag makes it easy to generate a single event rather than a stream of events.

After the initial lag, the interval between events is the value specified for Delay.

The default value of Delay is 50 milliseconds. This means the object initiates the first event after 250 milliseconds (5 times the specified value) and initiates each subsequent event after 50 milliseconds.


DragBehavior Property

Specifies whether the system enables the drag-and-drop feature for a TextBox or ComboBox.

Syntax

object.DragBehavior [= fmDragBehavior]

The DragBehavior property syntax has these parts:

Part	Description
object	Required. A valid object.
fmDragBehavior	Optional. Specifies whether the drag-and-drop feature is enabled.
Settings

The settings for fmDragBehavior are:

Constant	Value	Description
fmDragBehaviorDisabled	0	Does not allow a drag-and-drop action (default).
fmDragBehaviorEnabled	1	Allows a drag-and-drop action.
Remarks

If the DragBehavior property is enabled, dragging in a text box or combo box starts a drag-and-drop operation on the selected text. If DragBehavior is disabled, dragging in a text box or combo box selects text.

The drop-down portion of a ComboBox does not support drag-and-drop processes, nor does it support selection of list items within the text.

DragBehavior has no effect on a ComboBox whose Style property is set to fmStyleDropDownList.

Note  You can combine the effects of the EnterFieldBehavior property and DragBehavior to create a large number of text box styles.


DrawBuffer Property

Specifies the number of pixels set aside for off-screen memory in rendering a frame.

Syntax

object.DrawBuffer [= value]

Part	Description
object	Required. A valid object name.
value	An integer from 16,000 through 1,048,576 equal to the maximum number of pixels the object can render off-screen.
Remarks

The DrawBuffer property specifies the maximum number of pixels that can be drawn at one time as the display repaints. The actual memory used by the object depends upon the screen resolution of the display. If you set a large value for DrawBuffer, performance will be slower. A large buffer only helps when several large images overlap.

Use the Properties window to specify the value of DrawBuffer.


DropButtonStyle Property

Specifies the symbol displayed on the drop button in a ComboBox.

Syntax

object.DropButtonStyle [= fmDropButtonStyle]

The DropButtonStyle property syntax has these parts:

Part	Description
object	Required. A valid object.
fmDropButtonStyle	Optional. The appearance of the drop button.
Settings

The settings for fmDropButtonStyle are:

Constant	Value	Description
fmDropButtonStylePlain	0	Displays a plain button, with no symbol.
fmDropButtonStyleArrow	1	Displays a down arrow (default).
fmDropButtonStyleEllipsis	2	Displays an ellipsis ().
fmDropButtonStyleReduce	3	Displays a horizontal line like an underscore character.
Remarks

The recommended setting for showing items in a list is fmDropButtonStyleArrow. If you want to use the drop button in another way, such as to display a dialog box, specify fmDropButtonStyleEllipsis, fmDropButtonStylePlain, or fmDropButtonStyleReduce and trap the DropButtonClick event.


Enabled Property

Specifies whether a control can receive the focus and respond to user-generated events.

Syntax

object.Enabled [= Boolean]

The Enabled property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the object can respond to user-generated events.
Settings

The settings for Boolean are:

Value	Description
True	The control can receive the focus and respond to user-generated events, and is accessible through code (default).
False	The user cannot interact with the control by using the mouse, keystrokes, accelerators, or hotkeys. The control is generally still accessible through code.
Remarks

Use the Enabled property to enable and disable controls. A disabled control appears dimmed, while an enabled control does not. Also, if a control displays a bitmap, the bitmap is dimmed whenever the control is dimmed.

The Enabled and Locked properties work together to achieve the following effects:

•	If Enabled and Locked are both True, the control can receive focus and appears normally (not dimmed) in the form. The user can copy, but not edit, data in the control.

•	If Enabled is True and Locked is False, the control can receive focus and appears normally in the form. The user can copy and edit data in the control.

•	If Enabled is False and Locked is True, the control cannot receive focus and is dimmed in the form. The user can neither copy nor edit data in the control.

•	If Enabled and Locked are both False, the control cannot receive focus and is dimmed in the form. The user can neither copy nor edit data in the control.

You can combine the settings of the Enabled and the TabStop properties to prevent the user from selecting a command button with TAB, while still allowing the user to click the button. Setting TabStop to False means that the command button won't appear in the tab order. However, if Enabled is True, then the user can still click the command button, as long as TakeFocusOnClick is set to True.

When the user tabs into an enabled MultiPage or TabStrip, the first page or tab in the control receives the focus. If the first page or tab of a MultiPage or TabStrip is disabled, the first enabled page or tab of that control receives the focus. If all pages or tabs of a MultiPage or TabStrip are disabled, the control is disabled and cannot receive the focus.

If a Frame is disabled, all controls it contains are disabled.


EnterFieldBehavior Property

Specifies the selection behavior when entering a TextBox or ComboBox.

Syntax

object.EnterFieldBehavior [= fmEnterFieldBehavior]

The EnterFieldBehavior property syntax has these parts:

Part	Description
object	Required. A valid object.
fmEnterFieldBehavior	Optional. The desired selection behavior.
Settings

The settings for fmEnterFieldBehavior are:

Constant	Value	Description
fmEnterFieldBehaviorSelectAll	0	Selects the entire contents of the edit region when entering the control (default).
fmEnterFieldBehaviorRecallSelection	1	Leaves the selection unchanged. Visually, this uses the selection that was in effect the last time the control was active.
Remarks

The EnterFieldBehavior property controls the way text is selected when the user tabs to the control, not when the control receives focus as a result of the SetFocus method. Following SetFocus, the contents of the control are not selected and the insertion point appears after the last character in the control’s edit region.


EnterKeyBehavior Property

Defines the effect of pressing ENTER in a TextBox.

Syntax

object.EnterKeyBehavior [= Boolean]

The EnterKeyBehavior property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Specifies the effect of pressing ENTER.
Settings

The settings for Boolean are:

Value	Description
True	Pressing ENTER creates a new line.
False	Pressing ENTER moves the focus to the next object in the tab order (default).
Remarks

The EnterKeyBehavior and MultiLine properties are closely related. The values described above only apply if MultiLine is True. If MultiLine is False, pressing ENTER always moves the focus to the next control in the tab order regardless of the value of EnterKeyBehavior.

The effect of pressing CTRL+ENTER also depends on the value of MultiLine. If MultiLine is True, pressing CTRL+ENTER creates a new line regardless of the value of EnterKeyBehavior. If MultiLine is False, pressing CTRL+ENTER has no effect.


ForeColor Property

Specifies the foreground color of an object.

Syntax

object.ForeColor [= Long]

The ForeColor property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. A value or constant that determines the foreground color of an object.
Settings

You can use any integer that represents a valid color. You can also specify a color by using the RGB function with red, green, and blue color components. The value of each color component is an integer that ranges from zero to 255. For example, you can specify teal blue as the integer value 4966415 or as red, green, and blue color components 15, 200, 75.

Remarks

Use the ForeColor property for controls on forms to make them easy to read or to convey a special meaning. For example, if a text box reports the number of units in stock, you can change the color of the text when the value falls below the reorder level.

For a ScrollBar or SpinButton, ForeColor sets the color of the arrows. For a Frame, ForeColor changes the color of the caption. For a Font object, ForeColor determines the color of the text.


GroupName Property

Creates a group of mutually exclusive OptionButton controls.

Syntax

object.GroupName [= String]

The GroupName property syntax has these parts:

Part	Description
object	Required. A valid OptionButton.
String	Optional. The name of the group that includes the OptionButton. Use the same setting for all buttons in the group. The default setting is an empty string.
Remarks

To create a group of mutually exclusive OptionButton controls, you can put the buttons in a Frame on your form, or you can use the GroupName property. GroupName is more efficient for the following reasons:

•	You do not have to include a Frame for each group. By not using a Frame, you reduce the number of controls on the form, and in turn, improve performance and reduce the size of the form.

•	You have more design flexibility. If you use a Frame to create the group, all the buttons must be inside the Frame. If you want more than one group, you must have one Frame for each group. However, if you use GroupName to create the group, the group can include option buttons anywhere on the form. If you want more than one group, specify a unique name for each group; you can still place the individual controls anywhere on the form.

•	You can create buttons with transparent backgrounds, which can improve the visual appearance of your form. The Frame is not a transparent control.

Regardless of which method you use to create the group of buttons, clicking one button in a group sets all other buttons in the same group to False. All option buttons with the same GroupName within a single container are mutually exclusive. You can use the same group name in two containers, but doing so creates two groups (one in each container) rather than one group that includes both containers.

For example, assume your form includes some option buttons and a MultiPage that also includes option buttons. The option buttons on the MultiPage are one group and the buttons on the form are another group. The two groups do not affect each other. Changing the setting of a button on the MultiPage does not affect the buttons on the form.


Height, Width Properties

The height or width, in points, of an object.

Syntax

object.Height [= Single]

object.Width [= Single]

The Height and Width property syntaxes have these parts:

Part	Description
object	Required. A valid object.
Single	Optional. A numeric expression specifying the dimensions of an object.
Remarks

The Height and Width properties are automatically updated when you move or size a control. If you change the size of a control, the Height or Width property stores the new height or width and the OldHeight or OldWidth property stores the previous height or width. If you specify a setting for the Left or Top property that is less than zero, that value will be used to calculate the height or width of the control, but a portion of the control will not be visible on the form.

If you move a control from one part of a form to another, the setting of Height or Width only changes if you size the control as you move it. The settings of the control’s Left and Top properties will change to reflect the control’s new position relative to the edges of the form that contains it.

The value assigned to Height or Width must be greater than or equal to zero. For most systems, the recommended range of values is from 0 to +32,767. Higher values may also work depending on your system configuration.


HelpContextID Property

Associates a specific topic in a custom Microsoft Windows Help file with a specific control.

Syntax

object.HelpContextID [= Long]

The HelpContextID property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. A positive integer specifies the context ID of a topic in the Help file associated with the object. Zero indicates no Help topic is associated with the object (default). Must be a valid context ID in the specified Help file.
Remarks

The topic identified by the HelpContextID property is available to users when a form is running. To display the topic, the user must either select the control or set focus to the control, and then press F1.

The HelpContextID property refers to a topic in a custom Help file you have created to describe your form or application. In Visual Basic, the custom Help file is a property of the project.


HideSelection Property

Specifies whether selected text remains highlighted when a control does not have the focus.

Syntax

object.HideSelection [= Boolean]

The HideSelection property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the selected text remains highlighted even when the control does not have the focus.
Settings

The settings for Boolean are:

Value	Description
True	Selected text is not highlighted unless the control has the focus (default).
False	Selected text always appears highlighted.
Remarks

You can use the HideSelection property to maintain highlighted text when another form or a dialog box receives the focus, such as in a spell-checking procedure.


IMEMode Property

Specifies the default run time mode of the Input Method Editor (IME) for a control. This property applies only to applications written for the Far East and is ignored in other applications.

Syntax

object.IMEMode [= fmIMEMode]

The IMEMode property syntax has these parts:

Part	Description
object	Required. A valid object.
fmIMEMode	Optional. The mode of the Input Method Editor (IME).
Settings

The settings for fmIMEMode are:

Constant	Value	Description
fmIMEModeNoOp	0	Does not control IME (default).
fmIMEModeOn	1	IME on.
fmIMEModeOff	2	IME off. English mode.
fmIMEModeDisable	3	IME off. User can't turn on IME by keyboard.
fmIMEModeHiragana	4	IME on with Full-width Hiragana mode.
fmIMEModeKatakanaDbl	5	IME on with Full-width Katakana mode.
fmIMEModeKatakanaSng	6	IME on with Half-width Katakana mode.
fmIMEModeAlphaDbl	7	IME on with Full-width Alphanumeric mode.
fmIMEModeAlphaSng	8	IME on with Half-width Alphanumeric mode.
The fmIMEModeNoOp setting indicates that the mode of the IME does not change when the control receives focus at run time. For any other value, the mode of the IME is set to the value specified by the IMEMode property when the control receives focus at run time.

Remarks

There are two ways to set the mode of the IME. One is through the toolbar of the IME. The other is with the IMEMode property of a control, which sets or returns the current mode of the IME. This property allows dynamic control of the IME through code.

The following example explains how IMEMode interacts with the toolbar of the IME. Assume that you have designed a form with TextBox1 and CheckBox1. You have set TextBox1.IMEMode to 0, and you have set CheckBox1.IMEMode to 1. While in design mode you have used the IME toolbar to put the IME in mode 2.

When you run the form, the IME begins in mode 2. If you click TextBox1, the IME mode does not change because IMEMode for this control is 0. If you click CheckBox1, the IME changes to mode 1, because IMEMode for this control is 1. If you click again on TextBox1, the IME remains in mode 1 (IMEMode is 0, so the IME retains its last setting).

However, you can override IMEMode. For example, assume you click CheckBox1 and the IME enters mode 1, as defined by IMEMode for the CheckBox. If you then use the IME toolbar to put the IME in mode 3, then the IME will be set to mode 3 anytime you click the control. This does not change the value of the property, it overrides the property until the next time you run the form.


Index Property

The position of a Tab object within a Tabs collection or a Page object in a Pages collection.

Syntax

object.Index [= Integer]

The Index property syntax has these parts:

Part	Description
object	Required. A valid object.
Integer	Optional. The index of the currently selected Tab object.
Remarks

The Index property specifies the order in which tabs appear. Changing the value of Index visually changes the order of Pages in a MultiPage or Tabs on a TabStrip. The index value for the first page or tab is zero, the index value of the second page or tab is one, and so on.

In a MultiPage, Index refers to a Page as well as the page’s Tab. In a TabStrip, Index refers to the tab only.


InsideHeight, InsideWidth Properties

InsideHeight returns the height, in points, of the client region inside a form. InsideWidth returns the width, in points, of the client region inside a form.

Syntax

object.InsideHeight [ =Single]

object.InsideWidth [ =Single]

The InsideHeight and InsideWidth property syntaxes have these parts:

Part	Description
object	Required. A valid object.
Single	Optional. The height or width of the client region.
Remarks

If the region includes a scroll bar, the returned value does not include the height or width of the scroll bar.


IntegralHeight Property

Indicates whether a ListBox or TextBox displays full lines of text in a list or partial lines.

Syntax

object.IntegralHeight [= Boolean]

The IntegralHeight property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the list displays partial lines of text.
Settings

The settings for Boolean are:

Value	Description
True	The list resizes itself to display only complete items (default).
False	The list does not resize itself even if the item is too tall to display completely.
Remarks

The IntegralHeight property relates to the height of the list, just as the AutoSize property relates to the width of the list.

If IntegralHeight is True, the list box automatically resizes when necessary to show full rows. If False, the list remains a fixed size; if items are taller than the available space in the list, the entire item is not shown.


TakeFocusOnClick Property

Specifies whether a control takes the focus when clicked.

Syntax

object.TakeFocusOnClick [= Boolean]

The TakeFocusOnClick property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Specifies whether a control takes the focus when clicked.
Settings

The settings for Boolean are:

Value	Description
True	The button takes the focus when clicked (default).
False	The button does not take the focus when clicked.
Remarks

The TakeFocusOnClick property defines only what happens when the user clicks a control. If the user tabs to the control, the control takes the focus regardless of the value of TakeFocusOnClick.

Use this property to complete actions that affect a control without requiring that control to give up focus. For example, assume your form includes a TextBox and a CommandButton that checks for correct spelling of text. You would like to be able to select text in the TextBox, then click the CommandButton and run the spelling checker without taking focus away from the TextBox. You can do this by setting the TakeFocusOnClick property of the CommandButton to False.


KeepScrollBarsVisible Property

Specifies whether scroll bars remain visible when not required.

Syntax

object.KeepScrollBarsVisible [= fmScrollBars]

The KeepScrollBarsVisible property syntax has these parts:

Part	Description
object	Required. A valid object.
fmScrollBars	Optional. Where scroll bars are displayed.
Settings

The settings for fmScrollBars are:

Constant	Value	Description
fmScrollBarsNone	0	Displays no scroll bars.
fmScrollBarsHorizontal	1	Displays a horizontal scroll bar.
fmScrollBarsVertical	2	Displays a vertical scroll bar.
fmScrollBarsBoth	3	Displays both a horizontal and a vertical scroll bar (default).
Remarks

If the visible region is large enough to display all the controls on an object such as a Page object or a form, scroll bars are not required. The KeepScrollBarsVisible property determines whether the scroll bars remain visible when they are not required.

If the scroll bars are visible when they are not required, they appear normal in size, and the scroll box fills the entire width or height of the scroll bar.


LargeChange Property

Specifies the amount of movement that occurs when the user clicks between the scroll box and scroll arrow.

Syntax

object.LargeChange [= Long]

The LargeChange property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. An integer that specifies the amount of change to the Value property.
Remarks

The LargeChange property applies only to the ScrollBar. It does not apply to the scrollbars in other controls such as a TextBox or a drop-down ComboBox.

The value of LargeChange is the amount by which the ScrollBar’s Value property changes when the user clicks the area between the scroll box and scroll arrow. The direction of the movement is always toward the place where the user clicks. For example, in a horizontal ScrollBar, clicking to the left of the scroll box moves the scroll box to the left. In a vertical ScrollBar, clicking above the scroll box moves the scroll box up.

LargeChange does not have units. Any integer is a valid setting for LargeChange. The recommended range of values is from –32,767 to +32,767, and the value must be between the values of the Max and Min properties of the ScrollBar.


LayoutEffect Property

Specifies whether a control was moved during a layout change.

Syntax

object.LayoutEffect [ =fmLayoutEffect]

The LayoutEffect property syntax has these parts:

Part	Description
object	Required. A valid object.
fmLayoutEffect	Optional. Whether the control moved.
Return Values

The fmLayoutEffect argument has the following values:

Constant	Value	Description
fmLayoutEffectNone	0	The control was not moved.
fmLayoutEffectInitiate	1	The control moved.
Remarks

The LayoutEffect property is available only in the Layout event. The Layout event is initiated by the Move method if the Layout argument is True.

The Layout event is not initiated when you change the settings of the Left, Top, Height, or Width properties of a control.

The Layout event sets LayoutEffect for any control that was involved in a move operation. For example, if you move a group of controls, LayoutEffect of each control is set.


Left, Top Properties

The distance between a control and the left or top edge of the form that contains it.

Syntax

object.Left [= Single]

object.Top [= Single]

The Left and Top property syntaxes have these parts:

Part	Description
object	Required. A valid object.
Single	Optional. A numeric expression specifying the coordinates of an object.
Settings

Setting the Left or Top property to 0 places the control's edge at the left or top edge of its container.

Remarks

For most systems, the recommended range of values for Left and Top is from -32,767 to +32,767. Other values may also work depending on your sytem configuration. For a ComboBox, values of Left and Top apply to the text portion of the control, not to the list portion. When you move or size a control, its new Left setting is automatically entered in the property sheet. When you print a form, the control's horizontal or vertical location is determined by its Left or Top setting.


LineCount Property

Returns the number of text lines in a TextBox or ComboBox.

Syntax

object.LineCount [ =Long]

The LineCount property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Return value. Specifies the number of text lines in the control.
Remarks

The LineCount property is read-only. The returned value is from 0 to one less than the value of LineCount.

Note  A ComboBox will only have one line.


List Property

Returns or sets the list entries of a ListBox or ComboBox.

Syntax

object.List( row, column ) [= Variant]

The List property syntax has these parts:

Part	Description
object	Required. A valid object.
row	Required. An integer with a range from 0 to one less than the number of entries in the list.
column	Required. An integer with a range from 0 to one less than the number of columns.
Variant	Optional. The contents of the specified entry in the ListBox or ComboBox.
Settings

Row and column numbering begins with zero. That is, the row number of the first row in the list is zero; the column number of the first column is zero. The number of the second row or column is 1, and so on.

Remarks

The List property works with the ListCount and ListIndex properties.Use List to access list items. A list is a variant array; each item in the list has a row number and a column number.

Initially, ComboBox and ListBox contain an empty list.

Note  To specify items you want to display in a ComboBox or ListBox, use the AddItem method. To remove items, use the RemoveItem method.

You can also use List to copy an entire two-dimensional array of values to a control. This lets you quickly load a list of choices rather than using AddItem to individually load each element of the list.


ListCount Property

Returns the number of list entries in a control.

Syntax

Long=object.ListCount

The ListCount property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Return value. Reports the number of entries in a control. The default value is zero (0).
Remarks

The ListCount property is read-only. ListCount is the number of rows over which you can scroll. ListRows is the maximum to display at once. ListCount is always one greater than the largest value for the ListIndex property, because index numbers begin with 0 and the count of items begins with 1. If no item is selected, ListCount is 0 and ListIndex is –1.


ListIndex Property

Identifies the currently selected item in a ListBox or ComboBox.

Syntax

object.ListIndex [= Variant]

The ListIndex property syntax has these parts:

Part	Description
object	Required. A valid object.
Variant	Optional. The currently selected item in the control.
Remarks

The ListIndex property contains an index of the selected row in a list. Values of ListIndex range from –1 to one less than the total number of rows in a list (that is, ListCount – 1). When no rows are selected, ListIndex returns –1. When the user selects a row in a ListBox or ComboBox, the system sets the ListIndex value. The ListIndex value of the first row in a list is 0, the value of the second row is 1, and so on.

Note  If you use the MultiSelect property to create a ListBox that allows multiple selections, the Selected property of the ListBox (rather than the ListIndex property) identifies the selected rows. The Selected property is an array with the same number of values as the number of rows in the ListBox. For each row in the list box, Selected is True if the row is selected and False if it is not. In a ListBox that allows multiple selections, ListIndex returns the index of the row that has focus, regardless of whether that row is currently selected.

The ListIndex value is also available by setting the BoundColumn property to 0 for a combo box or list box. If BoundColumn is 0, the underlying data source to which the combo box or list box is bound contains the same list index value as ListIndex.


ListRows Property

Specifies the maximum number of rows to display in the list.

Syntax

object.ListRows [= Long]

The ListRows property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. An integer indicating the maximum number of rows. The default value is 8.
Remarks

If the number of items in the list exceeds the value of the ListRows property, a scroll bar appears at the right edge of the list box portion of the combo box.


ListStyle Property

Specifies the visual appearance of the list in a ListBox or ComboBox.

Syntax

object.ListStyle [= fmListStyle]

The ListStyle property syntax has these parts:

Part	Description
object	Required. A valid object.
fmListStyle	Optional. The visual style of the list.
Settings

The settings for fmListStyle are:

Constant	Value	Description
fmListStylePlain	0	Looks like a regular list box, with the background of items highlighted.
fmListStyleOption	1	Shows option buttons, or check boxes for a multi-select list (default). When the user selects an item from the group, the option button associated with that item is selected and the option buttons for the other items in the group are deselected.
Remarks

The ListStyle property lets you change the visual presentation of a ListBox or ComboBox. By specifying a setting other than fmListStylePlain, you can present the contents of either control as a group of individual items, with each item including a visual cue to indicate whether it is selected.

If the control supports a single selection (the MultiSelect property is set to fmMultiSelectSingle), the user can press one button in the group. If the control supports multi-select, the user can press two or more buttons in the group.


ListWidth Property

Specifies the width of the list in a ComboBox.

Syntax

object.ListWidth [= Variant]

The ListWidth property syntax has these parts:

Part	Description
object	Required. A valid object.
Variant	Optional. The width of the list. A value of zero makes the list as wide as the ComboBox. The default value is to make the list as wide as the text portion of the control.
Remarks

If you want to display a multicolumn list, enter a value that will make the list box wide enough to fit all the columns.

Tip  When designing combo boxes, be sure to leave enough space to display your data and for a vertical scroll bar.


Locked Property

Specifies whether a control can be edited.

Syntax

object.Locked [= Boolean]

The Locked property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the control can be edited.
Settings

The settings for Boolean are:

Value	Description
True	You can't edit the value.
False	You can edit the value (default).
Remarks

When a control is locked and enabled, it can still initiate events and can still receive the focus.


MatchEntry Property

Returns or sets a value indicating how a ListBox or ComboBox searches its list as the user types.

Syntax

object.MatchEntry [= fmMatchEntry]

The MatchEntry property syntax has these parts:

Part	Description
object	Required. A valid object.
fmMatchEntry	Optional. The rule used to match entries in the list.
Settings

The settings for fmMatchEntry are:

Constant	Value	Description
fmMatchEntryFirstLetter	0	Basic matching. The control searches for the next entry that starts with the character entered. Repeatedly typing the same letter cycles through all entries beginning with that letter.
fmMatchEntryComplete	1	Extended matching. As each character is typed, the control searches for an entry matching all characters entered (default).
fmMatchEntryNone	2	No matching.
Remarks

The MatchEntry property searches entries from the TextColumn property of a ListBox or ComboBox.

The control searches the column identified by TextColumn for an entry that matches the user's typed entry. Upon finding a match, the row containing the match is selected, the contents of the column are displayed, and the contents of its BoundColumn property become the value of the control. If the match is unambiguous, finding the match initiates the Click event.

The control initiates the Click event as soon as the user types a sequence of characters that match exactly one entry in the list. As the user types, the entry is compared with the current row in the list and with the next row in the list. When the entry matches only the current row, the match is unambiguous.

In Microsoft Forms, this is true regardless of whether the list is sorted. This means the control finds the first occurrence that matches the entry, based on the order of items in the list. For example, entering either “abc” or “bc” will initiate the Click event for the following list:

abcde

bcdef

abcxyz

bchij

Note that in either case, the matched entry is not unique; however, it is sufficiently different from the adjacent entry that the control interprets the match as unambiguous and initiates the Click event.


MatchFound Property

Indicates whether the text that a user has typed into a combo box matches any of the entries in the list.

Syntax

object.MatchFound [ =Boolean]

The MatchFound property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether a matching record was found.
Return Values

The MatchFound property return values are:

Value	Description
True	The contents of the Value property matches one of the records in the list.
False	The contents of Value does not match any of the records in the list (default).
Remarks

The MatchFound property is read-only. It is not applicable when the MatchEntry property is set to fmMatchEntryNone.


MatchRequired Property

Specifies whether a value entered in the text portion of a ComboBox must match an entry in the existing list portion of the control. The user can enter non-matching values, but may not leave the control until a matching value is entered.

Syntax

object.MatchRequired [= Boolean]

The MatchRequired property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the text entered must match an existing item in the list.
Settings

The settings for Boolean are:

Value	Description
True	The text entered must match an existing list entry.
False	The text entered can be different from all existing list entries (default).
Remarks

If the MatchRequired property is True, the user cannot exit the ComboBox until the text entered matches an entry in the existing list. MatchRequired maintains the integrity of the list by requiring the user to select an existing entry.

Note  Not all containers enforce this property.


Max, Min Properties

Specify the maximum and minimum acceptable values for the Value property of a ScrollBar or SpinButton.

Syntax

object.Max [= Long]

object.Min [= Long]

The Max and Min property syntaxes have these parts:

Part	Description
object	Required. A valid object.
Long	Optional. A numeric expression specifying the maximum or minimum Value property setting.
Remarks

Clicking a SpinButton or moving the scroll box in a ScrollBar changes the Value property of the control.

The value for the Max property corresponds to the lowest position of a vertical ScrollBar or the rightmost position of a horizontal ScrollBar. The value for the Min property corresponds to the highest position of a vertical ScrollBar or the leftmost position of a horizontal ScrollBar.

Any integer is an acceptable setting for this property. The recommended range of values is from –32,767 to +32,767. The default value is 1.

Note  Min and Max refer to locations, not to relative values, on the ScrollBar. That is, the value of Max could be less than the value of Min. If this is the case, moving toward the Max (bottom) position means decreasing Value; moving toward the Min (top) position means increasing Value.


MaxLength Property

Specifies the maximum number of characters a user can enter in a TextBox or ComboBox.

Syntax

object.MaxLength [= Long]

The MaxLength property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. An integer indicating the allowable number of characters.
Remarks

Setting the MaxLength property to 0 indicates there is no limit other than that created by memory constraints.


MouseIcon Property

Assigns a custom icon to an object.

Syntax

object.MouseIcon = LoadPicture( pathname )

The MouseIcon property syntax has these parts:

Part	Description
object	Required. A valid object.
pathname	Required. A string expression specifying the path and filename of the file containing the custom icon.
Remarks

The MouseIcon property is valid when the MousePointer property is set to 99. The mouse icon of an object is the image that appears when the user moves the mouse across that object.

To assign an image for the mouse pointer, you can either assign a picture to the MouseIcon property or load a picture from a file using the LoadPicture method.


MousePointer Property

Specifies the type of pointer displayed when the user positions the mouse over a particular object.

Syntax

object.MousePointer [= fmMousePointer]

The MousePointer property syntax has these parts:

Part	Description
object	Required. A valid object.
fmMousePointer	Optional. The shape you want for the mouse pointer.
Settings

The settings for fmMousePointer are:

Constant	Value	Description
fmMousePointerDefault	0	Standard pointer. The image is determined by the object (default).
fmMousePointerArrow	1	Arrow.
fmMousePointerCross	2	Cross-hair pointer.
fmMousePointerIBeam	3	I-beam.
fmMousePointerSizeNESW	6	Double arrow pointing northeast and southwest.
fmMousePointerSizeNS	7	Double arrow pointing north and south.
fmMousePointerSizeNWSE	8	Double arrow pointing northwest and southeast.
fmMousePointerSizeWE	9	Double arrow pointing west and east.
fmMousePointerUpArrow	10	Up arrow.
fmMousePointerHourglass	11	Hourglass.
fmMousePointerNoDrop	12	"Not" symbol (circle with a diagonal line) on top of the object being dragged. Indicates an invalid drop target.
fmMousePointerAppStarting	13	Arrow with an hourglass.
fmMousePointerHelp	14	Arrow with a question mark.
fmMousePointerSizeAll	15	Size all cursor (arrows pointing north, south, east, and west).
fmMousePointerCustom	99	Uses the icon specified by the MouseIcon property.
Remarks

Use the MousePointer property when you want to indicate changes in functionality as the mouse pointer passes over controls on a form. For example, the hourglass setting (11) is useful to indicate that the user must wait for a process or operation to finish.

Some icons vary depending on system settings, such as the icons associated with desktop themes.


MultiLine Property

Specifies whether a control can accept and display multiple lines of text.

Syntax

object.MultiLine [= Boolean]

The MultiLine property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the control supports more than one line of text.
Settings

The settings for Boolean are:

Value	Description
True	The text is displayed across multiple lines (default).
False	The text is not displayed across multiple lines.
Remarks

A multiline TextBox allows absolute line breaks and adjusts its quantity of lines to accommodate the amount of text it holds. If needed, a multiline control can have vertical scroll bars.

A single-line TextBox doesn’t allow absolute line breaks and doesn’t use vertical scroll bars.

Single-line controls ignore the value of the WordWrap property.


MultiRow Property

Specifies whether the control has more than one row of tabs.

Syntax

object.MultiRow [= Boolean]

The MultiRow property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the control has more than one row of tabs.
Settings

The settings for Boolean are:

Value	Description
True	Allows more than one row of tabs.
False	Restricts tabs to a single row (default).
Remarks

The width and number of tabs determines the number of rows. Changing the control's size also changes the number of rows. This allows the developer to resize the control and ensure that tabs wrap to fit the control. If the MultiRow property is False, then truncation occurs if the width of the tabs exceeds the width of the control.

If MultiRow is False and tabs are truncated, there will be a small scroll bar on the TabStrip to allow scrolling to the other tabs or pages.


MultiSelect Property

Indicates whether the object permits multiple selections.

Syntax

object.MultiSelect [= fmMultiSelect]

The MultiSelect property syntax has these parts:

Part	Description
object	Required. A valid object.
fmMultiSelect	Optional. The selection mode that the control uses.
Settings

The settings for fmMultiSelect are:

Constant	Value	Description
fmMultiSelectSingle	0	Only one item can be selected (default).
fmMultiSelectSimple	1	Pressing the SPACEBAR or clicking selects or deselects an item in the list.
fmMultiSelectExtended	2	Pressing SHIFT and clicking the mouse, or pressing SHIFT and one of the arrow keys, extends the selection from the previously selected item to the current item. Pressing CTRL and clicking the mouse selects or deselects an item.
Remarks

When the MultiSelect property is set to Extended or Simple, you must use the list box's Selected property to determine the selected items. Also, the Value property of the control is always Null.

The ListIndex property returns the index of the row with the keyboard focus.


Name Property

Specifies the name of a control or an object, or the name of a font to associate with a Font object.

Syntax

For Font
Font.Name [= String]

For all other controls and objects
object.Name [= String]

The Name property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. The name you want to assign to the font or control.
Settings

Guidelines for assigning a string to Name, such as the maximum length of the name, vary from one application to another.

Remarks

For objects, the default value of Name consists of the object's class name followed by an integer. For example, the default name for the first TextBox you place on a form is TextBox1. The default name for the second TextBox is TextBox2.

You can set the Name property for a control from the control's property sheet or, for controls added at run time, by using program statements. If you add a control at design time, you cannot modify its Name property at run time.

Each control added to a form at design time must have a unique name.

For Font objects, Name identifies a particular typeface to use in the text portion of a control, object, or form. The font's appearance on screen and in print may differ, depending on your computer and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.


Object Property

Identifies a control whose property or method will be used instead of a standard property or method of the same name.

Syntax

object.Object[.property |.method]

The Object property syntax has these parts:

Part	Description
object	Required. The custom control that supports a property or method you want to use instead of a standard property or method supplied in the project.
property	Optional. A custom property whose name is identical to the name of a standard property in the project.
method	Optional. A custom method whose name is identical to the name of a standard method in the project.
Remarks

A project provides a standard set of properties and methods for use by controls you add to the project. However, a control you add might include a property or method with a name that is identical to one of the standard properties ormethods. By default, the project uses the standard property or method, not the one that is part of the added control. The Object property lets you override this default, and use the property or method supplied with the control you added.


OldHeight, OldWidth Properties

Specifies the previous height or width, in points, of the control.

Syntax

object.OldHeight [ =Single]

object.OldWidth [ =Single]

The OldHeight and OldWidth property syntaxes have these parts:

Part	Description
object	Required. A valid object.
Single	Optional. Returns the previous height or width.
Remarks

The OldHeight and OldWidth properties are automatically updated when you move or size a control. If you change the size of a control, the Height and Width properties store the new height and OldHeight and OldWidth store the previous height.

These properties are used exclusively in the Layout event.


OldLeft, OldTop Properties

Indicates the distance, in points, between the previous position of a control and the left or top edge of the form that contains it.

Syntax

object.OldLeft [ =Single]

object.OldTop [ =Single]

The OldLeft and OldTop property syntaxes have these parts:

Part	Description
object	Required. A valid object.
Single	Optional. Returns the previous left or top coordinate.
Remarks

The OldLeft and OldTop properties are automatically updated when you move or size a control. If you move a control, the Left and Top properties store the new distance from the control to the left edge of its container and OldLeft and OldTop store the previous value of Left.

OldLeft and OldTop are used exclusively in the Layout event.


Orientation Property

Specifies whether the SpinButton or ScrollBar is oriented vertically or horizontally.

Syntax

object.Orientation [= fmOrientation]

The Orientation property syntax has these parts:

Part	Description
object	Required. A valid object.
fmOrientation	Optional. Orientation of the control.
Settings

The settings for fmOrientation are:

Constant	Value	Description
fmOrientationAuto	–1	Automatically determines the orientation based upon the dimensions of the control (default).
fmOrientationVertical	0	Control is rendered vertically.
fmOrientationHorizontal	1	Control is rendered horizontally.
Remarks

If you specify automatic orientation, the height and width of the control determine whether it appears horizontally or vertically. For example, if the control is wider than it is tall, it appears horizontally; if it is taller than it is wide, the control appears vertically.


Parent Property

Returns the name of the form, object, or collection that contains a specific control, object, or collection.

Syntax

object.Parent [= Object]

The Parent property syntax has these parts:

Part	Description
object	Required. A valid object.
Object	Optional. The parent of the object.
Remarks

Use the Parent property to access the properties, methods, or controls of an object's parent.

This property is useful in an application in which you pass objects as arguments. For example, you could pass a control variable to a general procedure in a module, and use Parent to access its parent form.


PasswordChar Property

Specifies whether placeholder characters are displayed instead of the characters actually entered in a TextBox.

Syntax

object.PasswordChar [= String]

The PasswordChar property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. A string expression specifying the placeholder character.
Remarks

You can use the PasswordChar property to protect sensitive information, such as passwords or security codes. The value of PasswordChar is the character that appears in a control instead of the actual characters that the user types. If you don't specify a character, the control displays the characters that the user types.


Picture Property

Specifies the bitmap to display on an object.

Syntax

object.Picture = LoadPicture( pathname )

The Picture property syntax has these parts:

Part	Description
object	Required. A valid object.
pathname	Required. The full path to a picture file.
Remarks

While designing a form, you can use the control’s property page to assign a bitmap to the Picture property. While running a form, you must use the LoadPicture function to assign a bitmap to Picture.

To remove a picture that is assigned to a control, click the value of the Picture property in the property page and then press DELETE. Pressing BACKSPACE will not remove the picture.

Note   For controls with captions, use the PicturePosition property to specify where to display the picture on the object. Use the PictureSizeMode property to determine how the picture fills the object.

Transparent pictures sometimes have a hazy appearance. If you do not like this appearance, display the picture on a control that supports opaque images. Image and MultiPage support opaque images.


PictureAlignment Property

Specifies the location of a background picture.

Syntax

object.PictureAlignment [= fmPictureAlignment]

The PictureAlignment property syntax has these parts:

Part	Description
object	Required. A valid object.
fmPictureAlignment	Optional. The position where the picture aligns with the control.
Settings

The settings for fmPictureAlignment are:

Constant	Value	Description
fmPictureAlignmentTopLeft	0	The top left corner.
fmPictureAlignmentTopRight	1	The top right corner.
fmPictureAlignmentCenter	2	The center.
fmPictureAlignmentBottomLeft	3	The bottom left corner.
fmPictureAlignmentBottomRight	4	The bottom right corner.
Remarks

The PictureAlignment property identifies which corner of the picture is the same as the corresponding corner of the control or container where the picture is used.

For example, setting PictureAlignment to fmPictureAlignmentTopLeft means that the top left corner of the picture coincides with the top left corner of the control or container. Setting PictureAlignment to fmPictureAlignmentCenter positions the picture in the middle, relative to the height as well as the width of the control or container.

If you tile an image on a control or container, the setting of PIctureAlignment affects the tiling pattern. For example, if PictureAlignment is set to fmPictureAlignmentUpperLeft, the first copy of the image is laid in the upper left corner of the control or container and additional copies are tiled from left to right across each row. If PictureAlignment is fmPictureAlignmentCenter, the first copy of the image is laid at the center of the control or container, additional copies are laid to the left and right to complete the row, and additional rows are added to fill the control or container.

Note  Setting the PictureSizeMode property to fmSizeModeStretch overrides PictureAlignment. When PictureSizeMode is set to fmSizeModeStretch, the picture fills the entire control or container.


PicturePosition Property

Specifies the location of the picture relative to its caption.

Syntax

object.PicturePosition [= fmPicturePosition]

The PicturePosition property syntax has these parts:

Part	Description
object	Required. A valid object.
fmPicturePosition	Optional. How the picture aligns with its container.
Settings

The settings for fmPicturePosition are:

Constant	Value	Description
fmPicturePositionLeftTop	0	The picture appears to the left of the caption. The caption is aligned with the top of the picture.
fmPicturePositionLeftCenter	1	The picture appears to the left of the caption. The caption is centered relative to the picture.
fmPicturePositionLeftBottom	2	The picture appears to the left of the caption. The caption is aligned with the bottom of the picture.
fmPicturePositionRightTop	3	The picture appears to the right of the caption. The caption is aligned with the top of the picture.
fmPicturePositionRightCenter	4	The picture appears to the right of the caption. The caption is centered relative to the picture.
fmPicturePositionRightBottom	5	The picture appears to the right of the caption. The caption is aligned with the bottom of the picture.
fmPicturePositionAboveLeft	6	The picture appears above the caption. The caption is aligned with the left edge of the picture.
fmPicturePositionAboveCenter	7	The picture appears above the caption. The caption is centered below the picture (default).
fmPicturePositionAboveRight	8	The picture appears above the caption. The caption is aligned with the right edge of the picture.
fmPicturePositionBelowLeft	9	The picture appears below the caption. The caption is aligned with the left edge of the picture.
fmPicturePositionBelowCenter	10	The picture appears below the caption. The caption is centered above the picture.
fmPicturePositionBelowRight	11	The picture appears below the caption. The caption is aligned with the right edge of the picture.
fmPicturePositionCenter	12	The picture appears in the center of the control. The caption is centered horizontally and vertically on top of the picture.
Remarks

If no caption exists, the picture’s location is relative to the center of the control.

This property is ignored if the Picture property does not specify a picture.


PictureSizeMode Property

Specifies how to display the background picture on a control, form, or page.

Syntax

object.PictureSizeMode [= fmPictureSizeMode]

The PictureSizeMode property syntax has these parts:

Part	Description
object	Required. A valid object.
fmPictureSizeMode	Optional. The action to take if the picture and the form or page that contains it are not the same size.
Settings

The settings for fmPictureSizeMode are:

Constant	Value	Description
fmPictureSizeModeClip	0	Crops any part of the picture that is larger than the form or page (default).
fmPictureSizeModeStretch	1	Stretches the picture to fill the form or page. This setting distorts the picture in either the horizontal or vertical direction.
fmPictureSizeModeZoom	3	Enlarges the picture, but does not distort the picture in either the horizontal or vertical direction.
Remarks

The fmPictureSizeModeClip setting indicates you want to show the picture in its original size and scale. If the form or page is smaller than the picture, this setting only shows the part of the picture that fits within the form or page.

The fmPictureSizeModeStretch and fmPictureSizeModeZoom settings both enlarge the image, but fmPictureSizeModeStretch causes distortion. The fmPictureSizeModeStretch setting enlarges the image horizontally and vertically until the image reaches the corresponding edges of the container or control. The fmPictureSizeModeZoom setting enlarges the image until it reaches either the horizontal or vertical edges of the container or control. If the image reaches the horizontal edges first, any remaining distance to the vertical edges remains blank. If it reaches the vertical edges first, any remaining distance to the horizontal edges remains blank.


PictureTiling Property

Lets you tile a picture in a form or page.

Syntax

object.PictureTiling [= Boolean]

The PictureTiling property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether a picture is repeated across a background.
Settings

The settings for Boolean are:

Value	Description
True	The picture is tiled across the background.
False	The picture is not tiled across the background (default).
Remarks

If a picture is smaller than the form or page that contains it, you can tile the picture on the form or page.

The tiling pattern depends on the current setting of the PictureAlignment and PictureSizeMode properties. For example, if PictureAlignment is set to fmPictureAlignmentTopLeft, the tiling pattern starts at the upper left and repeats the picture across the form or page and down the height of the form or page. If PictureSizeMode is set to fmPictureSizeModeClip, the tiling pattern crops the last tile if it doesn't completely fit on the form or page.


ProportionalThumb Property

Specifies whether the size of the scroll box is proportional to the scrolling region or fixed.

Syntax

object.ProportionalThumb [= Boolean]

The ProportionalThumb property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the scroll box is proportional or fixed.
Settings

The settings for Boolean are:

Value	Description
True	The scroll box is proportional in size to the scrolling region (default).
False	The scroll box is a fixed size.
Remarks

The size of a proportional scroll box graphically represents the percentage of the object that is visible in the window. For example, if 75 percent of an object is visible, the scroll box covers three-fourths of the scrolling region in the scroll bar.

If the scroll box is a fixed size, the system determines its size based on the height and width of the scroll bar.


RowSource Property

Specifies the source providing a list for a ComboBox or ListBox.

Syntax

object.RowSource [= String]

The RowSource property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. The source of the list for the ComboBox or ListBox.
Remarks

The RowSource property accepts worksheet ranges from Microsoft Excel.


ScrollBars Property

Specifies whether a control, form, or page has vertical scroll bars, horizontal scroll bars, or both.

Syntax

object.ScrollBars [= fmScrollBars]

The ScrollBars property syntax has these parts:

Part	Description
object	Required. A valid object.
fmScrollBars	Optional. Where scroll bars should be displayed.
Settings

The settings for fmScrollBars are:

Constant	Value	Description
fmScrollBarsNone	0	Displays no scroll bars (default).
fmScrollBarsHorizontal	1	Displays a horizontal scroll bar.
fmScrollBarsVertical	2	Displays a vertical scroll bar.
fmScrollBarsBoth	3	Displays both a horizontal and a vertical scroll bar.
Remarks

If the KeepScrollBarsVisible property is True, any scroll bar on a form or page is always visible, regardless of whether the object's contents fit within the object's borders.

If visible, a scroll bar constrains its scroll box to the visible region of the scroll bar. It also modifies the scroll position as needed to keep the entire scroll bar visible. The range of a scroll bar changes when the value of the ScrollBars property changes, the scroll size changes, or the visible size changes.

If a scroll bar is not visible, then you can set its scroll position to any value. Negative values and values greater than the scroll size are both valid.

For a single-line control, you can display a horizontal scroll bar by using the ScrollBars and AutoSize properties. Scroll bars are hidden or displayed according to the following rules:

1.	When ScrollBars is set to fmScrollBarsNone, no scroll bar is displayed.

2.	When ScrollBars is set to fmScrollBarsHorizontal or fmScrollBarsBoth, the control displays a horizontal scroll bar if the text is longer than the edit region and if the control has enough room to include the scroll bar underneath its edit region.

3.	When AutoSize is True, the control enlarges itself to accommodate the addition of a scroll bar unless the control is at or near its maximum size.

For a multiline TextBox, you can display scroll bars by using the ScrollBars, WordWrap, and AutoSize properties. Scroll bars are hidden or displayed according to the following rules:

1.	When ScrollBars is set to fmScrollBarsNone, no scroll bar is displayed.

2.	When ScrollBars is set to fmScrollBarsVertical or fmScrollBarsBoth, the control displays a vertical scroll bar if the text is longer than the edit region and if the control has enough room to include the scroll bar at the right edge of its edit region.

3.	When WordWrap is True, the multiline control will not display a horizontal scroll bar. Most multiline controls do not use a horizontal scroll bar.

4.	A multiline control can display a horizontal scroll bar if the following conditions occur simultaneously:

•	The edit region contains a word that is longer than the edit region’s width.

•	The control has enabled horizontal scroll bars.

•	The control has enough room to include the scroll bar under the edit region.

•	The WordWrap property is set to False.


ScrollHeight, ScrollWidth Properties

Specify the height, in points, of the total area that can be viewed by moving the scroll bars on the control, form, or page.

Syntax

object.ScrollHeight [= Single]

object.ScrollWidth [= Single]

The ScrollHeight and ScrollWidth property syntaxes have these parts:

Part	Description
object	Required. A valid object.
Single	Optional. The height or width of the scrollable region.


ScrollLeft, ScrollTop Properties

Specify the distance, in points, of the left or top edge of the visible form from the left or top edge of the logical form, page, or control.

Syntax

object.ScrollLeft [= Single]

object.ScrollTop [= Single]

The ScrollLeft and ScrollTop property syntaxes have these parts:

Part	Description
object	Required. A valid object.
Single	Optional. The distance from the edge of the form.
Remarks

The minimum value is zero; the maximum value is the difference between the value of the ScrollWidth property and the value of the Width property for the form or page.


Selected Property

Returns or sets the selection state of items in a ListBox.

Syntax

object.Selected( index ) [= Boolean]

The Selected property syntax has these parts:

Part	Description
object	Required. A valid object.
index	Required. An integer with a range from 0 to one less than the number of items in the list.
Boolean	Optional. Whether an item is selected.
Settings

The settings for Boolean are:

Value	Description
True	The item is selected.
False	The item is not selected.
Remarks

The Selected property is useful when users can make multiple selections. You can use this property to determine the selected rows in a multi-select list box. You can also use this property to select or deselect rows in a list from code.

The default value of this property is based on the current selection state of the ListBox.

For single-selection list boxes, the Value or ListIndex properties are recommended for getting and setting the selection. In this case, ListIndex returns the index of the selected item. However, in a multiple selection, ListIndex returns the index of the row contained within the focus rectangle, regardless of whether the row is actually selected.

When a list box control's MultiSelect property is set to None, only one row can have its Selected property set to True.

Entering a value that is out of range for the index does not generate an error message, but does not set a property for any item in the list.


SelectedItem Property

Returns or sets the currently selected Tab or Page object.

Syntax

object.SelectedItem [ =Object]

The SelectedItem property syntax has these parts:

Part	Description
object	Required. A valid TabStrip or MultiPage.
Object	Optional. The currently selected Tab or Page of the specified TabStrip or MultiPage.
Remarks

Use the SelectedItem property to programmatically control the currently selected Tab or Page object. For example, you can use SelectedItem to assign values to properties of a Tab or Page object.


SelectionMargin Property

Specifies whether the user can select a line of text by clicking in the region to the left of the text.

Syntax

object.SelectionMargin [= Boolean]

The SelectionMargin property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether clicking in the margin selects a line of text.
Settings

The settings for Boolean are:

Value	Description
True	Clicking in margin causes selection of text (default).
False	Clicking in margin does not cause selection of text.
Remarks

When the SelectionMargin property is True, the selection margin occupies a thin strip along the left edge of a control’s edit region. When set to False, the entire edit region can store text.

If the SelectionMargin property is set to True when a control is printed, the selection margin also prints.


SelLength Property

The number of characters selected in a text box or the text portion of a combo box.

Syntax

object.SelLength [= Long]

The SelLength property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. A numeric expression specifying the number of characters selected. For SelLength and SelStart, the valid range of settings is 0 to the total number of characters in the edit area of a ComboBox or TextBox.
Remarks

The SelLength property is always valid, even when the control does not have focus. Setting SelLength to a value less than zero creates an error. Attempting to set SelLength to a value greater than the number of characters available in a control results in a value equal to the number of characters in the control.

Note  Changing the value of the SelStart property cancels any existing selection in the control, places an insertion point in the text, and sets SelLength to zero.

The default value, zero, means that no text is currently selected.


SelStart Property

Indicates the starting point of selected text, or the insertion point if no text is selected.

Syntax

object.SelStart [= Long]

The SelStart property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. A numeric expression specifying the starting point of text selected. For SelLength and SelStart, the valid range of settings is 0 to the total number of characters in the edit area of a ComboBox or TextBox. The default value is zero.
Remarks

The SelStart property is always valid, even when the control does not have focus. Setting SelStart to a value less than zero creates an error. Attempting to set SelStart to a value greater than the number of characters available in a control results in a value equal to the number of characters in the control.

Changing the value of SelStart cancels any existing selection in the control, places an insertion point in the text, and sets the SelLength property to zero.


SelText Property

Returns or sets the selected text of a control.

Syntax

object.SelText [= String]

The SelText property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. A string expression containing the selected text.
Remarks

If no characters are selected in the edit region of the control, the SelText property returns a zero length string. This property is valid regardless of whether the control has the focus.


ShowDropButtonWhen Property

Specifies when to show the drop-down button for a ComboBox or TextBox.

Syntax

object.ShowDropButtonWhen [= fmShowDropButtonWhen]

The ShowDropButtonWhen property syntax has these parts:

Part	Description
object	Required. A valid object.
fmShowDropButtonWhen	Optional. The circumstances under which the drop-down button will be visible.
Settings

The settings for fmShowDropButtonWhen are:

Constant	Value	Description
fmShowDropButtonWhenNever	0	Do not show the drop-down button under any circumstances.
fmShowDropButtonWhenFocus	1	Show the drop-down button when the control has the focus.
fmShowDropButtonWhenAlways	2	Always show the drop-down button (default).


SmallChange Property

Specifies the amount of movement that occurs when the user clicks either scroll arrow in a ScrollBar or SpinButton.

Syntax

object.SmallChange [= Long]

The SmallChange property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. An integer that specifies the amount of change to the Value property.
Remarks

The SmallChange property does not have units.

Any integer is an acceptable setting for this property. The recommended range of values is from –32,767 to +32,767. The default value is 1.


SpecialEffect Property

Specifies the visual appearance of an object.

Syntax

For CheckBox, OptionButton, ToggleButton
object.SpecialEffect [= fmButtonEffect]

For other controls
object.SpecialEffect [= fmSpecialEffect]

The SpecialEffect property syntax has these parts:

Part	Description
object	Required. A valid object.
fmButtonEffect	Optional. The desired visual appearance for a CheckBox, OptionButton, or ToggleButton.
fmSpecialEffect	Optional. The desired visual appearance of an object other than a CheckBox, OptionButton, or ToggleButton.
Settings

The settings for fmSpecialEffect are:

Constant	Value	Description
fmSpecialEffectFlat	0	Object appears flat, distinguished from the surrounding form by a border, a change of color, or both. Default for Image and Label, valid for all controls.
fmSpecialEffectRaised	1	Object has a highlight on the top and left and a shadow on the bottom and right. Not valid for check boxes or option buttons.
fmSpecialEffectSunken	2	Object has a shadow on the top and left and a highlight on the bottom and right. The control and its border appear to be carved into the form that contains them. Default for CheckBox and OptionButton, valid for all controls (default).
fmSpecialEffectEtched	3	Border appears to be carved around the edge of the control. Not valid for check boxes or option buttons.
fmSpecialEffectBump	6	Object has a ridge on the bottom and right and appears flat on the top and left. Not valid for check boxes or option buttons.
For a Frame, the default value is Sunken.

Note that only Flat and Sunken (0 and 2) are acceptable values for CheckBox, OptionButton, and ToggleButton. All values listed are acceptable for other controls.

Remarks

You can use either the SpecialEffect or the BorderStyle property to specify the edging for a control, but not both. If you specify a nonzero value for one of these properties, the system sets the value of the other property to zero. For example, if you set SpecialEffect to fmSpecialEffectRaised, the system sets BorderStyle to zero (fmBorderStyleNone).

For a Frame, BorderStyle is ignored if SpecialEffect is fmSpecialEffectFlat.

SpecialEffect uses the system colors to define its borders.

Note   Although the ToggleButton supports the Alignment property, changing the property has no effect on the ToggleButton.


Style Property

For ComboBox, specifies how the user can choose or set the control’s value. For MultiPage and TabStrip, identifies the style of the tabs on the control.

Syntax

For ComboBox
object.Style [= fmStyle]

For MultiPage and TabStrip
object.Style [= fmTabStyle]

The Style property syntax has these parts:

Part	Description
object	Required. A valid object.
fmStyle	Optional. Specifies how a user sets the value of a ComboBox.
fmTabStyle	Optional. Specifies the tab style in a MultiPage or TabStrip.
Settings

The settings for fmStyle are:

Constant	Value	Description
fmStyleDropDownCombo	0	The ComboBox behaves as a drop-down combo box. The user can type a value in the edit region or select a value from the drop-down list (default).
fmStyleDropDownList	2	The ComboBox behaves as a list box. The user must choose a value from the list.
The settings for fmTabStyle are:

Constant	Value	Description
fmTabStyleTabs	0	Displays tabs on the tab bar (default).
fmTabStyleButtons	1	Displays buttons on the tab bar.
fmTabStyleNone	2	Does not display the tab bar.


TabFixedHeight, TabFixedWidth Property
TabFixedHeight, TabFixedWidth Properties

Sets or returns the fixed height or width of the tabs in points.

Syntax

object.TabFixedHeight [= Single]

object.TabFixedWidth [= Single]

The TabFixedHeight and TabFixedWidth property syntaxes have these parts:

Part	Description
object	Required. A valid object.
Single	Optional. The number of points of the height or width of the tabs on a TabStrip or MultiPage.
Settings

If the value is 0, tab widths are automatically adjusted so that each tab is wide enough to accommodate its contents and each row of tabs spans the width of the control.

If the value is greater than 0, all tabs have an identical width as specified by this property.

Remarks

The minimum size is 4 points.


TabIndex Property

Specifies the position of a single object in the form's tab order.

Syntax

object.TabIndex [= Integer]

The TabIndex property syntax has these parts:

Part	Description
object	Required. A valid object.
Integer	Optional. An integer from 0 to one less than the number of controls on the form that have a TabIndex property. Assigning a TabIndex value of less than 0 generates an error. If you assign a TabIndex value greater than the largest index value, the system resets the value to the maximum allowable value.
Remarks

The index value of the first object in the tab order is zero.


TabKeyBehavior Property

Determines whether tabs are allowed in the edit region.

Syntax

object.TabKeyBehavior [= Boolean]

The TabKeyBehavior property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. The effect of pressing TAB.
Settings

The settings for Boolean are:

Value	Description
True	Pressing TAB inserts a tab character in the edit region.
False	Pressing TAB moves the focus to the next object in the tab order (default).
Remarks

The TabKeyBehavior and MultiLine properties are closely related. The values described above only apply if MultiLine is True. If MultiLine is False, pressing TAB always moves the focus to the next control in the tab order regardless of the value of TabKeyBehavior.

The effect of pressing CTRL+TAB also depends on the value of MultiLine. If MultiLine is True, pressing CTRL+TAB creates a new line regardless of the value of TabKeyBehavior. If MultiLine is False, pressing CTRL+TAB has no effect.


TabOrientation Property

Specifies the location of the tabs on a MultiPage or TabStrip.

Syntax

object.TabOrientation [= fmTabOrientation]

The TabOrientation property syntax has these parts:

Part	Description
object	Required. A valid object.
fmTabOrientation	Optional. Where the tabs will appear.
Settings

The settings for fmTabOrientation are:

Constant	Value	Description
fmTabOrientationTop	0	The tabs appear at the top of the control (default).
fmTabOrientationBottom	1	The tabs appear at the bottom of the control.
fmTabOrientationLeft	2	The tabs appear at the left side of the control.
fmTabOrientationRight	3	The tabs appear at the right side of the control.
Remarks

If you use TrueType fonts, the text rotates when the TabOrientation property is set to fmTabOrientationLeft or fmTabOrientationRight. If you use bitmapped fonts, the text does not rotate.


TabStop Property

Indicates whether an object can receive focus when the user tabs to it.

Syntax

object.TabStop [= Boolean]

The TabStop property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the object is a tab stop.
Settings

The settings for Boolean are:

Value	Description
True	Designates the object as a tab stop (default).
False	Bypasses the object when the user is tabbing, although the object still holds its place in the actual tab order, as determined by the TabIndex property.


Tag Property

Stores additional information about an object.

Syntax

object.Tag [= String]

The Tag property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. A string expression identifying the object. The default is a zero-length string ("").
Remarks

Use the Tag property to assign an identification string to an object without affecting other property settings or attributes.

For example, you can use Tag to check the identity of a form or control that is passed as a variable to a procedure.


Text Property

Returns or sets the text in a TextBox. Changes the selected row in a ComboBox or ListBox.

Syntax

object.Text [= String]

The Text property syntax has these parts:

Part	Description
object	Required. A valid object.
String	Optional. A string expression specifying text. The default value is a zero-length string (“”).
Remarks

For a TextBox, any value you assign to the Text property is also assigned to the Value property.

For a ComboBox, you can use Text to update the value of the control. If the value of Text matches an existing list entry, the value of the ListIndex property (the index of the current row) is set to the row that matches Text. If the value of Text does not match a row, ListIndex is set to –1.

For a ListBox, the value of Text must match an existing list entry. Specifying a value that does not match an existing list entry causes an error.

You cannot use Text to change the value of an entry in a ComboBox or ListBox; use the Column or List property for this purpose.

The ForeColor property determines the color of the text.


TextAlign Property

Specifies how text is aligned in a control.

Syntax

object.TextAlign [= fmTextAlign]

The TextAlign property syntax has these parts:

Part	Description
object	Required. A valid object.
fmTextAlign	Optional. How text is aligned in the control.
Settings

The settings for fmTextAlign are:

Constant	Value	Description
fmTextAlignLeft	1	Aligns the first character of displayed text with the left edge of the control's display or edit area (default).
fmTextAlignCenter	2	Centers the text in the control's display or edit area.
fmTextAlignRight	3	Aligns the last character of displayed text with the right edge of the control's display or edit area.
Remarks

For a ComboBox, the TextAlign property only affects the edit region; this property has no effect on the alignment of text in the list. For stand-alone labels, TextAlign determines the alignment of the label's caption.


TextColumn Property

Identifies the column in a ComboBox or ListBox to display to the user.

Syntax

object.TextColumn [= Variant]

The TextColumn property syntax has these parts:

Part	Description
object	Required. A valid object.
Variant	Optional. The column to be displayed.
Settings

Values for the TextColumn property range from –1 to the number of columns in the list. The TextColumn value for the first column is 1, the value of the second column is 2, and so on. Setting TextColumn to 0 displays the ListIndex values. Setting TextColumn to –1 displays the first column that has a ColumnWidths value greater than 0.

Remarks

When the user selects a row from a ComboBox or ListBox, the column referenced by TextColumn is stored in the Text property. For example, you could set up a multicolumn ListBox that contains the names of holidays in one column and dates for the holidays in a second column. To present the holiday names to users, specify the first column as the TextColumn. To store the dates of the holidays, specify the second column as the BoundColumn.

When the Text property of a ComboBox changes (such as when a user types an entry into the control), the new text is compared to the column of data specified by TextColumn.


TextLength Property

Returns the length, in characters, of text in the edit region of a TextBox or ComboBox.

Syntax

object.TextLength [ =Long]

The TextLength property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	The number of characters in the edit region.
Remarks

The TextLength property is read-only. For a multiline TextBox, TextLength includes LF (line feed) and CR (carriage return) characters.


TopIndex Property

Sets and returns the item that appears in the topmost position in the list.

Syntax

object.TopIndex [= Variant]

The TopIndex property syntax has these parts:

Part	Description
object	Required. A valid object.
Variant	Optional. The number of the list item that is displayed in the topmost position. The default is 0, or the first item in the list.
Settings

Returns the value –1 if the list is empty or not displayed.


TransitionEffect Property

Specifies the visual effect to use when changing from one page to another.

Syntax

object.TransitionEffect [= fmTransitionEffect]

The TransitionEffect property syntax has these parts:

Part	Description
object	Required. A valid object.
fmTransitionEffect	Optional. The transition effect you want between pages.
Settings

The settings for fmTransitionEffect are:

Constant	Value	Description
fmTransitionEffectNone	0	No special effect (default).
fmTransitionEffectCoverUp	1	The new page covers the old page, moving from the bottom to the top.
fmTransitionEffectCoverRightUp	2	The new page covers the old page, moving from the bottom left corner to the top right corner.
fmTransitionEffectCoverRight	3	The new page covers the old page, moving from the left edge to the right.
fmTransitionEffectCoverRightDown	4	The new page covers the old page, moving from the top left corner to the bottom right corner.
fmTransitionEffectCoverDown	5	The new page covers the old page, moving from the top to the bottom.
fmTransitionEffectCoverLeftDown	6	The new page covers the old page, moving from the top right corner to the bottom left corner.
fmTransitionEffectCoverLeft	7	The new page covers the old page, moving from the right to the left.
fmTransitionEffectCoverLeftUp	8	The new page covers the old page, moving from the bottom right corner to the top left corner.
fmTransitionEffectPushUp	9	The new page pushes the old page out of view, moving from the bottom to the top.
fmTransitionEffectPushRight	10	The new page pushes the old page out of view, moving from the left to the right.
fmTransitionEffectPushDown	11	The new page pushes the old page out of view, moving from the top to the bottom.
fmTransitionEffectPushLeft	12	The new page pushes the old page out of view, moving from the right to the left.
Remarks

Use the TransitionPeriod property to specify the duration of a transition effect.


TransitionPeriod Property

Specifies the duration, in milliseconds, of a transition effect.

Syntax

object.TransitionPeriod [= Long]

The TransitionPeriod property syntax has these parts:

Part	Description
object	Required. A valid object.
Long	Optional. How long it takes to complete the transition from one page to another.
Remarks

Any integer from zero to 10000 is a valid setting for this property. Setting the TransitionPeriod property to zero disables the transition effect; setting TransitionPeriod to 10000 creates a 10-second transition.


TripleState Property

Determines whether a user can specify, from the user interface, the Null state for a stand-alone Yes/No control.

Syntax

object.TripleState [= Boolean]

The TripleState property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the control supports the Null state.
Settings

The settings for Boolean are:

Value	Description
True	The button clicks through three states.
False	The button only supports True and False (default).
Remarks

When the TripleState property is True, a user can choose from the values of Null, True, and False. The null value is displayed as a shaded button.

When TripleState is False, the user can choose either True or False.

When TripleState is Null, the control does not initiate the Click event.

Regardless of the property setting, the null value can always be assigned programmatically to the button, causing the button to appear shaded.


Value Property

Specifies the state or content of a given control.

Syntax

object.Value [= Variant]

The Value property syntax has these parts:

Part	Description
object	Required. A valid object.
Variant	Optional. The state or content of the control.
Settings

Control	Description
CheckBox	An integer value indicating whether the item is selected:
	Null   Indicates the item is in a null state, neither selected nor cleared.
	–1   True. Indicates the item is selected.
	0   False. Indicates the item is cleared.
OptionButton	Same as CheckBox.
ToggleButton	Same as CheckBox.
ScrollBar	An integer between the values specified for the Max and Min properties.
SpinButton	Same as ScrollBar.
ComboBox, ListBox	The value in the BoundColumn of the currently selected rows.
CommandButton	Always False.
MultiPage	An integer indicating the currently active page.
	Zero (0) indicates the first page. The maximum value is one less than the number of pages.
TextBox	The text in the edit region.
Remarks

For a CommandButton, setting the Value property to True in a macro or procedure initiates the button’s Click event.

For a ComboBox, changing the contents of Value does not change the value of BoundColumn. To add or delete entries in a ComboBox, you can use the AddItem or RemoveItem method.

Value cannot be used with a multi-select list box.


VerticalScrollbarSide Property

Specifies whether a vertical scroll bar appears on the right or left side of a form or page.

Syntax

object.VerticalScrollbarSide [= fmVerticalScrollbarSide]

The VerticalScrollbarSide property syntax has these parts:

Part	Description
object	Required. A valid object.
fmVerticalScrollbarSide	Optional. Where the scroll bar should appear.
Settings

The settings for fmVerticalScrollbarSide are:

Constant	Value	Description
fmVerticalScrollbarSideRight	0	Puts the scroll bar on the right side (default).
fmVerticalScrollBarSideLeft	1	Puts the scroll bar on the left side.
Remarks

The VerticalScrollBarSide property is is particularly useful if the form will be used in an environment where reading occurs from right to left.


Visible Property

Specifies whether an object is visible or hidden.

Syntax

object.Visible [= Boolean]

The Visible property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the object is visible or hidden.
Settings

The settings for Boolean are:

Value	Description
True	Object is visible (default).
False	Object is hidden.
Remarks

Use the Visible property to control access to information without displaying it. For example, you could use the value of a control on a hidden form as the criteria for a query.

All controls are visible at design time.


WordWrap Property

Indicates whether the contents of a control automatically wrap at the end of a line.

Syntax

object.WordWrap [= Boolean]

The WordWrap property syntax has these parts:

Part	Description
object	Required. A valid object.
Boolean	Optional. Whether the control expands to fit the text.
Settings

The settings for Boolean are:

Value	Description
True	The text wraps (default).
False	The text does not wrap.
Remarks

For controls that support the MultiLine property as well as the WordWrap property, WordWrap is ignored when MultiLine is False.


Zoom Property

Specifies how much to change the size of a displayed object.

Syntax

object.Zoom [= Integer]

The Zoom property syntax has these parts:

Part	Description
object	Required. A valid object.
Integer	Optional. The percentage to increase or decrease the displayed image.
Remarks

The value of the Zoom property specifies a percentage of image enlargement or reduction by which an image display should change. Values from 10 to 400 are valid. The value specified is a percentage of the object's original size; thus, a setting of 400 means you want to enlarge the image to four times its original size (or 400 percent), while a setting of 10 means you want to reduce the image to one-tenth of its original size (or 10 percent).


accelerator key

Also called keyboard accelerator, shortcut key, keyboard shortcut. A single character used as a shortcut for selecting an object. Pressing the ALT key followed by the accelerator key gives focus to the object and invokes any code associated with the object.

VB access key definition: A key pressed while holding down the ALT key that allows the user to open a menu, carry out a command, select an object, or move to an object.  For example, ALT+F opens the File menu.


background color

The color of the client region of an empty window or display screen, on which all drawing and color display takes place.


bound

Describes a control whose contents are associated with a particular source of data, such as a cell or cell range in a worksheet.


class identifier

A unique identifier (UUID) that identifies an OLE object. An object registers its CLSID in the system registration database so the object can be loaded and programmed by other applications.


clear

To change a setting to "off" or remove a value.


client region

The portion of a window where the application displays output such as text or graphics.


context ID

A unique number or string that corresponds to a specific object in the application. Context IDs are used to create links between the application and the corresponding Help topics.


control group

A set of controls that are conceptually or logically related. Controls that are conceptually related are usually viewed together but do not necessarily affect each other. Controls that are logically related affect each other. For example, setting one button in a group of option buttons sets the value of all other buttons in the group to False.


control tip

A brief phrase that describes a control, a Page, or a Tab. The control tip appears when the user briefly holds the mouse pointer over a control without clicking. A control tip is similar to a ToolTip. The difference is that Microsoft Forms provides ToolTips to developers at design time, and developers provide control tips to end-users at run time.


cursor

A piece of software that returns rows of data to the application. A cursor on a result set indicates the current position in the result set.


cycle

To move through a group of objects in a defined order.


data format

The structure or appearance of a unit of data, such as a file, fields in a database record, a cell in a spreadsheet, or the text in a word-processing document.


data source

The location of data to which a control is bound. A cell in a worksheet is an example of a data source. The current value of the data source is often stored in the Value property of a control. However, the control does not store the data; it only displays the information that is stored in the data source.


dominant control

A reference for the Align and Make Same Size choices of the Format menu. When aligning controls, the selected controls align to the dominant control. When sizing controls, the selected controls are assigned the dimensions of the dominant control.

The dominant control is indicated by white sizing handles. The sizing handles of the other selected controls are black.


drop source

The selected text or object that is dragged in a drag-and-drop operation.


focus

The ability to receive mouse clicks or keyboard input at any one time. In Microsoft Windows, only one window, form, or control can have this ability at a time. The object that "has the focus" is usually indicated by a highlighted caption or title bar. The focus can be set by the user or by the application.


foreground color

The color that is currently selected for drawing or displaying text on screen. In monochrome displays, the foreground color is the color of a bitmap or other graphic.


grid block

The space between two adjacent grid points.


IME

Input Method Editor. An application that translates what you type into characters of a DBCS language, such as Japanese or Chinese. As the user types, the IME displays possible equivalents. The user selects the most appropriate entry.


inherited property

A property that has acquired the characteristics of another class.


keyboard state

A return value that identifies which keys are pressed and whether keyboard modifiers, SHIFT, CTRL, and ALT are pressed.


OLE container controls

A Visual Basic control that is used to link and embed objects from other applications in a Visual Basic application.


OLE object

An object in an application that can be linked or embedded.


OLE status code

Object Linking and Embedding defines a data structure to return information for error conditions. The error number is a portion of that information.


placeholder

A character that masks or hides another character for security reasons, for example, when a user types a password, an asterisk appears on the screen to take the place of each character typed.


property page

A grouping of properties presented as a tabbed page of a property sheet.


RGB

A method used with color monitors to describe colors as a mixture of red (R), green (G), and blue (B). The color is defined as a set of three integers (R,G,B) where each integer ranges from 0–255. A value of 0 indicates a total absence of that color component. A value of 255 indicates the highest intensity of that color component.


single-precision value

The size of this data value is 16-bits or 2 bytes.


system colors

Colors that are defined by the operating system for a particular type of monitor and video adapter. Each color is associated with a specific part of the user interface, such as a window title or a menu.


target

An object onto which the user drops the object being dragged.


transparent

Describes the background of the object if the background is not visible. Instead of the background, you see whatever is behind the object, for example, an image or picture used as a backdrop in your application. Use the BackStyle property to make the background transparent.


unbound

Describes a control that is not related to a worksheet cell. In contrast, a bound control is a data source for a worksheet cell that provides access to display and edit the value of a control.


z-order

The visual layering of controls on a form along the form's z-axis (depth). The z-order determines which controls are in front of other controls.


What is a MultiPage?

A MultiPage is a control that contains a collection of one or more pages.

Each Page of a MultiPage is a form that contains its own controls, and as such, can have a unique layout. Typically, the pages in a MultiPage have tabs so the user can select the individual pages.

By default, a MultiPage includes two pages, called Page1 and Page2. Each of these is a Page object, and together they represent the Pages collection of the MultiPage. If you add more pages, they become part of the same Pages collection.


What is a TabStrip?

A TabStrip is a control that contains a collection of one or more tabs.

Each Tab of a TabStrip is a separate object that users can select. Visually, a TabStrip also includes a client area that all the tabs in the TabStrip share.

By default, a TabStrip includes two pages, called Tab1 and Tab2. Each of these is a Tab object, and together they represent the Tabs collection of the TabStrip. If you add more pages, they become part of the same Tabs collection.


Should I use a MultiPage or a TabStrip?

If you use a single layout for data, use a TabStrip and map each set of data to its own Tab. If you need several layouts for data, use a MultiPage and assign each layout to its own Page.

Unlike a Page of a MultiPage, the client region of a TabStrip is not a separate form, but a portion of the form that contains the TabStrip. The border of a TabStrip defines a region of the form that you can associate with the tabs. When you place a control in the client region of a TabStrip, you are adding a control to the form that contains the TabStrip.


Tips on using text boxes

The TextBox is a flexible control governed by the following properties: Text, MultiLine, WordWrap, and AutoSize.

Text contains the text that’s displayed in the text box.

MultiLine controls whether the TextBox can display text as a single line or as multiple lines. Newline characters identify where one line ends and another begins. If MultiLine is False, then the text is truncated instead of wrapped.

WordWrap allows the TextBox to wrap lines of text that are longer than the width of the TextBox into shorter lines that fit.

If you do not use WordWrap, the TextBox starts a new line of text when it encounters a newline character in the text. If WordWrap is turned off, you can have text lines that do not fit completely in the TextBox. The TextBox displays the portions of text that fit inside its width and truncates the portions of text that do not fit. WordWrap is not applicable unless MultiLine is True.

AutoSize controls whether the TextBox adjusts to display all of the text. When using AutoSize with a TextBox, the width of the TextBox shrinks or expands according to the amount of text in the TextBox and the font size used to display the text.

AutoSize works well in the following situations:

•	Displaying a caption of one or more lines.

•	Displaying the contents of a single-line TextBox.

•	Displaying the contents of a multiline TextBox that is read-only to the user.

Note   Avoid using AutoSize with an empty TextBox that also uses the MultiLine and WordWrap properties. When the user enters text into a TextBox with these properties, the TextBox automatically sizes to a long narrow box one character wide and as long as the line of text.


Create a standard list box

1	In the Properties window, select the ListStyle property.

2	Click the drop-down arrow to display a list of available styles.

3	From the list, choose Plain.


Create a list box with option buttons or check boxes

1	In the Properties window, select the ListStyle property.

2	Click the drop-down arrow to display a list of available styles.

3	From the list, choose Option.

When the MultiSelect property is False, the list appears with option buttons. When MultiSelect is True, the list appears with check boxes.


ListBox styles

You can choose between two presentation styles for a ListBox. Each style provides different ways for users to select items in the list.

If the style is Plain, each item is on a separate row; the user selects an item by highlighting one or more rows.

If the style is Option, an option button or check box appears at the beginning of each row. With this style, the user selects an item by clicking the option button or check box. Check boxes appear only when the MultiSelect property is True.


What is the difference between the DataObject and the Clipboard?

The DataObject and the Clipboard both provide a means to move data from one place to another. As an application developer, there are several important points to remember when you use either a DataObject or the Clipboard:

•	You can store more than one piece of data at a time on either a DataObject or the Clipboard as long as each piece of data has a different data format. If you store data with a format that is already in use, the new data is saved and the old data is discarded.

•	The Clipboard supports picture formats and text formats. A DataObject currently supports only text formats.

•	A DataObject exists only while your application is running; the Clipboard exists as long as the operating system is running. This means you can put data on the Clipboard and close an application without losing the data. The same is not true with the DataObject. If you close the application that put data on a DataObject, you lose the data.

•	A DataObject is a standard OLE object, while the Clipboard is not. This means the Clipboard can support standard move operations (copy, cut, and paste) but not drag-and-drop operations. You must use the DataObject if you want your application to support drag-and-drop operations.

Tip   You can define your own data format names when you use the SetText method to move data to the Clipboard or a DataObject. This can help distinguish between text that your application moves and text that the user moves.


Display or hide the Toolbox

On the View menu, determine whether a check mark appears in front of Toolbox. If the check mark is present, the Toolbox is displayed. If not, the Toolbox is hidden.

Do one of the following:

•	To display the Toolbox, make sure a check mark appears in front of Toolbox. If not, select Toolbox.

•	To hide the Toolbox, make sure there is no check mark in front of Toolbox. If there is, select Toolbox to remove it.


What is the Toolbox?

The Toolbox identifies the different controls that you can add to a form, Frame, or Page.

You can customize the Toolbox in many ways including the following:

•	Add pages to the Toolbox.

•	Move controls from one page to another.

•	Rename pages.

•	Add other controls, including ActiveX controls, to the Toolbox.

•	Copy customized controls from the form into the Toolbox.

For example, OK and Cancel buttons are special cases of a CommandButton. If you add OK and Cancel templates to the Toolbox, you can quickly add them to other forms.


Add a customized control to the Toolbox

1	Place a control on your form and customize it.

For example, to create an OK button, place a CommandButton on the form, set its Caption property to OK and set its Default property to True.

3	Select the customized control.

4	Drag the control to the Toolbox.

Note   When you drag a control onto the Toolbox, you only transfer property values. Any code you have written for that control does not transfer with the control. You must write new code for the icon or copy code from the control on the form to the control on the Toolbox.


Add a control to the Toolbox

1	Right-click any control icon in the Toolbox, or an empty area on any page of the Toolbox.

2	From the shortcut menu, select Additional Controls.

3	From the Available Controls list, select the new controls.

4	Click OK.


Delete an item from the Toolbox

1	In the Toolbox, right-click the icon of the item you want to remove.

2	From the shortcut menu, select Delete. The command will include the name of the selected control.

Note   If you are deleting controls, you can use Additional Controls from the shortcut menu, and clear the check boxes of all controls you want to delete.


Customize a Toolbox icon

1	Right-click the icon in the Toolbox.

2	From the shortcut menu, choose Customize.

3	Do one of the following:

•	To change the ToolTip, enter the new text for the ToolTip.

•	To edit the icon, choose Edit Picture. Then choose the color you want to use and choose the pixel in the image where you want to apply that color.

•	To assign a new bitmap, choose Load Picture. Then identify the file that contains the bitmap you want to use as the icon. If you attempt to load a picture that is larger than an icon, an error occurs.


What is a ToolTip?

A ToolTip is a short description, usually just a few words, that appears when the user holds the mouse pointer briefly over a control or another part of the user interface without clicking. You can customize ToolTips for controls and for the Toolbox.

The default value for a new control that is copied from a form to the Toolbox is “New” followed by the control type. For example, the default ToolTip for a customized CommandButton (such as OK) is “New CommandButton”. If a control has no associated ToolTip, “Unknown” is the default value.

Note   The ToolTip is information provided by Microsoft Forms to forms developers in design mode. Each control has a property, ControlTipText, that allows forms developers to give a “ToolTip” to end users while the application is running.


Customize a ToolTip in the Toolbox

1	Select the control in the Toolbox.

2	Right-click.

3	From the shortcut menu, choose Customize. The Customize command will include the name of the control, such as “Customize Label.”

4	Enter the new text for the ToolTip.

5	Click OK.


Set the ToolTip for a Toolbox page

1	Select the page of the Toolbox.

2	Right-click.

3	From the shortcut menu, choose Rename.

4	Enter the new text for the ToolTip.

5	Click OK.


Change the name of a Toolbox page

1	Right-click the tab of the Toolbox page whose name you want to change.

2	From the shortcut menu, choose Rename.

3	In the Caption field, enter the name you want to use.

4	Click OK.


Change the order of Toolbox pages

1	Right-click the tab of any Toolbox page.

2	From the shortcut menu, choose Move.

3	Select the name of a page you want to move.

4	Choose Move Up or Move Down until the page is at the appropriate position in the page list.

5	Click OK.


Create a new Toolbox page

1	Right-click the tab of any Toolbox page. The new page will be inserted after this page.

2	Choose New Page.


Delete a Toolbox page

1	Right-click the tab of the Toolbox page you want to delete.

2	Choose Delete Page. All controls on the page are deleted at the same time.


Import or export a Toolbox page

1	Right-click the tab of any page in the Toolbox. If you import a page, it will be inserted after this page.

2	Do one of the following:

•	To import a page, choose Import Page. Then select the name of the page file you want to import.

•	To export a page, choose Export Page. Then enter a name for the file that will store a copy of the Toolbox page. Exporting a page does not remove it from the Toolbox.

1	Click OK.


Move an item to another Toolbox page

1	Select a control on any page of the Toolbox.

2	Drag the control to the tab of the new page. Hold the mouse pointer over the tab until the page appears at the front of the Toolbox.

3	Drag the control onto the main region of the page.

Note   If the page you want to place the control on is not visible, you can increase the width of the Toolbox to display tabs for all the pages, and then drag the control to the appropriate page.


Change the size of the Toolbox

1	Move the mouse pointer over an edge or a corner of the Toolbox. The pointer changes to a double-ended arrow.

2	When the double-ended arrow appears, drag the Toolbox to change its size.


Assign a custom Help topic to a control

This procedure assumes you have created a custom Help file and associated it with your project. The procedure for associating a Help file with a project depends on your project environment.

1	Select a control for which you have written a custom Help topic.

2	In the Properties window, select the HelpContextID property.

3	Enter the context ID of the appropriate topic from your custom Help file.


Custom Help files

As an application developer, you can use a custom Help file to provide information about how to use your form application.

To create a custom Help file, use a product or tool that creates Windows Help files.

You can associate a specific topic in your custom Help file with each control in your application. When your application is running, the user can view your Help topic by selecting the control and pressing F1.


Assign an accelerator key

1	In design mode, select the control on the form.

2	In the Properties window, select the Accelerator property.

3	Enter a single character as the value for Accelerator.

Tip   Use a character from the caption of the control. Note that the selected character is underlined in the control’s caption.


Assign an accelerator key for a Page or Tab

1	In design mode, select an individual Page or Tab. Be sure to select the Page or Tab, not the associated MultiPage or TabStrip. When a Page or Tab is selected, a rectangle appears around the caption of the Page or Tab.

2	Right-click the selected Page or Tab.

3	From the shortcut menu, choose Rename.

4	In the Rename dialog box, enter a single character in the Accelerator Key field.

Tip   Use a character from the caption of the control. Note that the selected character is underlined in the control’s caption.


Assign a control tip to a Page or Tab

1	Select an individual Page or Tab.

Be sure to select an individual Page or Tab, not the corresponding MultiPage or TabStrip. When a Page or Tab is selected, a rectangle appears around its caption.

2	Right-click the selected Page or Tab.

3	From the shortcut menu, choose Rename.

4	In the ControlTipText field, type the string you want to use as the control tip.

5	Click OK.

Tip   To assign a control tip for a MultiPage or TabStrip, use the ControlTipText property.


Assign a control tip to a control

1	Select the control.

2	In the Properties window, select the ControlTipText property.

You can also set the value of ControlTipText through code.

3	Enter the string you want to use as the control tip.

Tip   To assign a control tip for a Page or Tab, use the Rename command on the shortcut menu of the Page or Tab.


What is a control tip?

A control tip is a brief phrase that describes a control, a Page, or a Tab. The control tip appears when the user briefly holds the mouse pointer over a control without clicking. A control tip is very similar to a ToolTip. The difference is that Microsoft Forms provides ToolTips to developers at design time, and developers provide control tips to end-users at run time.

If you assign a control tip to a MultiPage or a TabStrip, control tips for the individual Page or Tab objects within the MultiPage or TabStrip are not displayed.


Assign a caption

To assign a caption to a CheckBox, CommandButton, Frame, Label, OptionButton, or ToggleButton:

1	Display the control’s Properties window.

2	Select the Caption property.

3	Enter the text you want to use as the caption.

To assign a caption to a Page or Tab:

1	Select the MultiPage or TabStrip that contains the Page or Tab.

2	Select the individual Page or Tab. When the Page or Tab is selected, a rectangle appears around its caption.

3	Right-click the selected MultiPage or TabStrip.

4	From the shortcut menu, choose Rename.

5	In the Caption field, enter the text you want to use as the caption.

6	Click OK.


What is a caption?

A caption is descriptive text that appears directly on or around a control. The following controls can have captions: CheckBox, CommandButton, Frame, Label, OptionButton, and ToggleButton. The Page and Tab objects that are part of the MultiPage and TabStrip also can have captions.


Set the tab order using the Tab Order dialog box

1	Make sure no controls are selected.

2	Right-click in the form, but not on a control.

3	From the shortcut menu, choose Tab Order.

4	Select the name of a control you want to reposition in the tab order.

5	Choose Move Up or Move Down until the control name is in the appropriate position in the tab order.


Set the tab order using the TabIndex property

1	Identify the tab order you want to use for the form.

The tab index of the first control in the tab order is 0; the tab index of the second is 1, and so on.

3	Select a control in the tab order.

4	In the Properties window, select the TabIndex property.

5	Enter the appropriate number to identify the control’s position in the tab order.


Change the order of pages in a MultiPage or TabStrip

1	Select any page in the MultiPage or TabStrip.

2	Right-click the caption of the page.

3	From the shortcut menu, choose Move.

4	In the Move dialog box, select the Page you want to move.

5	Choose Move Up or Move Down to change the position of the page.

6	When you’ve made all changes you want to, click OK.

Note   You can also use the Index property to change the page order through the Properties window. The index of the first page is 0; the index of the second page is 1, and so on.


Change the size of the form

At design time:

•	Drag the sizing handle of the form until the form is the size you want.

At run time:

•	Set the form’s Height and Width properties to the appropriate values.


Change the location of the form

Through the user interface:

•	Drag the title bar until the form is where you want it.

At design time:

•	Set the form’s Left and Top properties to the appropriate values. You can set these properties through the Properties window or through code.


Ways to protect sensitive information

Many applications use data that should be available only to certain users. Here are some suggestions you can use to protect sensitive information in Microsoft Forms:

•	Write code that makes a control (and its data) invisible to unauthorized users. The Visible property makes a control visible or invisible. For more information about Visible, click [image].

•	Write code that sets the control’s foreground and background to the same color when unauthorized users run the application. This hides the information from unauthorized users. The ForeColor and BackColor properties determine the foreground color and the background color. For information about ForeColor, click [image]. For information about BackColor, click [image].

•	Disable the control when unauthorized users run the application. The Enabled property determines when a control is disabled. For information about Enabled, click [image].

•	Require a password for access to the application or a specific control. You can use placeholders as the user types each character. The PasswordChar property defines placeholder characters. For information about PasswordChar, click [image].

Note   Using passwords or any other techniques listed can improve the security of your application, but does not guarantee the prevention of unauthorized access to your data.


Make a control that automatically adjusts to the size of its data

In the Properties window, set the AutoSize property to True.


Ways to change the appearance of a control

Microsoft Forms includes several properties that let you define the appearance of controls in your application:

•	ForeColor

•	BackColor, BackStyle

•	BorderColor, BorderStyle

•	SpecialEffect

ForeColor determines the foreground color. The foreground color applies to any text associated with the control, such as the caption or the control’s contents.

BackColor and BackStyle apply to the control’s background. The background is the area within the control’s boundaries, such as the area surrounding the text in a control, but not the control’s border. BackColor determines the background color. BackStyle determines whether the background is transparent. A transparent control background is useful if your application design includes a picture as the main background and you want to see that picture through the control.

BorderColor, BorderStyle, and SpecialEffect apply to the control’s border. You can use BorderStyle or SpecialEffect to choose a type of border. Only one of these two properties can be used at a time. When you assign a value to one of these properties, the system sets the other property to None. SpecialEffect lets you choose one of several border styles, but only lets you use system colors for the border. BorderStyle supports only one border style, but lets you choose any color that is a valid setting for BorderColor. BorderColor specifies the color of the control’s border, and is only valid when you use BorderStyle to create the border.


Things you can do with a picture on an Image control

An Image control is not a picture itself; rather, it contains a picture that is stored in a separate file. You cannot edit the picture with the properties of the Image, but you can use them to specify the way the picture appears on the Image.

An interesting application of Image is that you can use it as a background picture for your application. To do this, make the Image the same size as the form. Then, you can place other controls on top of the background.


Align text in a control

1	In the Properties window, choose the TextAlign property.

2	Click the drop-down arrow next to the property’s value to display a list of available choices.

3	Choose one of the following:

•	Left—to align the text with the left edge of the control.

•	Right—to align the text with the right edge of the control.

•	Center—to center the text relative to the length of the control.

TextAlign is available for a ComboBox, Label, and TextBox.


Show or hide the grid

1	From the Tools menu, choose Options.

2	Select the General tab sheet.

3	Do one of the following:

•	To show the grid, check the Show Grid box.

•	To hide the grid, clear the Show Grid box.

1	Click OK.


Size to grid

1	Select the control.

2	From the Format menu, choose Size to Grid.

Microsoft Forms adjusts the size of the selected control so that each corner aligns with a grid point.


Size to fit

1	Select the control.

2	From the Format menu, choose Size to Fit.

Microsoft Forms sets the size of the control so it is just large enough to display its picture and any text assigned to the Caption or Text property.


Make controls the same size

1	Select all the controls you want to be the same size.

2	Select the dominant control.

3	From the Format menu, choose Make Same Size.

4	From the cascading menu, choose one of the following:

•	Width—to make all selected controls the same width as the dominant control.

•	Height—to make all selected controls the same height as the dominant control.

•	Both—to make all selected controls the same height and width as the dominant control.


Align controls

1	Select the controls to align.

2	Select the dominant control.

3	From the Format menu, choose Align.

4	From the cascading menu, choose one of the following to align the specified part of each selected control with the same part of the dominant control:

•	Lefts—to align the left edge.

•	Centers—to align the center of each control. This means a vertical line drawn at the center of the dominant control would contain the center of every selected control.

•	Rights—to align the right edge.

•	Tops—to align the top.

•	Middles—to align the center of each control. This means a horizontal line drawn at the center of the dominant control would also contain the center of every selected control.

•	Bottoms—to align the bottom.

•	To Grid—to align the upper left corner of each selected control with its nearest grid point. Note that this option is not based on the position of the dominant control.

Note   Each command on the menu has a small picture that shows how the controls will be aligned.


Adjust horizontal and vertical spacing between controls

1	Select the controls where you want to adjust spacing.

2	From the Format menu, choose Horizontal Spacing or Vertical Spacing.

3	From the cascading menu, choose one of the following:

•	Make Equal—to make all horizontal and vertical spaces between controls the same size. The amount of horizontal and vertical space will vary depending on the area available for displaying controls and the combined width of all controls.

•	Increase—to increase the space between controls by one grid block.

•	Decrease—to decrease the space between controls by one grid block.

•	Remove—to remove the space between controls. The controls do not overlap, but are immediately adjacent to each other.


Arrange buttons

1	Select the CommandButton controls to arrange.

2	From the Format menu, choose Arrange Buttons.

3	From the cascading menu, choose one of the following:

•	Bottom—to put the buttons in a row starting at the bottom left corner of the form and align the bottoms of all buttons.

•	Right—to put the buttons in a column starting at the upper right corner of the form and align the right edges of all buttons.

After you arrange the buttons, use either Horizontal Spacing or Vertical Spacing on the Format menu to adjust the spacing between the buttons.

Tip   Select a small grid size before choosing this command to position the buttons close to the bottom or right of the form. Changing the grid size after the buttons are in place will not change their position.


Center controls in a form

1	Select the controls or groups to center.

2	From the Format menu, choose Center in Form.

3	From the cascading menu, choose one of the following:

•	Horizontally

•	Vertically


Things you can do with control groups

A group is two or more controls on a form that you treat as a single unit. You can include any control on the form in a group. Once controls belong to a group, you can work with the entire group, or you can select a single object.

Microsoft Forms provides many ways to work with groups and the controls in a group. After you select a group, you can do any of the following:

•	Size all controls in the group at the same time. For more information, click [image].

•	Select a single control inside a group. For more information, click [image].

•	Break up the group so each control is independent of the others. For more information, click [image].

•	Display the group’s shortcut menu, which provides quick access to commands that affect the group. For more information, click [image].

•	Select a single control within the group without breaking up the group, which lets you change property settings of that control without affecting any other control in the group. For more information, click [image].


Transparency in Microsoft Forms

Microsoft Forms supports transparency in two areas: the background of certain controls, and in bitmaps used on certain controls.

The BackStyle property determines whether a control is transparent. A transparent control lets you see what is behind it on the form. This is useful if you have a decorative background on the form and you want to minimize the amount of that background that is hidden behind the controls. For more information on making a control transparent, click [image].

You can display a bitmap on many controls in Microsoft Forms. Certain controls support transparent bitmaps, that is, bitmaps in which one or more background color is transparent. Bitmap transparency is not controlled by any control property; it is controlled by the color of the lower-left pixel in the image. Microsoft Forms does not provide a way to edit a bitmap and make it transparent; you must use a picture editor for this purpose.

In Microsoft Forms, bitmaps are always transparent on the following controls:

•	CheckBox

•	CommandButton

•	Label

•	OptionButton

•	ToggleButton

Transparent pictures sometimes have a hazy appearance. If you do not like this appearance, display the picture on a control that supports opaque images.

If you use a transparent bitmap on a control that does not support transparent bitmaps, the bitmap will display correctly but you won’t be able to see what’s behind it. In Microsoft Forms, the following controls do not support transparent bitmaps:

•	The form window (UserForm)

•	Frame

•	Image

•	MultiPage


What is a shortcut menu?

A shortcut menu is a menu that appears when you right-click an object. In Microsoft Forms, the following objects have shortcut menus:

•	The Toolbox, each page in the Toolbox, and each item on a page of the Toolbox.

•	Individual controls on a form.

•	Groups of controls (groups created with the Group command).

•	Containers (such as UserForm).

•	Individual Page objects in a MultiPage.

•	Individual Tab objects in a TabStrip.

•	Multiple controls that aren’t in a group.

The commands on a shortcut menu vary depending on the object you select. For example, if you select multiple controls that aren’t in a group, the shortcut menu will include the Group command; the shortcut menu for the Toolbox will not.

To display the shortcut menu for a control or container, right-click the object.

For more information on displaying the shortcut menu for a MultiPage or a Page, click [image].

For more information on displaying the shortcut menu for a TabStrip or a Tab, click [image].


Ways to put data in a ListBox or ComboBox

In a ListBox or ComboBox with a single column, the AddItem method provides an effective technique for adding an individual entry to the list. In a multicolumn ListBox or ComboBox, however, the List and Column properties offer another technique; you can load the list from a two-dimensional array.


Things you can do with a multicolumn ListBox or ComboBox

To control the column widths of a multicolumn ListBox or ComboBox, you can specify the width, in points, for all the columns in the ColumnWidths property. Specifying zero for a specific column hides that column of information from the display.

If you want to hide all but one column of a ListBox or ComboBox from the user, you can identify the column of information to display by using the TextColumn property.

Similarly, you can control which column of values is used for the control when the user makes a selection by specifying the column number in the BoundColumn property.


Add items to a list using the List or Column property

1	Create a multicolumn ListBox or ComboBox.

2	Create a two-dimensional array that contains the items you want to put in the list.

3	Set the ColumnCount property of the ListBox or ComboBox to match the number of entries in the list.

4	Do one of the following:

•	Assign the array as the value of the List property. The contents of the ListBox will match the contents of the array exactly.

•	Assign the array as the value of the Column property. Column transposes rows and columns, so each row of the ListBox matches the corresponding column of the array.


Show or hide ToolTips

1	From the Tools menu, choose Options.

2	Select the General tab sheet.

3	Do one of the following:

•	To display ToolTips, check the Show ToolTips box.

•	To hide ToolTips, clear the Show ToolTips box.


Object model for Microsoft Forms

The Microsoft Forms object model includes the following types of object:

•	Controls

•	Collections

•	Objects (within collections)

Each element of the Microsoft Forms object model has some combination of properties, events, and methods that you can use to make your application work the way you want it to.

Microsoft Forms has three collections:

Controls collection—contains all the controls on a form, Frame, or Page.

Pages collection—contains all the Page objects in a MultiPage. Each MultiPage has its own distinct Pages collection.

Tabs collection—contains all the Tab objects in a TabStrip. Each TabStrip has its own distinct Tabs collection.


Ways to create an option group

By default, all OptionButton controls on a container (such as a form, a MultiPage, or a Frame) are part of a single option group. This means that selecting one of the buttons automatically sets all other option buttons on the form to False.

If you want more than one option group on the form, there are two ways to create additional groups:

•	Use the GroupName property to identify related buttons.

•	Put related buttons in a Frame on the form.

The first method is recommended over the second because it reduces the number of controls required in the application. This reduces the disk space required for your application and can improve the performance of your application as well.

Note   A TabStrip is not a container. Option buttons in the TabStrip are included in the form’s option group. You can use GroupName to create an option group from buttons in a TabStrip.


Create an option group using the GroupName property

1	Place all required OptionButton controls on the form. Note that option buttons in a MultiPage or Frame will automatically form an option group.

2	Identify the buttons for each group you want to create.

3	Enter a value for the Name property of each control.

4	For each button in a group, set the GroupName property to the same value.


Ways to match entries in a list

Microsoft Forms provides three ways to match a value entered by the user with an entry that exists in the list of a ListBox or ComboBox:

•	No matching—provides no assistance in matching a user’s typed entry to an entry in the list.

•	First letter—compares the most recently-typed letter to the first letter of each entry in the list. The first match in the list is selected.

•	Complete—compares the user’s entry and tries to find an exact match in an entry from the list.

The matching feature resets after two seconds (six seconds in the Far East version). For example, if you have a list of the 50 states and you type “CO” quickly, you will find “Colorado.” But if you type “CO” slowly, you will find “Ohio” because the auto-complete search resets between letters.

If you choose Complete matching, it is a good idea to sort the list entries alphabetically (you can use the TextColumn property to do this). If the list is not sorted alphabetically, matching may not work correctly. For example, if the list includes Alabama, Louisiana, and Alaska in that order, then “Alabama” will be considered a complete match if the user types “ala.” In fact, this result is ambiguous because there are two entries in the list that could match what the user entered. Sorting alphabetically eliminates this ambiguity.


Layer controls
Use z-order to layer controls

To place a control at the front or back of the z-order:

1.	Select the controls you want to reposition.

2.	From the Format menu, choose Order.

3.	From the cascading menu, select Bring to Front or Send to Back.

To adjust a control one position in the z-order:

1.	Select the controls you want to reposition.

2.	From the Format menu, choose Order.

3.	From the cascading menu, select Bring Forward or Send Backward.

Note   You can't Undo or Redo layering commands, such as Send to Back or Bring to Front. For example, if you select an object and click Move Backward on the shortcut menu, you won't be able to Undo or Redo that action.


Create a transparent control

1	Put the basic control onto the form.

2	View the control’s properties.

3	Set the BackStyle property to Transparent.

4	If the control supports the BorderStyle property, set it to None.

Note   When you make a control transparent, the background color does not display, so the BackColor property is ignored. However, the setting for BackColor is not changed when a control is transparent.


Delete a bitmap from a control

In the Properties window:

1	Highlight the value of the Picture property (the word “bitmap”).

2	Press DELETE.

Or, in code:

•	Enter the following statement: Object.Picture = LoadPicture(“”)


Assign a bitmap to a control

In the Properties window:

1	Choose the Picture property.

2	In the Picture dialog box, enter the name of the picture and its location.

If the picture is larger than the control, Microsoft Forms scales the picture to fit the control, regardless of whether you assign the picture through the Properties window or through code. The PictureAlignment property determines how it is aligned within the control.


Ways to align a picture on a control

The Picture property assigns a bitmap or other picture to a control. After you assign the picture to the control, you can do any of the following to align the picture on the control:

•	Use the PictureAlignment property to center the picture within the Image or align any corner of the picture with the corresponding corner of the Image.

•	Use the PictureSizeMode property to clip, stretch, or zoom the picture within the Image. Stretching can distort the picture, but zooming will not.

•	Use the PictureTiling property to display multiple copies of the picture within the Image.


Select a grid size

1	From the Tools menu, choose Options.

2	In the Options dialog box, choose the General page.

3	In the Form Grid Settings group, specify the size you want for each grid block. Specifying smaller numbers results in smaller grid blocks.

Tip   If you use the Arrange Buttons command to position command buttons in your application, try a small grid setting. This will allow you to position the buttons closer to the edge of the form.


Create a control group

1	In the form, select each control you want to include in the group.

2	From the Format menu, choose Group.


Size all the controls in a group

1	Select the group.

A rectangle with sizing handles surrounds the group to indicate it is selected.

3	Click one of the sizing handles and drag it to change the size of the rectangle.

4	Release the mouse button.

The size of each control will be changed proportionately to the way you changed the rectangle around the group.


Break up a control group

1	Select the group.

2	From the Format menu, choose Ungroup.


Display a group's shortcut menu
Display a group’s shortcut menu

1	Select the group.

2	Right-click anywhere inside the rectangle that surrounds the group.

Tip   Click anywhere in the group, but not on the shortcut menu, to make the shortcut menu go away if you don’t want to use any of the commands on the menu.


Select a control within a group

1	Select the group.

2	Select a single control within the group. The sizing handles around the group become lighter, and dark handles appear on the selected control.

You can change the value of the selected control’s properties. Any changes you make will affect only the selected control.

3	When you’re finished working with the selected control, click anywhere inside the group, but not on the selected control. The group is still selected.

You can select another control in the group or go on to any other task you need to perform.


Display the shortcut menu for a MultiPage or Page

1	Make sure the form isn’t running.

2	Do one of the following:

•	To display the shortcut menu of an individual Page, right-click the caption of the appropriate page.

•	To display the shortcut menu of the entire MultiPage, right-click anywhere in the control, but not on the caption of any Page in the control.


Display the shortcut menu for a TabStrip or Tab

1	Make sure the form isn’t running.

2	Do one of the following:

•	To display the shortcut menu of an individual Tab, select the appropriate tab.

When the tab is selected, a dotted rectangle appears around its caption.

Right-click the selected caption.

•	To display the shortcut menu of the TabStrip, right-click anywhere in the control, but not on the caption of any Tab in the control.


The Rename dialog box

Contains the Accelerator, Caption, and ControlTipText property settings for the individual page or tab that has the focus. Contains the Caption and ToolTipText property settings for the current Toolbox page. You can update the values for these properties.

The accelerator key is a keyboard key that the user presses simultaneously with ALT to set the focus to a Page or Tab. The caption is the text in the tab area of a Page or Tab, or the current Toolbox page. The ControlTipText is a brief description of a control that appears when the user holds the mouse pointer over the control without clicking. The ToolTipText is a brief description of a control that appears when the user holds the mouse pointer over the current Toolbox page without clicking.

To set an accelerator for the Page or Tab:

•	Enter a single character for Accelerator.

To rename the Page or Tab:

•	Enter a new value for Caption.

To define ControlTipText for the Page or Tab:

•	Enter a new value for ControlTipText.

To define ToolTipText for the current Toolbox page:

•	Enter a new value for ToolTipText.

Note   Click OK to apply the new values to the page, tab, or Toolbox page.


The Page Order/Tab Order dialog box

To change the position of a page or tab:

1.	Select the name of the Page or Tab you want to move.

2.	Choose Move Up or Move Down until the selected item is in the desired location.

3.	When all items are in the order you want, click OK.


The Additional Controls dialog box

1.	In the Available Controls list, select the control or controls you want to add to the Toolbox.

2.	Click OK.

Tip   You can filter the Available Controls list by selecting options in the Show group.


The Customize Control dialog box

Contains the ControlTipText property and the icon that represents this control in the Toolbox. With this dialog box, you can define or change the ControlTipText associated with this control, as well as change the icon that is displayed in the Toolbox.

To define or edit ControlTipText:

•	Enter a new value for ControlTipText.

To edit the icon:

1.	Choose the Edit Picture CommandButton.

2.	Use the Image Editor to alter the icon as needed.

To load another icon:

1.	Choose the Load Picture CommandButton.

2.	From the common dialog box, select a picture file.

3.	Click OK to apply the new values.


Item Method Example

The following example demonstrates how to use the Item method to access individual members of the Controls and Pages collections.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	A CommandButton named CommandButton1.

•	A Label named Label1.

•	Two OptionButton controls named OptionButton1 and OptionButton2.

•	A MultiPage named MultiPage1.

Dim MyControl As Object

Dim ControlsIndex As Integer

Private Sub CommandButton1_Click()

    If OptionButton1.Value = True Then

        'Process Controls collection for UserForm

        Set MyControl = Controls.Item(ControlsIndex)

        Label1.Caption = MyControl.Name

        'Prepare index for next control on Userform

        ControlsIndex = ControlsIndex + 1

        If ControlsIndex >= Controls.Count Then

            ControlsIndex = 0

        End If

    ElseIf OptionButton2.Value = True Then

        'Process Current Page of Pages collection

        Set MyControl = MultiPage1.Pages.Item(MultiPage1.Value)

        Label1.Caption = MyControl.Name

    End If

End Sub

Private Sub UserForm_Initialize()

    ControlsIndex = 0

    'TabsIndex = 0

    OptionButton1.Caption = "Controls Collection"

    OptionButton2.Caption = "Pages Collection"

    OptionButton1.Value = True

    CommandButton1.Caption = "Get Member Name"

End Sub


GroupName Property Example

The following example demonstrates how to create two groups of OptionButton controls on the same form by setting the value of the GroupName property for each OptionButton.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains five OptionButton controls named OptionButton1 through OptionButton5.

Private Sub UserForm_Initialize()

    OptionButton1.GroupName = "Widgets"

    OptionButton2.GroupName = "Widgets"

    OptionButton4.GroupName = "Widgets"

    OptionButton3.GroupName = "Gadgets-Group2"

    OptionButton5.GroupName = "Gadgets-Group2"

End Sub


DragBehavior, EnterFieldBehavior Properties Example

The following example demonstrates the different effects that you can provide when entering a control and when dragging information from one control to another. The DragBehavior and EnterFieldBehavior properties provide these effects.

The sample uses two TextBox controls. You can set DragBehavior and EnterFieldBehavior for each control and see the effects of dragging from one control to another.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	A TextBox named TextBox1.

•	Two ToggleButton controls named ToggleButton1 and ToggleButton2. These controls are associated with TextBox1.

•	A TextBox named TextBox2.

•	Two ToggleButton controls named ToggleButton3 and ToggleButton4. These controls are associated with TextBox2.

Private Sub UserForm_Initialize()

    TextBox1.Text = "Once upon a time in a land ...,"

    ToggleButton1.Value = True

    ToggleButton1.Caption = "Drag Enabled"

    ToggleButton1.WordWrap = True

    TextBox1.DragBehavior = fmDragBehaviorEnabled

    ToggleButton2.Value = True

    ToggleButton2.Caption = "Recall Selection"

    ToggleButton2.WordWrap = True

    TextBox2.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection

    TextBox2.Text = "XXX, YYYY"

    ToggleButton3.Value = False

    ToggleButton3.Caption = "Drag Disabled"

    ToggleButton3.WordWrap = True

    TextBox1.DragBehavior = fmDragBehaviorDisabled

    ToggleButton4.Value = False

    ToggleButton4.Caption = "Select All"

    ToggleButton4.WordWrap = True

    TextBox2.EnterFieldBehavior = fmEnterFieldBehaviorSelectAll

End Sub

Private Sub ToggleButton1_Click()

    If ToggleButton1.Value = True Then

       ToggleButton1.Caption = "Drag Enabled"

       TextBox1.DragBehavior = fmDragBehaviorEnabled

    Else

       ToggleButton1.Caption = "Drag Disabled"

       TextBox1.DragBehavior = fmDragBehaviorDisabled

    End If

End Sub

Private Sub ToggleButton2_Click()

    If ToggleButton2.Value = True Then

        ToggleButton2.Caption = "Recall Selection"

        TextBox1.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection

    Else

        ToggleButton2.Caption = "Select All"

        TextBox1.EnterFieldBehavior = fmEnterFieldBehaviorSelectAll

    End If

End Sub

Private Sub ToggleButton3_Click()

    If ToggleButton3.Value = True Then

       ToggleButton3.Caption = "Drag Enabled"

       TextBox2.DragBehavior = fmDragBehaviorEnabled

    Else

       ToggleButton3.Caption = "Drag Disabled"

       TextBox2.DragBehavior = fmDragBehaviorDisabled

    End If

End Sub

Private Sub ToggleButton4_Click()

    If ToggleButton4.Value = True Then

        ToggleButton4.Caption = "Recall Selection"

        TextBox2.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection

    Else

       ToggleButton4.Caption = "Select All"

       TextBox2.EnterFieldBehavior = fmEnterFieldBehaviorSelectAll

    End If

End Sub


GetFormat, GetText, SetText Methods Example

The following example demonstrates how to use the GetFormat, GetText, and SetText methods to transfer text between a DataObject and the Clipboard.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	A TextBox named TextBox1.

•	Four CommandButton controls named CommandButton1 through CommandButton4.

•	A Label named Label1.

Dim MyDataObject As DataObject

Private Sub CommandButton1_Click()

‘Put standard format on Clipboard

    If TextBox1.TextLength > 0 Then

        Set MyDataObject = New DataObject

        MyDataObject.SetText TextBox1.Text

        Label1.Caption = "Put on D.O."

    End If

End Sub

Private Sub CommandButton2_Click()

‘Get standard format from Clipboard

    If MyDataObject.GetFormat(1) = True Then

        Label1.Caption = "Std format - " & MyDataObject.GetText(1)

    End If

End Sub

Private Sub CommandButton3_Click()

‘Put custom format on Clipboard

    If TextBox1.TextLength > 0 Then

        Set MyDataObject = New DataObject

        MyDataObject.SetText TextBox1.Text, 233

        Label1.Caption = "Custom on D.O."

    End If

End Sub

Private Sub CommandButton4_Click()

‘Get custom format from Clipboard

    If MyDataObject.GetFormat(233) = True Then

        Label1.Caption = "Cust format - " & MyDataObject.GetText(233)

End If

End Sub


CanPaste Property, Paste, Copy Methods Example

The following example demonstrates how to use the CanPaste property and the Paste method to paste a ComboBox from the Clipboard to a Page of a MultiPage. This sample also uses the SetFocus and Copy methods to copy a control from the form to the Clipboard.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	A TextBox named TextBox1.

•	A ComboBox named ComboBox1.

•	A MultiPage named MultiPage1.

•	A CommandButton named CommandButton1.

Note   This example also includes a subroutine to illustrate pasting text into a control.

Private Sub UserForm_Initialize()

    ComboBox1.AddItem "It's a beautiful day!"

    CommandButton1.Caption = "Copy ComboBox to Clipboard"

    CommandButton1.AutoSize = True

End Sub

Private Sub MultiPage1_DblClick(ByVal Index As Long, Cancel As Boolean)

    If MultiPage1.Pages(MultiPage1.Value).CanPaste = True Then

        MultiPage1.Pages(MultiPage1.Value).Paste

    Else

        TextBox1.Text = "Can't Paste"

    End If

End Sub

Private Sub CommandButton1_Click()

        UserForm1.ComboBox1.SetFocus

        UserForm1.Copy

End Sub

'Code for pasting text into a control

'Private Sub ComboBox1_DblClick(Cancel As Boolean)

'   If ComboBox1.CanPaste = True Then

'        ComboBox1.Paste

'    Else

'        TextBox1.Text = "Can't Paste"

'    End If

'End Sub


ScrollBar Control Example

The following example demonstrates the stand-alone ScrollBar and reports the change in its value as the user moves the scroll box.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	A ScrollBar named ScrollBar1.

•	Two Label controls named Label1 and Label2. Label1 contains scaling information for the user. Label2 reports the delta value.

Private Sub UserForm_Initialize()

    ScrollBar1.Min = -225

    ScrollBar1.Max = 289

    ScrollBar1.Value = 0

    Label1.Caption = "-225  -----Widgets-----   289"

    Label1.AutoSize = True

    Label2.Caption = ""

End Sub

Dim ScrollSaved As Integer        ‘Previous ScrollBar setting

Private Sub ScrollBar1_Change()

    Label2.Caption = " Widget Changes " & (ScrollSaved - ScrollBar1.Value)

End Sub

Private Sub ScrollBar1_Exit(Cancel As Boolean)

    Label2.Caption = " Widget Changes " & (ScrollSaved - ScrollBar1.Value)

    ScrollSaved = ScrollBar1.Value

End Sub

Private Sub ScrollBar1_Scroll()

    Label2.Caption = (ScrollSaved - ScrollBar1.Value) & " Widget Changes by Scrolling"

End Sub


CanUndo, CanRedo Properties and UndoAction, RedoAction Methods Example

The following example demonstrates how to undo or redo text editing within a text box or within the text area of a ComboBox. This sample checks whether an undo or redo operation can occur and then performs the appropriate action. The sample uses the CanUndo and CanRedo properties, and the UndoAction and RedoAction methods.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	A ListBox named ListBox1.

•	A ComboBox named ComboBox1.

•	A Label named Label1.

•	Two CommandButton controls named CommandButton1 and CommandButton2.

Private Sub CommandButton1_Click()

    If UserForm1.CanUndo = True Then

        UserForm1.UndoAction

        Label7.Caption = "Undid IT"

    Else

        Label7.Caption = "No undo performed."

    End If

End Sub

Private Sub CommandButton2_Click()

    If UserForm1.CanRedo = True Then

        UserForm1.RedoAction

        Label7.Caption = "Redid IT"

    Else

        Label7.Caption = "No redo performed."

    End If

End Sub

Private Sub UserForm_Initialize()

    TextBox1.Text = "Type your text here."

    ComboBox1.ColumnCount = 3

    ComboBox1.AddItem "Choice 1, column 1"

    ComboBox1.List(0, 1) = "Choice 1, column 2"

    ComboBox1.List(0, 2) = "Choice 1, column 3"

End Sub


BoundColumn Property Example

The following example demonstrates how the BoundColumn property influences the value of a ListBox. The user can choose to set the value of the ListBox to the index value of the specified row, or to a specified column of data in the ListBox.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	A ListBox named ListBox1.

•	A Label named Label1.

•	Three OptionButton controls named OptionButton1, OptionButton2, and OptionButton3.

Private Sub UserForm_Initialize()

    OptionButton1.Caption = "List Index"

    OptionButton2.Caption = "Column 1"

    OptionButton3.Caption = "Column 2"

    OptionButton1.Value = False

    OptionButton2.Value = True

    OptionButton3.Value = False

    ListBox1.ColumnCount = 2

    ListBox1.AddItem "Item 1, Column 1"

    ListBox1.List(0, 1) = "Item 1, Column 2"

    ListBox1.AddItem "Item 2, Column 1"

    ListBox1.List(1, 1) = "Item 2, Column 2"

    ListBox1.Value = "Item 1, Column 1"

End Sub

Private Sub OptionButton1_Click()

    ListBox1.BoundColumn = 0

    Label1.Caption = ListBox1.Value

End Sub

Private Sub OptionButton2_Click()

    ListBox1.BoundColumn = 1

    Label1.Caption = ListBox1.Value

End Sub

Private Sub OptionButton3_Click()

    ListBox1.BoundColumn = 2

    Label1.Caption = ListBox1.Value

End Sub

Private Sub ListBox1_Click()

    Label1.Caption = ListBox1.Value

End Sub


List Property Example

The following example swaps columns of a multicolumn ListBox. The sample uses the List property in two ways:

1.	To access and exchange individual values in the ListBox. In this usage, List has subscripts to designate the row and column of a specified value.

2.	To initially load the ListBox with values from an array. In this usage, List has no subscripts.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a ListBox named ListBox1 and a CommandButton named cmdExchange13.

Dim MyArray(6, 3)           'Array containing column values for ListBox.

Private Sub UserForm_Initialize()

    Dim i As Single

    ListBox1.ColumnCount = 3        'This list box contains 3 data columns

    'Load integer values MyArray

    For i = 0 To 5

        MyArray(i, 0) = i

        MyArray(i, 1) = Rnd

        MyArray(i, 2) = Rnd

    Next i

    'Load ListBox1

    ListBox1.List() = MyArray

End Sub

Private Sub cmdExchange13_Click()

‘Exchange contents of columns 1 and 3

    Dim i As Single

    Dim Temp As Single

    For i = 0 To 5

        Temp = ListBox1.List(i, 0)

        ListBox1.List(i, 0) = ListBox1.List(i, 2)

        ListBox1.List(i, 2) = Temp

    Next i

End Sub


TabStrip Control Example

The following example sets the dimensions of an Image to the size of a TabStrip's client area when the user clicks a CommandButton and resets the image to its original size when the user clicks a second CommandButton. This code sample uses the following properties: Height, Left, Top, Width, ClientHeight, ClientLeft, ClientTop, ClientWidth, OldHeight, OldLeft, OldTop, and OldWidth.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	A CommandButton named CommandButton1.

•	A TabStrip named TabStrip1.

•	An Image named Image1.

Private Sub UserForm_Initialize()

CommandButton1.Caption = "Size Image to Tab Area"

CommandButton1.WordWrap = True

End Sub

Private Sub CommandButton1_Click()

Image1.ZOrder (fmFront)                  'Place Image in front of TabStrip

Image1.Left = TabStrip1.ClientLeft

Image1.Top = TabStrip1.ClientTop

Image1.Width = TabStrip1.ClientWidth

Image1.Height = TabStrip1.ClientHeight

End Sub


MultiLine, WordWrap, ScrollBars Properties Example

The following example demonstrates the MultiLine, WordWrap, and ScrollBars properties on a TextBox.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	A TextBox named TextBox1.

•	Three ToggleButton controls named ToggleButton1, ToggleButton2, and ToggleButton3.

To see the entire text placed in the TextBox, click the MultiLine and WordWrap ToggleButton controls.

When MultiLine is True, you can enter new lines of text by pressing SHIFT+ENTER.

ScrollBars appears when you manually change the content of the TextBox.

Private Sub UserForm_Initialize()

‘ Initialize TextBox properties and toggle buttons

TextBox1.AutoSize = False

ToggleButton1.Caption = "AutoSize Off"

ToggleButton1.Value = False

ToggleButton1.AutoSize = True

TextBox1.WordWrap = False

ToggleButton2.Caption = "WordWrap Off"

ToggleButton2.Value = False

ToggleButton2.AutoSize = True

TextBox1.ScrollBars = 0

ToggleButton3.Caption = "ScrollBars Off"

ToggleButton3.Value = False

ToggleButton3.AutoSize = True

TextBox1.MultiLine = False

ToggleButton4.Caption = "Single Line"

ToggleButton4.Value = False

ToggleButton4.AutoSize = True

TextBox1.Text = " A TextBox is the control most commonly used to display information entered by a user. Also, it can display a set of data, such as a table, query, worksheet, or a calculation result. If a TextBox is bound to a data source, then changing the contents of the TextBox also changes the value of the bound data source.”

End Sub

Private Sub ToggleButton1_Click()

‘Set AutoSize property and associated ToggleButton

If ToggleButton1.Value = True Then

TextBox1.AutoSize = True

ToggleButton1.Caption = "AutoSize On"

Else

TextBox1.AutoSize = False

ToggleButton1.Caption = "AutoSize Off"

End If

End Sub

Private Sub ToggleButton2_Click()

‘Set WordWrap property and associated ToggleButton

If ToggleButton2.Value = True Then

TextBox1.WordWrap = True

ToggleButton2.Caption = "WordWrap On"

Else

TextBox1.WordWrap = False

ToggleButton2.Caption = "WordWrap Off"

End If

End Sub

Private Sub ToggleButton3_Click()

‘Set ScrollBars property and associated ToggleButton

If ToggleButton3.Value = True Then

TextBox1.ScrollBars = 3

ToggleButton3.Caption = "ScrollBars On"

Else

TextBox1.ScrollBars = 0

ToggleButton3.Caption = "ScrollBars Off"

End If

End Sub

Private Sub ToggleButton4_Click()

‘Set MultiLine property and associated ToggleButton

If ToggleButton4.Value = True Then

TextBox1.MultiLine = True

ToggleButton4.Caption = "Multiple Lines"

Else

TextBox1.Value = False

ToggleButton4.Caption = "Single Line"

End If

End Sub


Drag-and-Drop Operation Example

The following example demonstrates a drag-and-drop operation from one ListBox to another using a DataObject to contain the dragged text. This code sample uses the SetText and StartDrag methods.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains two ListBox controls named ListBox1 and ListBox2. You also need to add choices to the second ListBox.

Private Sub ListBox2_MouseMove(ByVal Button As Integer, ByVal Shift As

Integer, ByVal X As Single, ByVal Y As Single)

Dim MyDataObject As DataObject

If Button = 1 Then

Set MyDataObject = New DataObject

Dim Effect As Integer

MyDataObject.SetText ListBox2.value

Effect = dataobj.startdrag

End If

End Sub


Accessing a Page Example

The following example accesses an individual page of a MultiPage in three ways: using the Pages collection with a numeric index, using the Pages collection with a string index, and directly using the name of the individual page in the MultiPage.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains the following controls:

•	A MultiPage named MultiPage1.

•	Three CommandButton controls named CommandButton1, CommandButton2, and CommandButton3.

Private Sub CommandButton1_Click()

'Access page two of MultiPage using numerical index

MultiPage1.Pages(1).Caption = "Second Page"

End Sub

Private Sub CommandButton2_Click()

'Access page two of MultiPage using string index

MultiPage1.Pages("Page2").Caption = "Page Two"

End Sub

Private Sub CommandButton3_Click()

'Access page two of MultiPage directly with page name.

MultiPage1.Page2.Caption = "Second Page 2"

End Sub


Adding a Control Example

The following example demonstrates how to add a control to a form at run time. The example uses the Add method.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a CommandButton named CommandButton1 and a Label named Label1.

Dim Mycmd as Control

Private Sub CommandButton1_Click()

Set Mycmd = Controls.Add("Forms.CommandButton.1") ', CommandButton2, Visible)

Mycmd.Left = 18

Mycmd.Top = 150

Mycmd.Width = 175

Mycmd.Height = 20

Mycmd.Caption = "This is fun." & Mycmd.Name

End Sub

Private Sub UserForm_AddControl(ByVal Control As MSForms.Control)

Label1.Caption = "Control was Added."

End Sub


Adding a Control to a MultiPage Example

The following example demonstrates how to add and remove a control to a Page of a MultiPage at run time. The example uses the Add, Clear, and Remove methods.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a MultiPage named MultiPage1 and three CommandButton controls named CommandButton1, CommandButton2, and CommandButton3.

Dim MyTextBox As Control

Private Sub CommandButton1_Click()

Set MyTextBox = MultiPage1.Pages(0).Controls.Add("Forms.TextBox.1", "MyTextBox", Visible)

End Sub

Private Sub CommandButton2_Click()

MultiPage1.Pages(0).Controls.Clear

End Sub

Private Sub CommandButton3_Click()

MultiPage1.Pages(0).Controls.Remove "MyTextBox"

End Sub


ListBox Control Example

The following example adds and deletes the contents of a ListBox using the AddItem, RemoveItem, and SetFocus methods, and the ListIndex property.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a ListBox named ListBox1 and two CommandButton controls labeled CommandButton1 and CommandButton2.

Dim EntryCount As Single

Private Sub CommandButton1_Click()

EntryCount = EntryCount + 1

ListBox1.AddItem (EntryCount & " - Selection")

End Sub

Private Sub CommandButton2_Click()

EntryCount = EntryCount + 1

ListBox1.SetFocus

ListBox1.RemoveItem (ListBox1.ListIndex)

End Sub

Private Sub UserForm_Initialize()

   EntryCount = 0

End Sub


ZOrder Method Example

The following example sets the z-order of a TextBox, so the user can display the entire TextBox (by bringing it to the front of the z-order) or can place the TextBox behind other controls (by sending it to the back of the z-order).

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	Three TextBox controls named TextBox1, TextBox2, and TextBox3.

•	A ToggleButton named ToggleButton1.

Private Sub ToggleButton1_Click()

If ToggleButton1.Value = True Then

TextBox2.ZOrder (fmTop)          'Place TextBox2 on Top of z-order

'Update ToggleButton caption to identify next state

ToggleButton1.Caption = "Send TextBox2 to back"

Else

TextBox2.ZOrder (1)              'Place TextBox2 on Bottom of z-order

'Update ToggleButton caption to identify next state

ToggleButton1.Caption = "Bring TextBox2 to front"

End If

End Sub

Private Sub UserForm_Initialize()

'Set up text boxes to show z-order in the form

TextBox1.Text = "TextBox 1"

TextBox2.Text = "TextBox 2"

TextBox3.Text = "TextBox 3"

TextBox1.Height = 40

TextBox2.Height = 40

TextBox3.Height = 40

TextBox1.Width = 60

TextBox2.Width = 60

TextBox3.Width = 60

TextBox1.Left = 10

TextBox1.Top = 10

TextBox2.Left = 25      'Overlap TextBox2 on TextBox1

TextBox2.Top = 25

TextBox3.Left = 40      'Overlap TextBox3 on TextBox2, TextBox1

TextBox3.Top = 40

ToggleButton1.Value = False

ToggleButton1.Caption = "Bring TextBox2 to Front"

ToggleButton1.Left = 10

ToggleButton1.Top = 90

ToggleButton1.Width = 50

ToggleButton1.Height = 50

End Sub


Accelerator, Caption Properties Example

This example changes the Accelerator and Caption properties of a CommandButton each time the user clicks the button by using the mouse or the accelerator key.

To try this example, paste the code into the Declarations section of a form containing a CommandButton named CommandButton1.

Private Sub UserForm_Initialize()

CommandButton1.Accelerator  = "C"         ' Set Accelerator key to ALT + C

End Sub

Private Sub CommandButton1_Click ()

If CommandButton1.Caption = "OK" Then     ' Check caption, then change it.

CommandButton1.Caption = "Clicked"

CommandButton1.Accelerator  = "C"         ' Set Accelerator key to ALT + C

Else

CommandButton1.Caption = "OK"

CommandButton1.Accelerator  = "O"         ' Set Accelerator key to ALT + O

End If

End Sub


AutoSize Property Example

The following example demonstrates the effects of the AutoSize property with a single line TextBox and a multiline TextBox. The user can enter text into either TextBox and turn AutoSize on or off independently of the contents of the TextBox. This code sample also uses the Text property.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	Two TextBox controls named TextBox1 and TextBox2.

•	A ToggleButton named ToggleButton1.

Private Sub UserForm_Initialize()

    TextBox1.Text = "Single-line TextBox. Type your text here."

    TextBox2.MultiLine = True

    TextBox2.Text = "Multi-line TextBox. Type your text here. Use CTRL+ENTER to start a new line."

    ToggleButton1.Value = True

    ToggleButton1.Caption = "AutoSize On"

    TextBox1.AutoSize = True

    TextBox2.AutoSize = True

End Sub

Private Sub ToggleButton1_Click()

    If ToggleButton1.Value = True Then

        ToggleButton1.Caption = "AutoSize On"

        TextBox1.AutoSize = True

        TextBox2.AutoSize = True

    Else

        ToggleButton1.Caption = "AutoSize Off"

        TextBox1.AutoSize = False

        TextBox2.AutoSize = False

    End If

End Sub


Bold, Italic, Size, StrikeThrough, Underline, Weight Properties Example

The following example demonstrates a Font object and the Bold, Italic, Size, StrikeThrough, Underline, and Weight properties related to fonts. You can manipulate font properties of an object directly or by using an alias, as this example also shows.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	Two Label objects named Label1 and Label2.

•	Four ToggleButton controls named ToggleButton1 through ToggleButton4.

•	Another Label and a TextBox named Label3 and TextBox1.

Dim MyFont As StdFont

Private Sub ToggleButton1_Click()

If ToggleButton1.Value = True Then

MyFont.Bold = True            'Using MyFont alias to control font

ToggleButton1.Caption = "Bold On"

MyFont.Size = 22              'Increase the font size

Else

MyFont.Bold = False

ToggleButton1.Caption = "Bold Off"

MyFont.Size = 8               'Return font size to initial size

End If

TextBox1.Text = Str(MyFont.Weight)  'Bold and Weight are related

End Sub

Private Sub ToggleButton2_Click()

If ToggleButton2.Value = True Then

Label2.Font.Italic = True            'Using Label2.Font directly

ToggleButton2.Caption = "Italic On"

Else

Label2.Font.Italic = False

ToggleButton2.Caption = "Italic Off"

End If

End Sub

Private Sub ToggleButton3_Click()

If ToggleButton3.Value = True Then

Label2.Font.Strikethrough = True            'Using Label2.Font directly

ToggleButton3.Caption = "StrikeThrough On"

Else

Label2.Font.Strikethrough = False

ToggleButton3.Caption = "StrikeThrough Off"

End If

End Sub

Private Sub ToggleButton4_Click()

If ToggleButton4.Value = True Then

MyFont.Underline = True            'Using MyFont alias for Label2.Font

ToggleButton4.Caption = "Underline On"

Else

Label2.Font.Underline = False

ToggleButton4.Caption = "Underline Off"

End If

End Sub

Private Sub UserForm_Initialize()

Set MyFont = Label2.Font

ToggleButton1.Value = False

ToggleButton1.Caption = "Bold Off"

ToggleButton2.Value = False

ToggleButton2.Caption = "Italic Off"

ToggleButton3.Value = False

ToggleButton3.Caption = "StrikeThrough Off"

ToggleButton4.Value = False

ToggleButton4.Caption = "Underline Off"

Label3.Caption = "Font Weight"

TextBox1.Text = Str(Label2.Font.Weight)

TextBox1.Enabled = False

End Sub


Border, Color Enhancements Example

The following example demonstrates the BorderStyle and SpecialEffect properties, showing each border available through these properties. The example also demonstrates how to control color settings by using the BackColor, BackStyle, BorderColor, and ForeColor properties.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	Six TextBox controls named TextBox1 through TextBox6.

•	Two ToggleButton controls named ToggleButton1 and ToggleButton2.

Private Sub UserForm_Initialize()

' Initialize each TextBox with a border style or special effect,

' and foreground and background colors

' TextBox1 initially uses a borderstyle

TextBox1.Text = "BorderStyle-Single"

TextBox1.BorderStyle = fmBorderStyleSingle

TextBox1.BorderColor = RGB(255, 128, 128)   'Color - Salmon

TextBox1.ForeColor = RGB(255, 255, 0)       'Color - Yellow

TextBox1.BackColor = RGB(0, 128, 64)        'Color - Green #2

' TextBoxes 2 through 6 initially use special effects

TextBox2.Text = "Flat"

TextBox2.SpecialEffect = fmSpecialEffectFlat

TextBox2.ForeColor = RGB(64, 0, 0)          'Color - Brown

TextBox2.BackColor = RGB(0, 0, 255)         'Color - Blue

' Ensure the background style for TextBox2 is initially opaque.

TextBox2.BackStyle = fmBackStyleOpaque

TextBox3.Text = "Etched"

TextBox3.SpecialEffect = fmSpecialEffectEtched

TextBox3.ForeColor = RGB(128, 0, 255)       'Color - Purple

TextBox3.BackColor = RGB(0, 255, 255)       'Color - Cyan

'Define BorderColor for later use (when borderstyle=fmBorderStyleSingle)

TextBox3.BorderColor = RGB(0, 0, 0)         'Color - Black

TextBox4.Text = "Bump"

TextBox4.SpecialEffect = fmSpecialEffectBump

TextBox4.ForeColor = RGB(255, 0, 255)       'Color - Magenta

TextBox4.BackColor = RGB(0, 0, 100)         'Color - Navy blue

TextBox5.Text = "Raised"

TextBox5.SpecialEffect = fmSpecialEffectRaised

TextBox5.ForeColor = RGB(255, 0, 0)         'Color - Red

TextBox5.BackColor = RGB(128, 128, 128)     'Color - Gray

TextBox6.Text = "Sunken"

TextBox6.SpecialEffect = fmSpecialEffectSunken

TextBox6.ForeColor = RGB(0, 64, 0)          'Color - Olive

TextBox6.BackColor = RGB(0, 255, 0)         'Color - Green #1

ToggleButton1.Caption = "Swap styles"

ToggleButton2.Caption = "Transparent/Opaque background"

End Sub

Private Sub ToggleButton1_Click()

‘Swap borders between TextBox1 and TextBox3

If ToggleButton1.Value = True Then

'Change TextBox1 from BorderStyle to Etched

TextBox1.Text = "Etched"

TextBox1.SpecialEffect = fmSpecialEffectEtched

'Change TextBox3 from Etched to BorderStyle

TextBox3.Text = "BorderStyle-Single"

TextBox3.BorderStyle = fmBorderStyleSingle

Else

'Change TextBox1 back to BorderStyle

TextBox1.Text = "BorderStyle-Single"

TextBox1.BorderStyle = fmBorderStyleSingle

'Change TextBox3 back to Etched

TextBox3.Text = "Etched"

TextBox3.SpecialEffect = fmSpecialEffectEtched

End If

End Sub

Private Sub ToggleButton2_Click()

‘Set background to Opaque or Transparent

If ToggleButton2.Value = True Then

'Change TextBox2 to a transparent background

TextBox2.BackStyle = fmBackStyleTransparent

Else

'Change TextBox2 back to opaque background

TextBox2.BackStyle = fmBackStyleOpaque

End If

End Sub


Column Property Example

'

The following example loads a two-dimensional array with data and, in turn, loads two ListBox controls using the Column and List properties. Note that the Column property transposes the array elements during loading.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains two ListBox controls named ListBox1 and ListBox2.

Dim MyArray(3,6)

Private Sub UserForm_Initialize()

Dim i As Single

ListBox1.ColumnCount = 3        'The 1st list box contains 3 data columns

ListBox2.ColumnCount = 6        'The 2nd box contains 6 data columns

'Load integer values into first column of ListBox1 and MyArray

For i = 0 To 5

MyArray(i, 0) = i

Next i

'Load columns 2 and three of MyArray

MyArray(0, 1) = "Zero"

MyArray(1, 1) = "One"

MyArray(2, 1) = "Two"

MyArray(3, 1) = "Three"

MyArray(4, 1) = "Four"

MyArray(5, 1) = "Five"

MyArray(0, 2) = "Zero"

MyArray(1, 2) = "Un ou Une"

MyArray(2, 2) = "Deux"

MyArray(3, 2) = "Trois"

MyArray(4, 2) = "Quatre"

MyArray(5, 2) = "Cinq"

'Load data into ListBox1 and ListBox2

ListBox1.List() = MyArray

ListBox2.Column() = MyArray

End Sub


ColumnWidths Property Example

The following example uses the ColumnWidths property to change the column widths of a multicolumn ListBox. The example also uses three TextBox controls to specify the individual column widths.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	A ListBox named ListBox1.

•	Three TextBox controls named TextBox1, TextBox2, and TextBox3.

•	A CommandButton named CommandButton1.

Try entering the value 0 to hide a column.

Dim MyArray(2, 3) As String

Private Sub CommandButton1_Click()

' ColumnWidths requires a value for each column separated by semicolons

ListBox1.ColumnWidths = TextBox1.Text & ";" & TextBox2.Text & ";" & TextBox3.Text

End Sub

Private Sub TextBox1_Exit(Cancel As Boolean)

'ColumnWidths accepts points (no units), inches or centimeters; make inches the default

If Not (InStr(TextBox1.Text, "in") > 0 Or InStr(TextBox1.Text, "cm") > 0) Then

TextBox1.Text = TextBox1.Text & " in"

End If

End Sub

Private Sub TextBox2_Exit(Cancel As Boolean)

'ColumnWidths accepts points (no units), inches or centimeters; make inches the default

If Not (InStr(TextBox2.Text, "in") > 0 Or InStr(TextBox2.Text, "cm") > 0) Then

TextBox2.Text = TextBox2.Text & " in"

End If

End Sub

Private Sub TextBox3_Exit(Cancel As Boolean)

'ColumnWidths accepts points (no units), inches or centimeters; make inches the default

If Not (InStr(TextBox3.Text, "in") > 0 Or InStr(TextBox3.Text, "cm") > 0) Then

TextBox3.Text = TextBox3.Text & " in"

End If

End Sub

Private Sub UserForm_Initialize()

Dim i, j, Rows As Single

ListBox1.ColumnCount = 3

Rows = 2

For j = 0 To ListBox1.ColumnCount - 1

For i = 0 To Rows - 1

MyArray(i, j) = "Row " & i & ", Column " & j

Next i

Next j

ListBox1.List() = MyArray           ' Load MyArray into ListBox1

TextBox1.Text = "1 in"              ' 1-inch columns initially

TextBox2.Text = "1 in"

TextBox3.Text = "1 in"

End Sub


ControlTipText Property Example

The following example defines the ControlTipText property for three CommandButton controls and two Page objects in a MultiPage.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a MultiPage named MultiPage1 and three CommandButton controls named CommandButton1, CommandButton2, and CommandButton3.

Note  For an individual Page of a MultiPage, ControlTipText becomes enabled when the MultiPage or a control on the current page of the MultiPage has the focus.

Private Sub UserForm_Initialize()

MultiPage1.Page1.ControlTipText = "Here in page 1"

MultiPage1.Page2.ControlTipText = "Now in page 2"

CommandButton1.ControlTipText = "And now here's"

CommandButton2.ControlTipText = "a tip from"

CommandButton3.ControlTipText = "your controls!"

End Sub


CurLine, CurTargetX, and CurX Properties Example

The following example tracks the CurLine, CurTargetX, and CurX property settings in a multiline TextBox. These settings change as the user moves the insertion point and extends the selection using the keyboard.

To use this example, follow these steps:

1.	Copy this sample code to the Declarations portion of a form.

2.	Add one large TextBox named TextBox1 to the form.

3.	Add three TextBox controls named TextBox2, TextBox3, and TextBox4 in a column.

Private Sub TextBox1_KeyUp(KeyCode As Integer, ByVal Shift As Integer)

TextBox2.Text = TextBox1.CurLine

TextBox3.Text = TextBox1.CurX

TextBox4.Text = TextBox1.CurTargetX

End Sub

Private Sub UserForm_Initialize()

TextBox1.MultiLine = True

TextBox1.Text = "Type your text here. User CTRL + ENTER to start a new line.”

End Sub


HideSelection Property Example

'

The following example demonstrates the HideSelection property in the context of either a single form or more than one form. The user can select text in a TextBox and TAB to other controls on a form, as well as transfer the focus to a second form. This code sample also uses the SetFocus method, and the EnterFieldBehavior, MultiLine, and Value properties.

To use this example, follow these steps:

1.	Copy this sample code (except for the last event subroutine) to the Declarations portion of a form.

2.	Add a large TextBox named TextBox1, a ToggleButton named ToggleButton1, and a CommandButton named CommandButton1.

3.	Insert a second form into this project named UserForm2.

4.	Paste the last event subroutine of this listing into the Declarations section of UserForm2.

5.	In this form, add a CommandButton named CommandButton1.

6.	Run UserForm1.

' ***** Code for UserForm1 *****

Private Sub CommandButton1_Click()

TextBox1.SetFocus

UserForm2.Show                             'Bring up the second form.

End Sub

Private Sub ToggleButton1_Click()

If ToggleButton1.Value = True Then

TextBox1.HideSelection = False

ToggleButton1.Caption = "Selection Visible"

Else

TextBox1.HideSelection = True

ToggleButton1.Caption = "Selection Hidden"

End If

End Sub

Private Sub UserForm_Initialize()

TextBox1.MultiLine = True

TextBox1.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection

‘Fill the TextBox

TextBox1.Text = "SelText indicates the starting point of selected text, or the insertion point if no text is selected." _

& Chr$(10) & Chr$(13) & "The SelStart property is always valid, even when the control does not have focus. Setting SelStart to a value less than zero creates an error. " _

& Chr$(10) & Chr$(13) & "Changing the value of SelStart cancels any existing selection in the control, places an insertion point in the text, and sets the SelLength property to zero."

TextBox1.HideSelection = True

ToggleButton1.Caption = "Selection Hidden"

ToggleButton1.Value = False

End Sub

'

' ***** Code for UserForm2 *****

Private Sub CommandButton1_Click()

UserForm2.Hide

End Sub


Picture, PicturePosition Properties Example

The following example uses a ComboBox to show the picture placement options for a control. Each time the user clicks a list choice, the picture and caption are updated on the Command Button. This code sample also uses the AddItem method to populate the ListBox choices.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a Label named Label1, a CommandButton named CommandButton1, and a ComboBox named ComboBox1.

Private Sub UserForm_Initialize()

Label1.Left = 18

Label1.Top = 18

Label1.Height = 12

Label1.Width = 190

Label1.Caption = "Select picture placement relative to the caption."

'Add list entries to combo box. The value of each entry matches the

'corresponding ListIndex value in the combo box.

ComboBox1.AddItem "Left Top"        'ListIndex = 0

ComboBox1.AddItem "Left Center"     'ListIndex = 1

ComboBox1.AddItem "Left Bottom"     'ListIndex = 2

ComboBox1.AddItem "Right Top"       'ListIndex = 3

ComboBox1.AddItem "Right Center"    'ListIndex = 4

ComboBox1.AddItem "Right Bottom"    'ListIndex = 5

ComboBox1.AddItem "Above Left"      'ListIndex = 6

ComboBox1.AddItem "Above Center"    'ListIndex = 7

ComboBox1.AddItem "Above Right"    'ListIndex = 8

ComboBox1.AddItem "Below Left"      'ListIndex = 9

ComboBox1.AddItem "Below Center"    'ListIndex = 10

ComboBox1.AddItem "Below Right"    'ListIndex = 11

ComboBox1.AddItem "Centered"        'ListIndex = 12

ComboBox1.Style = fmStyleDropDownList  'Use drop-down list

ComboBox1.BoundColumn = 0            'Combo box values are ListIndex values

ComboBox1.ListIndex = 0              'Set combo box to first entry

'Initialize CommandButton1

CommandButton1.Left = 276

CommandButton1.Top = 36

CommandButton1.Height = 120

CommandButton1.Width = 120

'Note: Be sure to refer to a bitmap file that is present on your

'Note: system, and to include the path in the filename.

CommandButton1.Picture = LoadPicture("c:\windows\argyle.bmp")

CommandButton1.PicturePosition = ComboBox1.Value

End Sub

Private Sub ComboBox1_Click()

Select Case ComboBox1.Value

Case 0  'Left Top

CommandButton1.Caption = "Left Top"

CommandButton1.PicturePosition = fmPicturePositionLeftTop

Case 1  'Left Center

CommandButton1.Caption = "Left Center"

CommandButton1.PicturePosition = fmPicturePositionLeftCenter

Case 2  'Left Bottom

CommandButton1.Caption = "Left Bottom"

CommandButton1.PicturePosition = fmPicturePositionLeftBottom

Case 3  'Right Top

CommandButton1.Caption = "Right Top"

CommandButton1.PicturePosition = fmPicturePositionRightTop

Case 4  'Right Center

CommandButton1.Caption = "Right Center"

CommandButton1.PicturePosition = fmPicturePositionRightCenter

Case 5  'Right Bottom

CommandButton1.Caption = "Right Bottom"

CommandButton1.PicturePosition = fmPicturePositionRightBottom

Case 6  'Above Left

CommandButton1.Caption = "Above Left"

CommandButton1.PicturePosition = fmPicturePositionAboveLeft

Case 7  'Above Center

CommandButton1.Caption = "Above Center"

CommandButton1.PicturePosition = fmPicturePositionAboveCenter

Case 8  'Above Right

CommandButton1.Caption = "Above Right"

CommandButton1.PicturePosition = fmPicturePositionAboveRight

Case 9  'Below Left

CommandButton1.Caption = "Below Left"

CommandButton1.PicturePosition = fmPicturePositionBelowLeft

Case 10 'Below Center

CommandButton1.Caption = "Below Center"

CommandButton1.PicturePosition = fmPicturePositionBelowCenter

Case 11 'Below Right

CommandButton1.Caption = "Below Right"

CommandButton1.PicturePosition = fmPicturePositionBelowRight

Case 12 'Centered

CommandButton1.Caption = "Centered"

CommandButton1.PicturePosition = fmPicturePositionCenter

End Select

End Sub


Control/Worksheet Binding Example

The following example uses a range of worksheet cells in a ListBox and, when the user selects a row from the list, displays the row index in another worksheet cell. This code sample also uses the BoundColumn and ControlSource properties.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a ListBox named ListBox1.You also need to enter data in cells A1:E4 of a worksheet.

Private Sub UserForm_Initialize()

ListBox1.ColumnCount = 5

ListBox1.RowSource = "a1:e4"

ListBox1.ControlSource = "a6"

ListBox1.BoundColumn = 0          'Place the ListIndex into cell a6

End Sub


Text Selection Properties Example

The following example tracks the selection-related properties (SelLength, SelStart, and SelText) that change as the user moves the insertion point and extends the selection using the keyboard. This example also uses the Enabled and EnterFieldBehavior properties.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	One large TextBox named TextBox1.

•	Three TextBox controls named TextBox2, TextBox3, and TextBox4 in a column.

•	A CommandButton named CommandButton1.

Private Sub TextBox1_KeyUp(KeyCode As Integer, ByVal Shift As Integer)

TextBox2.Text = TextBox1.SelStart

TextBox3.Text = TextBox1.SelLength

TextBox4.Text = TextBox1.SelText

End Sub

Private Sub UserForm_Initialize()

TextBox1.MultiLine = True

TextBox1.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection

TextBox1.Text = "Type your text here. Use CTRL+ENTER to start a new line."

End Sub


Controls Collection Example

The following example accesses individual controls from the Controls collection using a For Each...Next loop. When the user presses CommandButton1, the other controls are placed in a column along the left edge of the form.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a CommandButton named CommandButton1 and several other controls.

Dim CtrlHeight As Single

Dim CtrlTop As Single

Dim CtrlGap As Single

Private Sub CommandButton1_Click()

Dim MyControl As Control

For Each MyControl In Controls

If MyControl.Name = "CommandButton1" Then

'Don't move or resize this control.

Else

'Move method using named arguments

MyControl.Move Top:=CtrlTop, Height:=CtrlHeight, Left:=5

'Move method using unnamed arguments (left, top, width, height)

'MyControl.Move 5, CtrlTop, ,CtrlHeight

'Calculate top coordinate for next control

CtrlTop = CtrlTop + CtrlHeight + CtrlGap

End If

Next

End Sub

Private Sub UserForm_Initialize()

CtrlHeight = 20

CtrlGap = 5

CtrlTop = 5

Label1.Caption = "Hello"

Label1.Font.Size = 22

Label1.Font.Bold = True

CommandButton1.Caption = "Click to move controls"

CommandButton1.WordWrap = True

CommandButton1.Left = 120

CommandButton1.Top = CtrlTop

End Sub


Cycle Property Example

The following example defines the Cycle property for a Frame and two Page objects in a MultiPage.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a Frame named Frame1 and a MultiPage named MultiPage1 that contains two Page objects named Page1 and Page2.

In the form, the Frame, and each Page of the MultiPage, place a couple of controls, so you can see how Cycle affects the tab order of the Frame and MultiPage.

Private Sub RestrictCycles()

'Limit tab order for the Frame and Page objects

    Frame1.Cycle = fmCycleCurrentForm

    MultiPage1.Page1.Cycle = fmCycleCurrentForm

    MultiPage1.Page2.Cycle = fmCycleCurrentForm

End Sub

Private Sub UserForm_Initialize()

RestrictCycles()

End Sub

Private Sub CommandButton1_Click()

'Extend tab order subforms (the Frame and Page objects)

    Frame1.Cycle = fmCycleAllForms

    MultiPage1.Page1.Cycle = fmCycleAllForms

    MultiPage1.Page2.Cycle = fmCycleAllForms

End Sub

Private Sub CommandButton2_Click()

RestrictCycles()

End Sub


Controls Collection Move Example

The following example demonstrates moving all the controls on a form by using the Move method with the Controls collection.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a CommandButton named CommandButton1 and several other controls.

Private Sub CommandButton1_Click()

‘Move each control on the form right 25 points and up 25 points.

UserForm1.Controls.Move 25, -25

End Sub


Parent Property Example

The following example demonstrates how to use the Parent property to refer to the control or form that contains a specific control.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

•	Two Label controls named Label1 and Label2.

•	A CommandButton named CommandButton1.

•	One or more additional controls of your choice.

Dim MyControl As Object

Dim MyParent As Object

Dim ControlsIndex As Integer

Private Sub UserForm_Initialize()

    ControlsIndex = 0

    CommandButton1.Caption = "Get Control and Parent"

    CommandButton1.AutoSize = True

    CommandButton1.WordWrap = True

End Sub

Private Sub CommandButton1_Click()

    'Process Controls collection for UserForm

    Set MyControl = Controls.Item(ControlsIndex)

    Set MyParent = MyControl.Parent

    Label1.Caption = MyControl.Name

    Label2.Caption = MyParent.Name

    'Prepare index for next control on Userform

    ControlsIndex = ControlsIndex + 1

    If ControlsIndex >= Controls.Count Then

        ControlsIndex = 0

    End If

End Sub