CheckBox Control

A CheckBox control displays an X when selected; the X disappears when the CheckBox is cleared. Use this control to give the user a True/False or Yes/No option. You can use CheckBox controls in groups to display multiple choices from which the user can select one or more. You can also set the value of a CheckBox programmatically with the Value property.

Syntax

CheckBox

Remarks

CheckBox and OptionButton controls function similarly but with an important difference: Any number of CheckBox controls on a form can be selected at the same time. In contrast, only one OptionButton in a group can be selected at any given time.

To display text next to the CheckBox, set the Caption property. Use the Value property to determine the state of the control—selected, cleared, or unavailable.


ComboBox Control

A ComboBox control combines the features of a TextBox control and a ListBox control—users can enter information in the text box portion or select an item from the list box portion of the control.

Syntax

ComboBox

Remarks

To add or delete items in a ComboBox control, use the AddItem or RemoveItem method. Set the List, ListCount, and ListIndex properties to enable a user to access items in the ComboBox. Alternatively, you can add items to the list by using the List property at design time.

Note A Scroll event will occur in a ComboBox control only when the contents of the dropdown portion of the ComboBox are scrolled, not each time the contents of the ComboBox change. For example, if the dropdown portion of a ComboBox contains five items and the top item is highlighted, a Scroll event will not occur until you press the down arrow six times (or the pgdn key once). After that, a Scroll event occurs for each press of the down arrow key. However, if you then press the up arrow key, a Scroll event will not occur until you press the up arrow key six times (or the pgup key once). After that, each up arrow key press will result in a Scroll event.


CommandButton Control

Use a CommandButton control to begin, interrupt, or end a process. When chosen, a CommandButton appears pushed in and so is sometimes called a push button.

Syntax

CommandButton

Remarks

To display text on a CommandButton control, set its Caption property. A user can always choose a CommandButton by clicking it. To allow the user to choose it by pressing ENTER, set the Default property to True. To allow the user to choose the button by pressing ESC, set the Cancel property of the CommandButton to True.


Data Control

Provides access to data stored in databases using any one of three types of Recordset objects. The Data control enables you to move from record to record and to display and manipulate data from the records in bound controls. Without a Data control or an equivalent data source control like the RemoteData control, data-aware (bound) controls on a form can't automatically access data.

Syntax

Data

Remarks

You can perform most data access operations using the Data control without writing any code at all. Data-aware controls bound to a Data control automatically display data from one or more fields for the current record or, in some cases, for a set of records on either side of the current record. The Data control performs all operations on the current record.

If the Data control is instructed to move to a different record, all bound controls automatically pass any changes to the Data control to be saved in the database. The Data control then moves to the requested record and passes back data from the current record to the bound controls where it's displayed.

The Data control automatically handles a number of contingencies including empty recordsets, adding new records, editing and updating existing records, and handling some types of errors. However, in more sophisticated applications, you need to trap some error conditions that the Data control can't handle. For example, if the Microsoft Jet database engine has a problem accessing the database file, doesn't have permission, or can't execute the query as coded, a trappable error results. If the error occurs before your application procedures start or due to some internal errors, the Error event is triggered.

Bound Controls

The DataList, DataCombo, DataGrid, and MSHFlexGrid controls are all capable of managing sets of records when bound to a Data control. All of these controls permit several records to be displayed or manipulated at once.

The intrinsic Picture, Label, TextBox, CheckBox, Image, OLE, ListBox and ComboBox controls are also data-aware and can be bound to a single field of a Recordset managed by the Data control. Additional data-aware controls like the MaskedEdit and RichTextBox controls are available in the Professional and Enterprise Editions and from third-party vendors.

Operation

Once the application begins, Visual Basic uses Data control properties to open the selected database, create a Database object and create a Recordset object. The Data control's Database and Recordset properties refer to the newly created Database and Recordset objects which may be manipulated independently of the Data control — with or without bound controls. The Data control is initialized before the initial Form_Load event for the form on which it is placed. If any errors occur during this initialization step a non-trappable error results.

When Visual Basic uses the Jet database engine to create a Recordset, no other Visual Basic operations or events can occur until the operation is complete. However, other Windows-based applications are permitted to continue executing while the Recordset is being created. If the user presses CTRL+BREAK while the Jet engine is building a Recordset, the operation is terminated, a trappable error results, and the Recordset property of the Data control is set to Nothing. In design time, a second CTRL+BREAK causes Visual Basic to display the Debug window.

When you use a Data control to create a Recordset object or when you create a Recordset object in code and assign it to the Data control, the Microsoft Jet database engine automatically populates the Recordset object. As a result, bookmarks (and for snapshot-type Recordset objects, recordset data) are saved in local memory; the user doesn't need to manipulate the Data control, and you don't need to invoke the MoveLast method in code. Page locks used to create the Recordset are released more quickly, making it possible for other Recordset objects to access the same data. Recordset objects created in code but not assigned to the Data control aren't automatically populated by the Jet engine. Populate these objects through code. Because of the way that the Data control populates its Recordset in the background, an additional cloned Recordset might be created.

You can manipulate the Data control with the mouse, moving from record to record or to the beginning or end of the Recordset. The EOFAction and BOFAction properties determine what happens when the user moves to the beginning or end of a Recordset with the mouse. You can't set focus to the Data control.

Validation

Use the Validate event and the DataChanged property to perform last minute checks on the records being written to the database.

Data Access Objects

You can use the Database and Recordset data access objects created by the Data control in your procedures. The Database and Recordset objects each have properties and methods of their own, and you can write procedures that use these properties and methods to manipulate your data.

For example, the MoveNext method of a Recordset object moves the current record to the next record in the Recordset. To invoke this method, you could use this code:

Data1.Recordset.MoveNext

The Data control is capable of accessing any of the three types of Jet engine Version 3.0 Recordset objects. If you don't select a recordset type, a dynaset-type Recordset is created.

In many cases, the default type and configuration of the Recordset object created is extremely inefficient. That is, you might not need an updatable, fully-scrollable, keyset-type cursor to access your data. For example, a read-only, forward-only, snapshot-type Recordset might be far faster to create than the default cursor. Be sure to choose the most efficient Type, Exclusive, Options and ReadOnly properties possible for your situation.

Note The constants used to request a specific Recordset type when using the Data control are different than the constants used to determine the type of Recordset created or to create a Recordset using the OpenRecordset method.

To select a specific type of Recordset, set the Data control's RecordsetType property to:

Recordset Type | Value | Constant
Table | 0 | vbRSTypeTable
Dynaset | 1 | (Default) vbRSTypeDynaset
Snapshot | 2 | vbRSTypeSnapshot

Important The Data control cannot be used to access Recordset objects created with the dbForwardOnly option bit set.

Professional and Enterprise Editions

As far as data access is concerned, the primary difference between the Learning Edition, Professional and Enterprise Editions of Visual Basic is the ability to create new data access objects. In the Learning Edition, you can't declare (with the Dim keyword) variables as data access objects in code. This means that only the Data control can create Database and Recordset objects.

In the Professional and Enterprise Editions, you can create a new Recordset object and assign it to the Data control's Recordset property. Any bound controls connected to the Data control permit manipulation of the records in the Recordset you created. Make sure that your bound controls' DataField properties are set to field names that are valid in the new Recordset.

Stored Queries

Another important option when using the Data control is the ability to execute stored queries. If you create a QueryDef object beforehand, the Data control can execute it and create a Recordset using the QueryDef object's stored SQL, Connect and other properties. To execute a QueryDef, set the Data control's RecordSource property to the QueryDef name and use the Refresh method.

If the stored QueryDef contains parameters, you need to create the Recordset and pass it to the Data control.

BOF/EOF Handling

The Data control can also manage what happens when you encounter a Recordset with no records. By changing the EOFAction property, you can program the Data control to enter AddNew mode automatically.

You can program the Data control to automatically snap to the top or bottom of its parent form by using the Align property. In either case, the Data control is resized horizontally to fill the width of its parent form whenever the parent form is resized. This property allows a Data control to be placed on an MDI form without requiring an enclosing Picture control.


DirListBox Control

A DirListBox control displays directories and paths at run time. Use this control to display a hierarchical list of directories. You can create dialog boxes that, for example, enable a user to open a file from a list of files in all available directories.

Syntax

DirListBox

Remarks

Set the List, ListCount, and ListIndex properties to enable a user to access items in a list. If you also display the DriveListBox and FileListBox controls, you can write code to synchronize them with the DirListBox control and with each other.


DriveListBox Control

A DriveListBox control enables a user to select a valid disk drive at run time. Use this control to display a list of all the valid drives in a user's system. You can create dialog boxes that enable the user to open a file from a list of files on a disk in any available drive.

Syntax

DriveListBox

Remarks

Set the List, ListCount, and ListIndex properties to enable a user to access items in the list. If you also display the DirListBox and FileListBox controls, you can write code to synchronize them with the DriveListBox control and with each other.


FileListBox Control

A FileListBox control locates and lists files in the directory specified by the Path property at run time. Use this control to display a list of files selected by file type. You can create dialog boxes in your application that, for example, enable the user to select a file or group of files.

Syntax

FileListBox

Remarks

Set the List, ListCount, and ListIndex properties to enable a user to access items in the list. If you also display the DirListBox and DriveListBox controls, you can write code to synchronize them with the FileListBox control and with each other.


Frame Control

A Frame control provides an identifiable grouping for controls. You can also use a Frame to subdivide a form functionally—for example, to separate groups of OptionButton controls.

Syntax

Frame

Remarks

To group controls, first draw the Frame control, and then draw the controls inside the Frame. This enables you to move the Frame and the controls it contains together. If you draw a control outside the Frame and then try to move it inside, the control will be on top of the Frame and you'll have to move the Frame and controls separately.

To select multiple controls in a Frame, hold down the CTRL key while using the mouse to draw a box around the controls.


HScrollBar, VScrollBar Controls

Scroll bars provide easy navigation through a long list of items or a large amount of information. They can also provide an analog representation of current position. You can use a scroll bar as an input device or indicator of speed or quantity—for example, to control the volume of a computer game or to view the time elapsed in a timed process.

Syntax

HScrollBar

VScrollBar

Remarks

When you're using a scroll bar as an indicator of quantity or speed or as an input device, use the Max and Min properties to set the appropriate range for the control.

To specify the amount of change to report in a scroll bar, use the LargeChange property for clicking in the scroll bar, and the SmallChange property for clicking the arrows at the ends of the scroll bar. The scroll bar's Value property increases or decreases by the values set for the LargeChange and SmallChange properties. You can position the scroll box at run time by setting Value between 0 and 32,767, inclusive.


Image Control

Use the Image control to display a graphic. An Image control can display a graphic from a bitmap, icon, or metafile, as well as enhanced metafile, JPEG, or GIF files.

Syntax

Image

Remarks

The Image control uses fewer system resources and repaints faster than a PictureBox control, but it supports only a subset of the PictureBox properties, events, and methods. Use the Stretch property to determine whether the graphic is scaled to fit the control or vice versa. Although you can place an Image control within a container, an Image control can't act as a container.

Note The Unisys Corporation has a patent that it alleges covers certain aspects of GIF-LZW compression technology, which the PictureBox and Image controls use. Microsoft Corporation obtained a license to the Unisys LZW patents in September, 1996. Microsoft's license does not, however, extend to software developers or third parties who use any Microsoft toolkit, language development, or operating system products to provide GIF read/write and/or any other LZW capabilities in their own products (for example, by way of DLLs and APIs).

If your commercial application uses one of these controls (and thus, the LZW technology), you may wish to obtain an independent legal opinion on the effect of the patent, or contact Unisys USA at http://www.unisys.com/ for more information.


Label Control

A Label control is a graphical control you can use to display text that a user can't change directly.

Syntax

Label

Remarks

You can write code that changes the text displayed by a Label control in response to events at run time. For example, if your application takes a few minutes to commit a change, you can display a processing-status message in a Label. You can also use a Label to identify a control, such as a TextBox control, that doesn't have its own Caption property.

Set the AutoSize and WordWrap properties if you want the Label to properly display variable-length lines or varying numbers of lines.

A Label control can also act as a destination in a DDEconversation. Set the LinkTopic property to establish a link, set the LinkItem property to specify an item for the conversation, and set the LinkMode property to activate the link. When these properties have been set, Visual Basic attempts to initiate the conversation and displays a message if it's unable to do so.

Set the UseMnemonic property to True if you want to define a character in the Caption property of the Label as an access key. When you define an access key in a Label control, the user can press and hold down ALT+ the character you designate to move the focus to the next control in the tab order.


Line Control

A Line control is a graphical control displayed as a horizontal, vertical, or diagonal line.

Syntax

Line

Remarks

You can use a Line control at design time to draw lines on forms. At run time, you can use a Line control instead of, or in addition to, the Line method. Lines drawn with the Line control remain on the form even if the AutoRedraw property setting is False. Line controls can be displayed on forms, in picture boxes, and in frames. You can't use the Move method to move a Line control at run time, but you can move or resize it by altering its X1, X2, Y1, and Y2 properties. The effect of setting the BorderStyle property depends on the setting of the BorderWidth property. If BorderWidth isn't 1 and BorderStyle isn't 0 or 6, BorderStyle is set to 1.


ListBox Control

A ListBox control displays a list of items from which the user can select one or more. If the number of items exceeds the number that can be displayed, a scroll bar is automatically added to the ListBox control.

If no item is selected, the ListIndex property value is -1. The first item in the list is ListIndex 0, and the value of the ListCount property is always one more than the largest ListIndex value.

Syntax

ListBox

Remarks

To add or delete items in a ListBox control, use the AddItem or RemoveItem method. Set the List, ListCount, and ListIndex properties to enable a user to access items in the ListBox. Alternatively, you can add items to the list by using the List property at design time.


Menu Control

A Menu control displays a custom menu for your application. A menu can include commands, submenus, and separator bars. Each menu you create can have up to four levels of submenus.

Syntax

Menu

Remarks

To create a Menu control, use the Menu Editor. Enter the name of the Menu control in the Caption box. To create a separator bar, enter a single hyphen (-) in the Caption box. To display a check mark to the left of a menu item, select the Checked box.

While you can set some Menu control properties using the Menu Editor, all Menu control properties are displayed in the Properties window. To display the properties of a Menu control, select the menu name in the Objects list at the top of the Properties window.

When you create an MDI application, the menu bar on the MDI child form replaces the menu bar on the MDIForm object when the child form is active.


OptionButton Control

An OptionButton control displays an option that can be turned on or off.

Syntax

OptionButton

Remarks

Usually, OptionButton controls are used in an option group to display options from which the user selects only one. You group OptionButton controls by drawing them inside a container such as a Frame control, a PictureBox control, or a form. To group OptionButton controls in a Frame or PictureBox, draw the Frame or PictureBox first, and then draw the OptionButton controls inside. All OptionButton controls within the same container act as a single group.

While OptionButton controls and CheckBox controls may appear to function similarly, there is an important difference: When a user selects an OptionButton, the other OptionButton controls in the same group are automatically unavailable. In contrast, any number of CheckBox controls can be selected.


PictureBox Control

A PictureBox control can display a graphic from a bitmap, icon, or metafile, as well as enhanced metafile, JPEG, or GIF files. It clips the graphic if the control isn't large enough to display the entire image.

Syntax

PictureBox

Remarks

You can also use a PictureBox control to group OptionButton controls and to display output from graphics methods and text written with the Print method.

To make a PictureBox control automatically resize to display an entire graphic, set its AutoSize property to True.

To create animation or simulation, you can manipulate graphics properties and methods in code. Graphics properties and events are useful for run-time print operations, such as modifying the format of a screen form for printing.

A PictureBox control can also act as a destination link in a DDE conversation.

The PictureBox and Data controls are the only standard Visual Basic controls that you can place in the internal area of an MDI form. You can use it to group controls at the top or bottom of the internal area to create a toolbar or status bar.

Note The Unisys Corporation has a patent that it alleges covers certain aspects of GIF-LZW compression technology, which the PictureBox and Image controls use. Microsoft Corporation obtained a license to the Unisys LZW patents in September, 1996. Microsoft's license does not, however, extend to software developers or third parties who use any Microsoft toolkit, language development, or operating system products to provide GIF read/write and/or any other LZW capabilities in their own products (for example, by way of DLLs and APIs).

If your commercial application uses this control (and thus, the LZW technology), you may wish to obtain an independent legal opinion on the effect of the patent, or contact Unisys USA at http://www.unisys.com/ for more information.


Shape Control

The Shape control is a graphical control displayed as a rectangle, square, oval, circle, rounded rectangle, or rounded square.

Syntax

Shape

Remarks

Use Shape controls at design time instead of, or in addition to, invoking Circle and Line methods at run time. You can draw a Shape control in a container, but it can't act as a container. The effect of setting the BorderStyle property depends on the setting of the BorderWidth property. If BorderWidth isn't 1 and BorderStyle isn't 0 or 6, BorderStyle is set to 1.


TextBox Control

A TextBox control, sometimes called an edit field or edit control, displays information entered at design time, entered by the user, or assigned to the control in code at run time.

Syntax

TextBox

Remarks

To display multiple lines of text in a TextBox control, set the MultiLine property to True. If a multiple-line TextBox doesn't have a horizontal scroll bar, text wraps automatically even when the TextBox is resized. To customize the scroll bar combination on a TextBox, set the ScrollBars property.

Scroll bars will always appear on the TextBox when its MultiLine property is set to True, and its ScrollBars property is set to anything except None (0).

If you set the MultiLine property to True, you can use the Alignment property to set the alignment of text within the TextBox. The text is left-justified by default. If the MultiLine property is False, setting the Alignment property has no effect.

A TextBox control can also act as a destination link in a DDE conversation.


Timer Control

A Timer control can execute code at regular intervals by causing a Timer event to occur.

Syntax

Timer

Remarks

The Timer control, invisible to the user, is useful for background processing.

You can't set the Enabled property of a Timer for a multiple selection of controls other than Timer controls.

There is no practical limit on the number of active timer controls you can have in Visual Basic running under Windows 95 or Windows NT.


Topic Not Found

No matching topic was found. Some possible reasons and remedies are as follows:

  • The file (.chm) that contains the destination topic is not in the expected location.

    Remedy: Rerun the MSDN Library Setup.

  • The file (.chm) that contains the current topic or destination topic is out-of-date and the link is no longer valid.

    Remedy: Install the latest version of the MSDN Library.

  • The MSDN Library CD is not in the CD-ROM drive.

    Remedy: Insert the MSDN Library CD into the CD-ROM drive.


SQL Editor

A modal window that allows you to open, save, cut, copy, and paste stored procedures and triggers.

To open the SQL Editor

  1. In Data View, right-click the Stored Procedures folder or any stored procedure in that folder.

  2. Choose Design from the shortcut menu.

Font Colors

The SQL Editor window contains a single font that is color-coded. As you move from line to line by pressing ENTER or by using the mouse or keyboard, the text is colored based on the type of element.

Element | Color
keyword | red
argument | blue
text | black
punctuation | green

Keyboard Shortcuts

You can use the following shortcut keys to perform specific actions in the SQL Editor window.

Command | Shortcut Keys
Clear | DEL
Copy | CTRL+C
Cut | CTRL+X
Debug | CTRL+D
Find | CTRL+F
New | CTRL+N
Open Text File | CTRL+O
Paste | CTRL+V
Print | CTRL+P
Replace | CTRL+H
Save To Database | CTRL+S
Select All | CTRL+A
Undo | CTRL+Z


Add-Ins Menu

Visual Data Manager

Add-In Manager


Edit Menu

Undo

Redo

Cut

Copy

Paste

Paste Link

Delete

Delete Table from Database

Remove Table from Diagram

Select All

Select All Columns

Table

Find

Find Next

Replace

Indent

Outdent

Insert File

List Properties/Methods

List Constants

Quick Info

Parameter Info

Complete Word

Go To Row

Bookmarks


File Menu

New Project

Open Project

Add Project

Remove Project

Save Project/Save Project Group

Save Project As/Save Project Group As

Save

Save As

Print

Print Setup

Make <Project>

Make Project Group

File 1, 2, 3, 4

Exit


Help Menu

Contents

Runs MSDN Library Visual Studio and displays the Contents tab.

Toolbar shortcut: .

Index

Runs MSDN Library Visual Studio and displays the Index tab.

Search

Runs MSDN Library Visual Studio and displays the Search tab.

Toolbar shortcut: .

Technical Support

Displays information about obtaining technical support from Microsoft.

Toolbar shortcut: .

Microsoft on the Web

Displays a menu with Internet sites.

About Microsoft Visual Basic

Displays a dialog box with the version number, a copyright notice, and the amount of available memory.


Run Menu

Start

Start With Full Compile

Break

End

Restart


Tools Menu

Add Procedure

Procedure Attributes

Menu Editor

Options


View Menu

Code

Object

Definition

Last Position

Object Browser

Immediate Window

Locals Window

Watch Window

Call Stack

Project Explorer

Properties Window

Form Layout Window

Property Pages

Table

Zoom

Show Panes

Toolbox

Data View Window

Color Palette

Toolbars


There was an error processing a call to this machine. 'msgtext'

A call to a method of an object provided by an ActiveX component running on this computer has failed for the reason appended at 'msgtext.'

This error occurs when the Automation Manager has received the method call from the client computer, but is unable to make the cross-process call to the component, or made the cross-process call but failed to receive the result.

This error occurs only for cross-process communication failures. It does not occur for errors raised in a component, or for COM or OLE exceptions; such errors are simply returned to the client application.


The file 'file' could not be loaded. 'msgtext'

This error occurs during Setup. The Automation Manager has a dependency on the file named in the message, and that file cannot be found on the computer where Setup is being run, for the reason appended at 'msgtext'.

For example, Automation Manager depends on AUTPRX32.DLL.


There was an error adding information to the registry. 'msgtext'

Setup for the Automation Manager was unable to add the necessary entries to the Windows Registry for the reason appended at 'msgtext.' For example, an error will occur if Setup is executed from a login that does not have write access to the Windows Registry.


There was an error removing information from the registry. 'msgtext'

The Automation Manager was run with the /UNREGSERVER parameter, and was unable to remove the necessary entries from the Windows Registry for the reason appended at 'msgtext.' For example, an error will occur if the Automation Manager is executed in this fashion from a login that does not have write access to the Windows Registry.


There was an error connecting to an object of type 'type'. 'msgtext'

A client computer has a reference to an object on this computer, and has attempted to pass that reference to a third computer. The third computer was unable to connect to the object for the reason appended at 'msgtext.'

'Type' is the fully qualified class name (programmatic ID), for example Customer.Order.


There was an error creating an object of type 'type'. 'msgtext'

A client computer requested creation of an object of the specified type, for example by using the CreateObject function, or the Set statement with the New operator. The request failed for the reason given in the appended 'msgtext.'

If the class the object belongs to is in the Windows Registry of the network computer the Automation Manager is running on, 'type' is the fully qualified class name (programmatic ID).

For example, suppose the Customer server is installed on the network computer, the Automation Manager is using CreateIfKey security, and the CLSID entry for the Order class does not have the subkey AllowRemoteActivation=Y. The error message refers to the object type Customer.Order.

If the object type is not registered, for example when the ActiveX component that supplies it has not been installed on the network computer, 'type' is the CLSID of the object, as it appears in the Windows Registry of the client computer.


There was an error creating an object of type 'type' for 'user'. 'msgtext'

A client computer requested creation of an object of the specified type, for example by using the CreateObject function, or the Set statement with the New operator. The request failed for the reason given in the appended 'msgtext.'

If the class the object belongs to is in the Windows Registry of the network computer the Automation Manager is running on, 'type' is the fully qualified class name (programmatic ID), for example Customer.Order.

If the object type is not registered, for example when the ActiveX component that supplies it has not been installed on the network computer, 'type' is the CLSID of the object, as it appears in the Windows Registry of the client computer.

The user name associated with the request to create the object is inserted at 'user.'

This form of the error occurs only if both of the following are true:

  • The Automation Manager must be running under the Microsoft Windows NT operating system

  • The client computer must be using an Authentication level other than None (1).

Otherwise, the Automation Manager cannot determine the user name, and the form of the error without the user information is used.


The network protocol 'protocol' was needed but was not available. 'msgtext'

The Automation Manager was unable to use the indicated network protocol for the reason appended at 'msgtext.'

This error can occur when a client computer passes a reference to an object provided by an ActiveX component on the client computer, or on another network computer. (The client computer must itself be capable of running the Automation Manager for the first scenario to occur.)

The Automation Manager attempts to connect to the object using the same protocol that was used to pass the reference. If this protocol is not available on the network computer where the Automation Manager is running, the error occurs.

For example, the Named Pipes protocol (ncacn_np) is supported as an RPC client protocol under Windows 95, but not as an RPC server protocol. You can view the lists of RPC client and server protocols on a computer by accessing the following Windows Registry keys:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\ClientProtocols

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\ServerProtocols

On the client computer, the call that attempted to pass the object reference fails with the error &H800706D0, RPC_S_PROTSEQ_NOT_FOUND.


There was an error accessing preferences in the registry. 'msgtext'

Automation Manager was unable to access its preferences in the Windows Registry for the reason appended at 'msgtext.'

For example, an error will occur if the Automation Manager is executed from a login that does not have read permission to the subkeys in the Windows Registry that contain Automation Manager's preferences:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Automation Manager\CallTimeout

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Automation Manager\RemoteActivationPolicy


The Automation Manager was unable to use network protocol 'protocol'. 'msgtext'

Startup message (Warning). The Automation Manager attempts to start with all the RPC network server protocols currently installed on the computer. The Automation Manager was unable to use the protocol 'protocol' for the reason given in the system error message appended at 'msgtext.'

You can view the list of RPC server protocols on a computer by accessing the following Windows Registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\ServerProtocols


The Automation Manager could not be started. 'msgtext'

The Automation Manager could not be started on this computer for the reason given in the system error message appended at 'msgtext.'

For example, an Out of Memory error would prevent the Automation Manager from starting.


There was a timeout processing a call to this machine. 'msgtext'

A call to a method of an object on this machine has timed out for the reason appended at 'msgtext.'

The timeout occurs if the client computer waits more than a specified number of milliseconds for an object, because another client computer is making a call to the same object.

This error only occurs when the Automation Manager serializes requests from two client computers that are accessing the same object. It does not occur when two client computers have separate objects of the same type, nor when OLE serializes requests to an out-of-process ActiveX component that is single-threaded.

The number of milliseconds for the timeout is specified in the Automation Manager's CallTimeout preference setting:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Automation Manager\CallTimeout

The default value is an unsigned four-byte integer, 0xFFFFFFFF, which represents over a hundred years, and thus is effectively infinite. Changing this preference affects all calls to methods of objects on this computer, hence changing it is not recommended.


The Automation Manager was started with the following network protocols: 'protocols'.

Startup message (Information). The Automation Manager attempts to start using all the RPC network server protocols currently installed on the computer. A list of the protocols that were used successfully appears at 'protocols.'

You can view the list of RPC server protocols on a computer by accessing the following Windows Registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\ServerProtocols


The command line parameter 'parameter' was not recognized.

Startup message (Warning). The Automation Manager was started with an invalid command-line parameter, which was ignored. Valid parameters are:

Parameter | Description
/REGSERVER | Registers the Automation Manager in the Windows Registry.
/UNREGSERVER | Unregisters the Automation Manager.
/AUTOMATION | Accepted but ignored.
/EMBEDDING | Accepted but ignored.
/HIDDEN | Starts the Automation Manager without any visible window, so that it runs invisibly. This is particularly useful when the Automation Manager runs on a Win32 workstation. If the Automation Manager is started with this parameter there is no way for the user to close it.


The preference setting 'setting' had an invalid value. The default setting will be used instead.

Automation Manager's RemoteActivationPolicy setting was invalid. The default setting, CreateIfKey (2), will be used. Valid values are:

Setting | Description
0 | CreateNone. Do not allow creation of any CLSID.
1 | CreateAll. Allow creation of any CLSID. Not recommended.
2 | CreateIfKey. Allow creation of only those CLSIDs that include the subkey AllowRemoteActivation=Y
3 | CreateIfAcl. Allow creation of a CLSID only if the user making the request has KEY_QUERY_VALUE permission on the CLSID key.

The location of the RemoteActivationPolicy preference is:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Automation Manager\RemoteActivationPolicy


Error Event (Data Control)

Occurs only as the result of a data access error that takes place when no Visual Basic code is being executed.

Syntax

Private Sub object_Error ([index As Integer,] dataerr As Integer, response As Integer)

The Error event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | Identifies the control if it's in a control array.
dataerr | The error number.
response | A number corresponding to the response you want to take, as described in Settings.

Settings

The settings for response are:

Constant | Value | Description
vbDataErrContinue | 0 | Continue
vbDataErrDisplay | 1 | (Default) Display the error message

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

You usually provide error-handling functionality for run-time errors in your code. However, run-time errors can occur when none of your code is running, as when:

  • A user clicks a Data control button.

  • The Data control automatically opens a database and loads a Recordset object after the Form_Load event.

  • A custom control performs an operation such as the MoveNext method, the AddNew method, or the Delete method.

If an error results from one of these actions, the Error event occurs.

If you don't code an event procedure for the Error event, Visual Basic displays the message associated with the error.

Errors that occur before the Form_Load event, are not trappable and do not trigger the Error event. For example, if at design time you set the properties of the Data control to point to an unknown database table an untrappable error results.


Error Event Example

This example displays an Open dialog box if the database specified in the Data control's DatabaseName property isn't found after the Form_Load event is complete.

Private Sub Data1_Error (DataError As Integer, Response As Integer)
   Select Case DataError
      ' If database file not found.
      Case 3024
         ' Display an Open dialog box.
         CommonDialog1.ShowOpen
      ...
   End Select
End Sub


Reposition Event

Occurs after a record becomes the current record.

Syntax

Private Sub object.Reposition ([index As Integer])

The Reposition event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | Identifies the control if it's in a control array.

Remarks

When a Data control is loaded, the first record in the Recordset object becomes the current record, causing the Reposition event. Whenever a user clicks any button on the Data control, moving from record to record, or if you use one of the Move methods, such as MoveNext, the Find methods, such as FindFirst, or any other property or method that changes the current record, the Reposition event occurs after each record becomes current.

In contrast, the Validate event occurs before moving to a different record.

You can use this event to perform calculations based on data in the current record or to change the form in response to data in the current record.


Reposition Event Example

This example uses the Reposition event to update a list of Titles from the selected Publisher in the Biblio.mdb sample database. First place a DataGrid, TextBox, and two Data controls on a form. Set the DatabaseName properties of both Data controls to the Biblio.mdb sample database. Set the RecordSource property of Data1 to Publishers. Set the DataSource property of Text1 to Data1 and the DataField property to Name. Set the DataSource property of DataGrid1 to Data2. Add the following code:

Private Sub Data1_Reposition()
   ' Select all Titles that are published by
   ' the current record in Data1
   Data2.RecordSource = "Select * from Titles where PubID = " & Data1.Recordset("PubID")
   Data2.Refresh ' Rebuild the recordset
End Sub

The list of Titles in the DataGrid control will automatically be updated as you move through the Publishers recordset with Data1.


DataChanged Property and Validate Event Example

This example illustrates simple data validation. In the Authors table in the Biblio.mdb database, there are two fields: Au_ID and Author. Since the value in Au_ID is used to uniquely identify the author, this value should not change. The example doesn't allow changes to the Au_ID field, which is bound to Text1.

Private Sub Data1_Validate (Action As Integer, Save As Integer)
   If Text1.DataChanged Then   ' Check for change in data.
      MsgBox "You can't change the ID number."
      Text1.DataChanged = False   ' Don't save changed data.
   End If
   ...
End Sub


UpdateControls Method

Gets the current record from a Data control's Recordset object and displays the appropriate data in controls bound to a Data control. Doesn't support named arguments.

Syntax

object.UpdateControls

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use this method to restore the contents of bound controls to their original values, as when a user makes changes to data and then decides to cancel the changes.

This method creates the same effect as making the current record current again, except that no events occur.

The UpdateControls method terminates any pending Edit or AddNew operation.


UpdateRecord Method

Saves the current values of bound controls. Doesn't support named arguments.

Syntax

object.UpdateRecord

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use this method to save the current contents of bound controls to the database during the Validate event without triggering the Validate event again. Using this method avoids creating a cascading event.

The UpdateRecord method has the same effect as executing the Edit method, changing a field, and then executing the Update method, except that no events occur.

You can use this method to avoid triggering the Validate event.

Whenever you attempt to update a record in the database, any validation rules must be satisfied before the record is written to the database. These rules are established by setting the ValidationRule property or, in the case of Microsoft SQL Server, by Transact SQL defaults, rules, and triggers written to enforce referential and data integrity.

In some cases, the update may not occur because the operation violates referential integrity constraints, the page containing the record is locked, the database or Recordset object isn't updatable, or the user doesn't have permission to perform the operation. Any of these conditions generates a trappable error.


Database, DatabaseName Properties Example

This example examines the Database property of a data control and prints the name of each Table in the Debug window.

Sub PrintTableNames ()
   Dim Td As TableDef
   ' Set database file.
   Data1.DatabaseName = "BIBLIO.MDB"
   Data1.Refresh   ' Open the Database.
   ' Read and print the name of each table in the database.
   For Each Td in Data1.Database.TableDefs
      Debug.Print Td.Name
   Next
End Sub


Database Property

Returns a reference to a Data control's underlying Database object.

Syntax

object.Database

Set databaseobject = object.Database (Professional and Enterprise Editions only)

The Database property syntax has these parts:

Part | Description
databaseobject | An object expression that evaluates to an valid Database object created by the Data control.
object | An object expression that evaluates to an object in the Applies To list.

Remarks

The Database object created by the Data control is based on the control's DatabaseName, Exclusive, ReadOnly, and Connect properties.

Database objects have properties and methods you can use to manage your data. You can use any method of a Database object with the Database property of a Data control, such as Close and Execute. You can also examine the internal structure of the Database by using its TableDefs collection, and in turn, the Fields and Indexes collections of individual TableDef objects.

Although you can create a Recordset object and pass it to a Data control's Recordset property, you can't open a database and pass the newly created Database object to the Data control's Database property.

Data Type

Database


DataField Property

Returns or sets the name of a field that a data consumer will be bound to.

Syntax

object.DataField [= string]

The DataField property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | A string expression that evaluates to the name of one of the fields in the Recordset object specified by a data source.

Remarks

Bound controls provide access to specific data in your database. Bound controls that manage a single field typically display the value of a specific field in the current record. The DataSource property of a bound control specifies a valid data source, and the DataField property specifies a valid field name in the Recordset object created by the data source. Together, these properties specify what data appears in the bound control.

When you use a QueryDef object or SQL statement that returns the results of an expression, the field name is automatically generated by the Microsoft Jet database engine. For example, when you code an SQL aggregate function or an expression in your SQL query, unless you alias the aggregate fields using an AS clause, the field names are automatically generated. Generally, the expression field name is Expr1 followed by a three-character number starting with 000. The first expression returned would be named Expr1000.

It's recommended that you code your SQL queries to alias expression columns as shown below:

Adodc1.RecordSource = "Select AVG(Sales)  " _
   & " AS AverageSales From SalesTable"
Text1.DataField = "AverageSales"
Adodc1.Refresh

Note Make sure the DataField property setting is valid for each bound control. If you change the setting of a data control's RecordSource property and then use Refresh, the Recordset identifies the new object. This may invalidate the DataField settings of bound controls and produce a trappable error.


Exclusive Property Example

This example first opens a Database as single-user (exclusive) then changes it to multiuser access (non-exclusive).

Data1.DatabaseName = "BIBLIO.MDB"
Data1.RecordSource = "Publishers"
Data1.Exclusive = True
Data1.Refresh
...
Data1.Exclusive = False
Data1.Refresh


IntegralHeight Property

Returns or sets a value indicating if the control displays partial items. Read-only at run time.

Syntax

object.IntegralHeight [= value ]

The IntegralHeight property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A Boolean expression that determines whether the list is resized, as described in Settings.

Settings

The settings for value are:

Setting | Description
True | (Default) The list resizes itself to display only complete items.
False | The list doesn't resize itself even if the item is too tall to display completely.

Remarks

If the number of items in a list exceeds what can be displayed, a scroll bar is automatically added to the control. You can prevent partial rows from being displayed by setting the IntegralHeight property to True.

Data Type

Boolean


LastModified Property Example

This example might be used with a menu in a program to enable users to return to the last record that was modified.

Data1.Recordset.Bookmark = Data1.Recordset.LastModified


Recordset Property Example

This example uses a Data control to create a Recordset object containing all Titles published in 1994. The Recordset object created is accessible by referencing the Recordset property of the Data control.

Dim Rs As Recordset
Data1.DatabaseName = "BIBLIO.MDB"
Data1.RecordSource =  _
   "Select * From TITLES where [Year Published] = 1994"
Data1.Refresh
Set Rs = Data1.Recordset
If Rs.RecordCount > 0 Then
   Do Until Rs.EOF
      Debug.Print Rs!Title
      Rs.MoveNext
   Loop
Else
   MsgBox "No titles in 1994."
End If

This next example creates the same set of records as above in a Recordset object and assigns it to the Data control's Recordset property. To use this example, place a Textbox, Commandbutton, and Data control on a form and paste in the code.

Private Sub Command1_Click()
Dim DB As Database
Dim Rs As Recordset

Set DB = DBEngine.Workspaces(0).OpenDatabase("BIBLIO.MDB")

Set Rs = DB.OpenRecordset _
("Select * From TITLES where [Year Published] = 1994")

Set Data1.Recordset = Rs
Text1.DataField = "Title"
Data1.Refresh ' Force Data control to update now

End Sub


ODBCDirect

A technology that allows you to access ODBC data sources through RDO by using DAO features that bypass the Microsoft Jet database engine.

When an ODBC data source is referenced in this manner, it is called an "ODBCDirect" data source. This is to distinguish it from an ODBC data source that is connected indirectly through the Jet Database Engine, which is called a "Jet-connected ODBC data source." The technology used in accessing the data source determines which DAO objects, methods, and properties can be used.


Resync Method (Remote Data)

Fetches the batch conflict values for the current row.

Syntax

object.Resync

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The Resync method is valid only when using Client-Batch Cursors.

Resync resynchronizes the columns in the current row in the cursor library with the current data on the server (visible to your transaction). If you have not modified the row, this method changes the Value and OriginalValue properties to match what is currently on the server.

If you have modified the row, this method will only adjust the OriginalValue property so as not to loose your edits. This second case is useful when you want to avoid an optimistic concurrency conflict.

The last case where this is used is when you're dealing with a row that you attempted to update using BatchUpdate, but a conflict occurred because the concurrency check failed. In this case, this method will adjust the BatchConflictValue to reflect the most recent version of the column on the server.


Close Command (Shortcut Menu)

Closes the selected window.


Collapse Parent Command (Shortcut Menu)

Shrinks the list of items in the Locals or Watch window to the parent item. When you collapse a list, the icon to the left of the expression changes from a minus sign (-) to a plus sign (+).


Copy Command (Object Browser Shortcut Menu)

Copies the text for the selected class or member to the Clipboard.


Customize Command (Shortcut Menu)

Displays the Customize dialog box where you can add, delete, modify, or create custom toolbars.


Delete Watch Command (Shortcut Menu)

Deletes the selected watch expression.


Dockable Command (Shortcut Menu)

Toggles the ability to dock the active window on and off.

A window is docked when it is attached or "anchored" to one edge of the screen, application window, or another dockable window. When you move a dockable window, it "snaps" to the location. A window is not dockable when you can move it anywhere on the screen and leave it there.


Find Whole Word Only Command (Object Browser Shortcut Menu)

Allows you to search for occurrences that exactly match the word you typed into the Search Text box of the Object Browser.


Definition Command (Shortcut Menu)

Displays the location in the Code window where the variable or procedure under the pointer is defined. If the definition is in a referenced library, it is displayed in the Object Browser.


Group Members Command (Object Browser Shortcut Menu)

Toggles the Members of pane between an alphabetical list of the members of the selected class and a list grouped by the member type.


Help Command (Shortcut Menu)

Displays the Help topic related to the item selected when the Help command is chosen.


Hide Command (Shortcut Menu)

Hides the active window, project, folder, module, or the Toolbox.


Move Command (Shortcut Menu)

Depending on whether a window or the Toolbox is active when you select the Move command, one of the following actions occurs:

  • Changes the pointer to a [image] so you can move the active window to another location.

  • Displays the Page Order dialog box where you can change the order of the pages in your Toolbox.

You can move the selected page to the left or right of the other pages.


Order Command (Format Menu)

Changes the order of the selected objects on a form.

Bring To Front

Moves the selected objects to the front of all other objects on a form.

Toolbar shortcut: . Keyboard shortcut: CTRL+J.

Send To Back

Moves the selected objects behind all other objects on a form.

Toolbar shortcut: . Keyboard shortcut: CTRL+K.

Bring Forward

Moves the selected object one step higher in the z-order.

Toolbar shortcut: .

Send Backward

Moves the selected object one step lower in the z-order.

Toolbar shortcut:

Note These commands work only with selected objects at design time. In code, you can use the ZOrder method to move forms to the front or back of other forms and objects to the front or back of other objects.


Properties Command (Object Browser Shortcut Menu)

Displays the Member Options dialog box where you type a description of the custom member and give it a Help Context ID and Help File name.

Only available for items containing Basic code.


Properties Command (Shortcut Menu)

Opens the Properties window for the selected item.


Show Hidden Members Command (Object Browser Shortcut Menu)

Shows and hides the hidden members in the Object Browser for each class. Hidden members are members that are not intended for use by the programmer of the reusable object and are not normally visible in the Object Browser. They appear as light gray text.


Size Command (Shortcut Menu)

Changes the pointer so that you can resize the active window or Toolbox.


Toggle Commands (Shortcut Menu)

Breakpoint

Sets or removes a breakpoint at the current line.

Bookmark

Displays or removes a bookmark at the active line in the Code window.


View Definition Command (Object Browser Shortcut Menu)

Takes you to the definition of the selected member.


View Object and View Code Commands (Shortcut Menu)

Allows you to view either the Design window or the Code window.

View Object

Displays or activates the selected item.

View Code

Displays or activates the Code window for a currently selected object.


Commands Tab (Customize Dialog Box)

Allows you to add controls and modify existing controls on the Menu bar or any toolbar. You can also modify the button image and text of your added commands.

Tab Options

Categories

Lists the different command categories.

Commands

Lists the controls available for the category you select in the Categories list. You can drag the command to the toolbar where you want the command to reside. To add the command to a menu, drag it over the menu's title and then into the location in the menu that appears.

Description

Displays a QuickTip for the currently selected control.

Modify Selection

Allows you to change the selected command.

  • Reset — Resets the command to the default.

  • Delete — Deletes the command.

  • Name — Changes the name of the control to the name you type into the box. By using the ampersand (&), you can also set shortcut keys.

  • Copy Button Image — Copies the button image to the Clipboard.

  • Paste Button Image — Pastes the button image from the Clipboard.

  • Reset Button Image — Resets the button image to its default setting.

  • Edit Button Image — Displays the Button Editor dialog box.

  • Change Button Image — Displays a list of button images from which you can select a different image for your button.

  • Default Style — For toolbar buttons, shows only the icon. For menu items, shows the icon and the name.

  • Text Only (Always) — Shows the command name only.

  • Text Only (in Menus) — Hides the icon, if any, for menu items. This options has no effect on toolbar buttons.

  • Image and Text — For toolbars, shows both the icon and name. This option has no effect on menu items.

  • Begin a Group — For toolbars, puts a separator line before the control. Dimmed when the control is at the beginning of the toolbar.


Customize Dialog Box

Allows you to customize your toolbars and menus.

Tabs

Toolbars

Allows you to create, rename, delete, and reset your toolbars.

Commands

Contains commands you can drag to your menus and toolbars.

Options

Allows you to change the size of your toolbar buttons, to show ToolTips and shortcut keys, and to add animation to your menus.


Debugging Tab (Project Properties Dialog Box)

Allows you to specify additional actions to be taken when the IDE goes into run mode. This feature is not available in Standard EXE projects—only in projects that can create ActiveX components such as User Controls, User Documents, and ActiveX Designers (such as webclasses and DHTML Pages). These components are typically consumed by client programs like Internet Explorer and this Debugging tab automates the process of launching these client programs for the Visual Basic developer.

Tab Options

When this project starts

Wait for components to be created

Tells Visual Basic to do nothing in run mode.

Start component

Lets the component determine what happens. The types of components include special ActiveX Designers like the DHTMLPage Designer and the Webclass Designer, and also User Controls and User Documents. If you select a User Control or User Document, Visual Basic will launch the browser and display a dummy test page that contains the component. The component can tell Visual Basic to either launch the browser with a URL or start another program.

Selecting a startup component on the Debugging tab does not affect the Startup Object specified on the General tab. For example, an ActiveX.dll project could specify

Startup Object=Sub Main

and

Start Component=DHTMLPage1

When the project runs, Visual Basic would register the DHTMLPage1 component, as well as other components, execute Sub Main and then launch the Internet Explorer and navigate to a URL that creates an instance of DHTMLPage1.

Start program

Specifies an executable program to be used.

Start browser with URL

Specifies which URL the browser should navigate to.

Use existing browser

If Internet Explorer is already running, then use it. If not, launch a new browser.


Button Editor Dialog Box

Provides the tools to modify Toolbar icons.

Dialog Box Options

Picture

Shows the icon pixel by pixel.

Move

Moves the picture around so that you have access to all parts of it.

  • — Moves the picture up one row each time you click it until the top row of pixels is visible.

  • — Moves the picture down one row each time you click it until the bottom row of pixels is visible.

  • — Moves the picture to the right one column each time you click it until the right-most column is visible.

  • — Moves the picture to the left one column each time you click it until the left-most column is visible.

Colors

Changes the color of the pixel. You click on the color you want and then click on the pixel that you want to appear with that color.

Erase — Removes the color from the pixel you click on after you click on the Erase box.

Preview

Shows you how your icon will appear as you make the changes.

Clear

Clears all of the color and picture from the picture box.

OK

Assigns the picture to the control.


Font Dialog Box

Use to change the fonts, the font size, and/or the font style you use for text and data fields.

Dialog Box Options

Font

Lists all the fonts that you have installed for Windows. When the box first appears, the font already in use for the selected element is highlighted.

Font Style

Lists four additional attributes that you can assign to the font selected:

  • Regular — Standard, unmodified style

  • Bold — Boldface

  • Italic — Italic

  • Bold Italic — Bold Italic

Size

Lists common point sizes for the highlighted font. When the box first appears, the point size for the font already in use for the selected element is highlighted, and the highlighted point size appears in the edit box at the top.

You can select directly from the list or type the new point size in the edit box at the top (if you know that you have additional sizes installed for the currently selected printer or if you are using scalable type).

Effects

Lists two additional options that you can use for highlighting the selected font.

  • Strikeout — Prints the strikeout character across the font

  • Underline — Underlines the font

    You may select as many of the Effects as you wish.

Sample

Displays a sample of the font you have selected. The sample shows the font, style, size, effects, and color you have specified. You can use this box to preview the results as you experiment with different formatting options.

Script

Displays a list of available scripts.

OK

Applies the font changes to the selected report element.

Cancel

Cancels all font changes and leaves the selected element report unchanged.


Load Picture, Load Icon Dialog Boxes

Loads an existing picture or icon file.

Dialog Box Options

Look in

Select the location of the picture you want to open.

Up One Level

Shows a list of folders or drives one level above the current folder.

Create New Folder

Creates a new folder.

List

Shows the folders or files in a list format that includes the icon and its name.

Details

Shows the folders or files in a list that includes the icon and name, its size, type, and the date and time it was last modified.

File name

Select or type the name of a picture file you want to open.

List files of type

Select a file type. Files of the selected type appear in the File Name box.

  • All Picture Files (*.bmp, *.dib, *.wmf, *.emf, *.ico, *.cur) — Lists all picture files.

  • Bitmaps (*.bmp, *.dib) — Lists bitmaps and DIBs.

  • Metafiles (*.wmf, *.wmf) — Lists Microsoft Windows Metafiles.

  • Icons (*.ico, *.cur)—Lists the icons.

  • All Files (*.*) — Lists files of all types.

Open

Opens the selected file.

Cancel

Closes the dialog box without loading a picture file.

Desktop

Lists the folders and files on the desktop. The files and folders are displayed in the File Name box.


New Toolbar Dialog Box

Allows you to give your new toolbar a name.

Dialog Box Option

Toolbar name

You can type the name for your new toolbar or use the default name. The default name changes for each custom toolbar, for example, Custom1, Custom2 and so on.


Options Tab (Customize Dialog Box)

Allows you to change the appearance of your menu bar and toolbars.

Tab Options

Large Icons

Changes the toolbar icons to a larger size.

Show ScreenTips on toolbars

Turns ScreenTips off and on.

Show shortcut keys in ScreenTips

Displays the shortcut keys on the menus.

Menu animations

Lists available animations you can apply to your menu bar.


Toolbars Tab (Customize Dialog Box)

Allows you to create, rename, delete, and reset your toolbars,

Tab Options

Toolbars box

Displays the toolbars built into Visual Basic and any toolbars you create. When you show a toolbar, a check mark appears to the left of it.

Note The Menu bar cannot be hidden. It can only be reset.

New

Opens the New Toolbar dialog box where you type the name for your new toolbar in the Toolbar Name box.

Rename

Opens the Rename Toolbar dialog box where you type the new name for your toolbar. Only available if you select a user-defined toolbar.

Delete

Deletes a user-defined toolbar from your project. Only available if you select a user-defined toolbar.

Reset

Removes any changes to the built-in toolbars and resets them to their original state. Only available if you select a built-in toolbar.


Wildcard Characters Used in String Comparisons

Built-in pattern matching provides a versatile tool for making string comparisons. The following table shows the wildcard characters you can use with the Like operator and the number of digits or strings they match.

Character(s) in pattern | Matches in expression
? | Any single character
* | Zero or more characters
# | Any single digit (09)
[charlist] | Any single character in charlist
[!charlist] | Any single character not in charlist

A group of one or more characters (charlist) enclosed in brackets ([ ]) can be used to match any single character in expression and can include almost any characters in the ANSI character set, including digits. In fact, the special characters opening bracket ([ ), question mark (?), number sign (#), and asterisk (*) can be used to match themselves directly only if enclosed in brackets. The closing bracket ( ]) can't be used within a group to match itself, but it can be used outside a group as an individual character.

In addition to a simple list of characters enclosed in brackets, charlist can specify a range of characters by using a hyphen (-) to separate the upper and lower bounds of the range. For example, using [A-Z] in pattern results in a match if the corresponding character position in expression contains any of the uppercase letters in the range A through Z. Multiple ranges can be included within the brackets without any delimiting. For example, [a-zA-Z0-9] matches any alphanumeric character.

Other important rules for pattern matching include the following:

  • An exclamation mark (!) at the beginning of charlist means that a match is made if any character except those in charlist are found in expression. When used outside brackets, the exclamation mark matches itself.

  • The hyphen (-) can be used either at the beginning (after an exclamation mark if one is used) or at the end of charlist to match itself. In any other location, the hyphen is used to identify a range of ANSI characters.

  • When a range of characters is specified, they must appear in ascending sort order (A-Z or 0-100). [A-Z] is a valid pattern, but [Z-A] isn't.

  • The character sequence [ ] is ignored; it's considered to be a zero-length string ("").


Code Editing Keys

Use these key combinations to edit code in the Code window:

Press | To
CTRL+C | Copy the selected text to the Clipboard.
CTRL+X | Cut the selected text to the Clipboard.
DELETE or DEL | Delete the selected text without placing it on the Clipboard.
CTRL+V | Paste the Clipboard contents at the insertion point.
CTRL+Z | Undo the last editing action in the current line.
CTRL+Y | Cut the current line to the Clipboard.
CTRL+DELETE | Delete to the end of the word.
CTRL+BACKSPACE | Delete to the beginning of the word.
SHIFT+F4 | Find Next: repeat text search down through your code. If no text search has been done, the Find dialog box is displayed.
SHIFT+F3 | Find Previous: repeat text search up through your code. If no text search has been done, the Find dialog box is displayed.
SHIFT+TAB | Remove indent.
CTRL+N | Insert a blank line above the current line.


Code Window General Use Keys

Use these key combinations in the Code window:

Press | To
F1 | Get context-sensitive Help on functions, statements, methods, properties, or events.
F2 | Display the Object Browser.
F9 | Set or remove a breakpoint.
CTRL+SHIFT+F9 | Clear all breakpoints.
F5 | Run an application (or continue running, if in break mode).
F8 | Execute code one line at a time (single step).
SHIFT+F8 | Execute code one procedure at a time (procedure step).
CTRL+BREAK | Stop running a Visual Basic application.
HOME | Move the cursor to the beginning of text in a line.
END | Move the cursor to the end of text in a line.
Double-click on the split bar | Delete the split bar.
SHIFT+F10 | View shortcut menu.
SHIFT+F5 | Restart an application from the beginning.
ALT+F5 | Runs the error handler code or returns the error to the calling procedure. Does not affect the setting for error trapping on the General tab of the Options dialog box.
ALT+F8 | Steps into the error handler or returns the error to the calling procedure. Does not affect the setting for error trapping on the General tab of the Options dialog box.
CTRL+J | Turn on ListProperties/Methods.
CTRL+SHIFT+J | Turn on List Constants.
CTRL+I | Turn on Quick Info.
CTRL+SHIFT+I | Turn on Parameter Info.
CTRL+SPACEBAR | Turn on Complete Word.


Code Window Navigation Keys

Use these key combinations to navigate in the Code window:

Press | To
CTRL+F2 | Move the insertion point into the Object box.
SHIFT+F2 | Go to the definition of the selected procedure.
CTRL+DOWN ARROW | Display the next procedure.
CTRL+UP ARROW | Display the previous procedure.
PAGE DOWN | Page down through the procedures in your code.
PAGE UP | Page up through the procedures in your code.
CTRL+SHIFT+F2 | Go back to the last position in your code.
CTRL+HOME | Go to the beginning of the module.
CTRL+END | Go to the end of the module.
CTRL+RIGHT ARROW | Go one word to the right.
CTRL+LEFT ARROW | Go one word to the left.
END | Go to the end of the line.
HOME | Go to the beginning of the line.
CTRL+PAGE DOWN | Go to the bottom of the current procedure.
CTRL+PAGE UP | Go to the top of the current procedure.
F6 | Switch between Code window panes (when the window is split).


Immediate Window Keyboard Shortcuts

Use these key combinations in the Immediate window:

Press | To
ENTER | Run a line of selected code.
CTRL+C | Copy the selected text to the Clipboard.
CTRL+V | Paste the Clipboard contents at the insertion point.
CTRL+X | Cut the selected text to the Clipboard.
CTRL+L | Display Call Stack dialog box (break mode only).
F5 | Continue running an application.
F8 | Execute code one line at a time (single step).
SHIFT+F8 | Execute code one procedure at a time (procedure step).
DELETE or DEL | Delete the selected text without placing it on the Clipboard.
F2 | Display the Object Browser.
CTRL+ENTER | Insert carriage return.
CTRL+HOME | Move the cursor to the top of the Immediate window.
CTRL+END | Move the cursor to the end of the Immediate window.
SHIFT+F10 | View shortcut menu.
ALT+F5 | Runs the error handler code or returns the error to the calling procedure. Does not affect the setting for error trapping on the General tab of the Options dialog box.
ALT+F8 | Steps into the error handler or returns the error to the calling procedure. Does not affect the setting for error trapping on the General tab of the Options dialog box.
SHIFT+F5 | Restart an application.
F6 | Switch between the Immediate window and the Watch window (if visible).


Menu Shortcut Keys Available in the Code Window

Use these key combinations for menu shortcuts in the Code window:

Press | To
CTRL+P | Print
CTRL+Z | Undo
CTRL+V | Paste
DEL or DELETE | Delete
CTRL+F | Find
SHIFT+F4 | Find Next
CTRL+H | Replace
TAB | Indent
SHIFT+TAB | Outdent
SHIFT+F2 | Definition
CTRL+SHIFT+F2 | Last Position
F2 | Object Browser
CTRL+G | Immediate Window
CTRL+R | Project Explorer
F4 | Properties Window
F8 | Step Into
SHIFT+F8 | Step Over
CTRL+F8 | Run To Cursor
F9 | Toggle Breakpoint.
CTRL+SHIFT+F9 | Clear All Breakpoints
F5 | Start
CTRL+BREAK | Break
SHIFT+F10 | Shortcut menu
CTRL+S | Save Form
CTRL+A | Save Form As
CTRL+F5 | Start with Full Compile
SHIFT+F4 | Property Pages
CTRL+D | Add File
CTRL+J | List Properties/Methods
CTRL+SHIFT+J | List Constants
SHIFT+F9 | Quick Watch
CTRL+N | New Project
CTRL+O | Open Project
CTRL+I | Quick Info
CTRL+SHIFT+I | Parameter Info
CTRL+SPACEBAR | Complete Word


Project Explorer Keyboard Shortcuts

Use these key combinations in the Project Explorer:

Press | To
ENTER | Open the selected file from the list, or expand and collapse the list to show its subentries.
SHIFT+ENTER | Open the Code window for the selected file.
F7 | Open the Code window for the selected file.
SHIFT+F10 | View shortcut menu.
HOME | Select the first file in the list.
END | Select the last file in the list.
RIGHT ARROW | Expands a list and then selects a subentry in the list each time you press it.
LEFT ARROW | Selects a subentry in the list and then moves up the list each time you press it until the subentry list collapses into a folder.
UP ARROW | Moves up the list one entry at a time.
DOWN ARROW | Moves down the list one entry at a time.


Properties Window Keyboard Shortcuts

Use these key combinations when the Property list has the focus in the Properties window:

Press | To
PAGE DOWN | Move down through the Property list,.
PAGE UP | Move up through the Property list.
DOWN ARROW | Move down through the Property list, one property at a time.
UP ARROW | Move up through the Property list, one property at a time.
RIGHT ARROW | Move down through the Property list, one property at a time.
LEFT ARROW | Move up through the Property list, one property at a time.
END | Move to the last property in the list.
HOME | Move to the first property in the list.
TAB | Move the insertion point among the property, properties settings box, and the Object box.
CTRL+SHIFT+ALPHA | Move to the next property in the list that begins with the alpha character.
Double-Click | Cycle through settings of enumerated properties, or switch focus to the settings box for other property types.
ALT+F6 | Switch between the last two active windows.

Use these key combinations when the settings box for a property has the focus in the Properties window:

Press | To
CTRL+Z | Undo the last editing action in the current line.
CTRL+C | Copy the selected text to the Clipboard.
CTRL+X | Cut the selected text to the Clipboard.
DEL or DELETE | Delete the selected text without placing it on the Clipboard.
CTRL+V | Paste the Clipboard contents at the insertion point.
SHIFT+TAB | Switch focus between the Object box and the active Properties tab.
TAB | Move the focus among the Object box, the active Properties tab, a property, and the property value.
ESC | Cancel the property change.
CTRL +SHIFT+ALPHA | Move to the next property that begins with the alpha character, in the list.

Use these key combinations when a property has enumerated values and its settings box has the focus in the Properties window:

Press | To
ALT+DOWN ARROW | Open the settings box list.
ALT+UP ARROW | Close the settings box list.

Use these key combinations when you set the BackColor, ForeColor, FillColor, or BorderColor properties, and the settings box has the focus in the Properties window:

Press | To
ALT+DOWN ARROW | Display the Color palette.
ALT+UP ARROW | Close the Color palette.
DEL | Reset to (None).

Use these key combinations when you set the Icon or Picture properties, and the settings box has the focus in the Properties window:

Press | To
ALT+DOWN ARROW | Display the Load Icon or Load Picture dialog box.
ALT+UP ARROW | Display the Load Icon or Load Picture dialog box.
DEL | Reset to (None).


UserForm Window Keys

Use these key combinations in the UserForm window:

SHIFT+CTRL +ALPHA

.


Watch Window Keyboard Shortcuts

Use these key combinations in the Watch window:

Press | To
SHIFT+ENTER | Display the selected watch expression.
CTRL+W | Display Edit Watch dialog box.
ENTER | Expands or collapses the selected watch value if it has a plus (+) or minus (-) to the left of it.
F2 | Display the Object Browser.
SHIFT+F10 | View shortcut menu.
F6 | Switch between the Watch window and the Immediate window.


Add To Output Command (Query Menu)

Adds the selected column or columns in the input source window of the Diagram pane to the list of columns to appear in the result set of a Select query.


Change Type Command (Query Menu)

Displays a submenu that enables you to change the current query to another type: Select, Insert, Insert Values, Update, Delete, or Make Table. The Query Designer preserves as much information as possible from the current query, such as search conditions.


Clear Results Command (Query Menu)

Clears the results of the Results pane in the Query Designer.

If a query is being executed when you clear the Results pane, the Query Designer stops the query.


Visual Basic Menus

Visual Basic has two types of menus, built-in and shortcut.

Built-in Menus

Built-in menus appear on the menu bar across the top of the Visual Basic window. Each menu contains commands that relate to the menu name. For example, the Format menu contains commands used for formatting your form. Some of the commands have submenus that contains more specific commands. For example, the Toolbars command on the View menu has a submenu that contains the names of the toolbars and the Customize command. You can use the Customize command to modify the built-in menus or to add commands to the menu bar.

Shortcut Menus

Shortcut menus are menus containing frequently used commands that appear when you click the right mouse button or press SHIFT+F10.

Note To find information on a command on a menu, use the Search Reference Index command on the Help menu and search for the name of the command.


Delete Table from Database Command (Edit Menu)

Deletes a table from a database. A table marked for deletion is permanently deleted from the database when you save your diagram. A reference to that table exists in memory until you save your diagram. If you close the diagram without saving it, the table will continue to exist in your database and appear in your diagram and every other diagram in which it appeared before you marked it for deletion. Used in the Database designer.


Diagram Menu

New Text Annotation

Set Text Font

Add Related Tables

Show Relationship Labels

Modify Custom View

View Page Breaks

Recalculate Page Breaks

Arrange Selection

Arrange Tables

Autosize Selected Tables


Go To Row Command (Edit Menu)

Displays a submenu from which you can choose which Row in the Results pane to go to. The options on the submenu are available only when a result set is available in the Results pane. Used in the Query and View designers. The following options are available on the submenu:

First

Moves to the first row in the query results.

Last

Moves to the last row in the query results.

Next

Moves to the next row in the query results.

Previous

Moves to the previous row in the query results.

Row

Displays the Go To Row dialog box and allows you to move to a specified row in the query results.

New

Moves to the end of the query results and appends a blank row to the grid to allow you to enter a new data row.

NoteIf you attempt to go to a row that has not yet been fetched, you might experience a delay until the Query Designer has fetched the row you are moving to. For example, if you execute a long query and then attempt to go to the last row, the Query Designer notifies you that you must wait until the query has been completed.


Group By Command (Query Menu)

Changes the current query to an aggregate query that summarizes and groups data; if the current query is already an aggregate query, reverts to a non-aggregate query. When you are creating an aggregate query, the Query Designer displays a Group By column in the Grid pane to allow you to specify the data columns to group.


Query Menu

Run

Clear Results

Verify SQL Syntax

Group By

Change Type

Add To Output

Sort Ascending

Sort Descending

Remove Filter

Select All Rows From <Table A>

Select All Rows From <Table B>


Remove Filter (Query Menu)

Removes search conditions for the selected column or columns in the input source window of the Diagram pane. This command is available only when you have selected a column in the input source window that has search conditions defined. This option is available only when you have selected a column name in an input source window.


Remove Table from Diagram Command (Edit Menu)

Removes a table from your diagram. Removing a table does not alter your server database; the table and its relationships to other tables continue to exist in the database and appear in Data View. Used in the Database designer.


Run Command (Query Menu)

Executes the current query, stored procedure, or other SQL statement.

If you are creating a Select query, the results of the query appear in the Results pane of the Query Designer. If you are creating an Update, Insert, Insert Values query, Delete, or Make Table query, the Query Designer displays a message indicating how many rows were affected by the query.


Save Change Script Command (File Menu)

Displays the Save Change Script dialog box, which enables you to save the Transact-SQL statements generated during your editing session in a text file with an .sql extension in the project directory. You can use a change script to apply SQL changes to your database at a later time using a tool such as Microsoft SQL Server isql command-line utility. Used in the Table and Database designers.


Save Selection Command (File Menu)

Saves the selected tables and the relationships between them. If changes to a selected table affect an unselected table in your diagram, an asterisk appears in the unselected table's title bar to indicate that it was modified. When you save the selection, the unselected--but modified--table is also saved. Used in the Database designer.


Select All Columns Command (Edit Menu)

Selects all the columns in an input source window in the Diagram pane so that you can perform an action on all of them at once. Used in the Query designer.


Select All Rows From <Table A> (Query Menu)

Specifies an outer join that includes rows from the first table even if they do not have related rows in the second table.


Select All Rows From <Table B> (Query Menu)

Specifies an outer join that includes rows from the second table even if they do not have related rows in the first table.


Show Panes Command (View Menu)

Displays a submenu that enables you to hide and show panes. Choose the name of the pane to hide or show. If only one pane is visible, you cannot hide it. Used in the Query and View designers.

Diagram

Displays the Diagram pane, which displays the input sources (tables or views) you are querying. Each input source appears in its own window showing the available data columns as well as icons that indicate how each column is used in the query. Joins are indicated by lines between the input source windows.

Grid

Displays the Grid pane, which contains a spreadsheet-like grid in which you specify query options, such as which data columns to display, what rows to select, how to group rows, and so on.

SQL

Displays the SQL statement for the current query. You can edit the SQL statement created by the Query Designer or you can enter your own SQL statement. It is particularly useful for entering SQL statements that cannot be created using the Diagram and Grid panes, such as Union queries.

Results

Displays the Results pane, which shows a grid with the results of the most recently executed Select query. You can modify the database by editing values in the cells of the grid, and you can add or delete rows.


Sort Ascending Command (Query Menu)

Adds the selected column or columns in the input source window of the Diagram pane to the list of columns to sort by and specifies Ascending in the Sort By column of the Grid pane. This option is available only when you have selected a column name in an input source window.


Sort Descending Command (Query Menu)

Adds the selected column or columns in the input source window of the Diagram pane to the list of columns to sort by and specifies Descending in the Sort By column of the Grid pane. This option is available only when you have selected a column name in an input source window.


Table Command (Edit Menu)

Displays a submenu that provides table commands. Used in the Table and Database designers.

Set Primary Key

Defines a primary key to enforce uniqueness for values entered in specific columns that do not allow nulls.

Insert Column

Adds a new column definition to the end of a table. Use additional columns to capture additional data that isn't already stored in an existing column.

Delete Column

Deletes a column from a table. The columns, any constraints attached to them, any relationships they participate in, and the data that's stored in them are deleted from the database when you save the table or diagram.


Table Command (View Menu)

Displays a submenu that enables you to collapse and expand the selected window in the Diagram pane. Used in the Database, Query, and View designers.

Column Properties

Shows a set of properties for each column in the table. You can add, edit, and delete columns in this view. New tables inserted into a database diagram are displayed in this view.

Column Names

Shows the name of each column in the table. You can edit and delete columns in this view. Existing tables that are added to a database diagram are displayed in this view.

Keys

Shows the name of each column in the table that participates in a primary key, foreign key, or unique constraint. You can rename or delete columns in this view.

Name Only

Shows the table name and, if applicable, an asterisk to indicate that the table was modified.

Custom

Shows the table as defined by your custom view. You can use the Modify Custom View command in the Diagram menu to pick the column properties you want to display for all custom view tables.


Verify SQL Syntax (Query Menu)

Checks the statement in the SQL pane against the database to determine whether the statement uses correct syntax. This command does not check that the command is valid (that is, that it will return correct results), only that the elements in the statement have been entered correctly for the database you are querying.


Zoom Command (View Menu)

Displays a submenu that enables you to zoom the diagram by a fixed percentage: 10%, 25%, 50%, 75%, 100%, 150% or 200%. By default, database diagrams appear at 100%. Tables can be edited at 50% or higher. Relationships can be created at 25% or higher. Selection centers the selected table in the diagram window. Used in the Database designer.


Ambiguous selection

Either you have not selected a keyword or you have requested Help on a component of the integrated development environment (IDE). If you were trying to select a keyword, try reselecting a single keyword. If you were trying to get information on the IDE, click one of the following:

Code or Module Window

Immediate Window or Pane

Locals Windows or Pane

Object Browser

Watch Window or Pane


Data Types Displayed in Locals Window

The following is a list of data types and their default state when they are displayed in the Locals window.

Data Type | Default State
Currency | Value is displayed.
Double | Value is displayed.
Integer | Value is displayed
Long | Value is displayed.
Single | Value is displayed.
String | Value is displayed.
UDT | No value is displayed. Non-editable. Collapsed.
Variant | Value is displayed.
Object | No value is displayed. Non-editable. Collapsed.
Decimal | Value is displayed.
Array | No value is displayed. Non-editable. Collapsed.


Data View Window Command (View Menu)

Displays the Data View Window. Use the Data View Window to access the structure of your database and manipulate it. The Data View Window looks at all of the Data Environments added to your project and displays the connections from the Data Environments.

Toolbar shortcut:


Icons Used in the Object Browser and Code Windows

The Object Browser and Code window contain many icons that represent classes and members. The following is a list of icons and what they represent.

This Icon: | Represents a:
 | Property
 | Default Property
 | Method
 | Default Method
 | Event
 | Constant
 | Module
 | Class
 | User Defined Type
 | Global
 | Library
 | Project
 | Built-in keywords and types
 | Enum


Circle Method

Draws a circle, ellipse, or arc on an object.

Syntax

object.Circle [Step] (x, y), radius, [color, start, end, aspect]

The Circle method syntax has the following object qualifier and parts:

Part | Description
object | Optional. Object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with the focus is assumed to be object.
Step | Optional. Keyword specifying that the center of the circle, ellipse, or arc is relative to the current coordinates given by the CurrentX and CurrentY properties of object.
(x, y) | Required. Single values indicating the coordinates for the center point of the circle, ellipse, or arc. The ScaleMode property of object determines the units of measure used.
radius | Required. Single value indicating the radius of the circle, ellipse, or arc. The ScaleMode property of object determines the unit of measure used.
color | Optional. Long integer value indicating the RGB color of the circle's outline. If omitted, the value of the ForeColor property is used. You can use the RGB function or QBColor function to specify the color.
start, end | Optional. Single-precision values. When an arc or a partial circle or ellipse is drawn, start and end specify (in radians) the beginning and end positions of the arc. The range for both is –2 pi radians to 2 pi radians. The default value for start is 0 radians; the default for end is 2 * pi radians.
aspect | Optional. Single-precision value indicating the aspect ratio of the circle. The default value is 1.0, which yields a perfect (non-elliptical) circle on any screen.

Remarks

To fill a circle, set the FillColor and FillStyle properties of the object on which the circle or ellipse is drawn. Only a closed figure can be filled. Closed figures include circles, ellipses, or pie slices (arcs with radius lines drawn at both ends).

When drawing a partial circle or ellipse, if start is negative, Circle draws a radius to start, and treats the angle as positive; if end is negative, Circle draws a radius to end and treats the angle as positive. The Circle method always draws in a counter-clockwise (positive) direction.

The width of the line used to draw the circle, ellipse, or arc depends on the setting of the DrawWidth property. The way the circle is drawn on the background depends on the setting of the DrawMode and DrawStyle properties.

When drawing pie slices, to draw a radius to angle 0 (giving a horizontal line segment to the right), specify a very small negative value for start, rather than zero.

You can omit an argument in the middle of the syntax, but you must include the argument's comma before including the next argument. If you omit an optional argument, omit the comma following the last argument you specify.

When Circle executes, the CurrentX and CurrentY properties are set to the center point specified by the arguments.

This method cannot be used in an With…End With block.


Circle Method Example

This example uses the Circle method to draw a number of concentric circles in the center of a form. To try this example, paste the code into the General section of a form. Then press F5 and click the form.

Sub Form_Click ()
   Dim CX, CY, Radius, Limit   ' Declare variable.
   ScaleMode = 3   ' Set scale to pixels.
   CX = ScaleWidth / 2   ' Set X position.
   CY = ScaleHeight / 2   ' Set Y position.
   If CX > CY Then Limit = CY Else Limit = CX
   For Radius = 0 To Limit   ' Set radius.
      Circle (CX, CY), Radius,RGB(Rnd * 255, Rnd * 255, Rnd * 255)
   Next Radius
End Sub


Line Method

Draws lines and rectangles on an object.

Syntax

object.Line [Step] (x1, y1) [Step] - (x2, y2), [color], [B][F]

The Line method syntax has the following object qualifier and parts:

Part | Description
object | Optional. Object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with the focus is assumed to be object.
Step | Optional. Keyword specifying that the starting point coordinates are relative to the current graphics position given by the CurrentX and CurrentY properties.
(x1, y1) | Optional. Single values indicating the coordinates of the starting point for the line or rectangle. The ScaleMode property determines the unit of measure used. If omitted, the line begins at the position indicated by CurrentX and CurrentY.
Step | Optional. Keyword specifying that the end point coordinates are relative to the line starting point.
(x2, y2) | Required. Single values indicating the coordinates of the end point for the line being drawn.
color | Optional. Long integer value indicating the RGB color used to draw the line. If omitted, the ForeColor property setting is used. You can use the RGB function or QBColor function to specify the color.
B | Optional. If included, causes a box to be drawn using the coordinates to specify opposite corners of the box.
F | Optional. If the B option is used, the F option specifies that the box is filled with the same color used to draw the box. You cannot use F without B. If B is used without F, the box is filled with the current FillColor and FillStyle. The default value for FillStyle is transparent.

Remarks

To draw connected lines, begin a subsequent line at the end point of the previous line.

The width of the line drawn depends on the setting of the DrawWidth property. The way a line or box is drawn on the background depends on the setting of the DrawMode and DrawStyle properties.

When Line executes, the CurrentX and CurrentY properties are set to the end point specified by the arguments.

This method cannot be used in an With…End With block.


Line Method Example

This example uses the Line method to draw concentric boxes on a form. To try this example, paste the code into the General section of a form. Then press F5 and click the form.

Sub Form_Click ()
   Dim CX, CY, F, F1, F2, I   ' Declare variables
   ScaleMode = 3   ' Set ScaleMode to pixels.
   CX = ScaleWidth / 2   ' Get horizontal center.
   CY = ScaleHeight / 2   ' Get vertical center.
   DrawWidth = 8   ' Set DrawWidth.
   For I = 50 To 0 Step -2
      F = I / 50   ' Perform interim
      F1 = 1 - F: F2 = 1 + F   ' calculations.
      Forecolor = QBColor(I Mod 15)   ' Set foreground color.
      Line (CX * F1, CY * F1)-(CX * F2, CY * F2), , BF
   Next I
   DoEvents   ' Yield for other processing.
   If CY > CX Then   ' Set DrawWidth.
      DrawWidth = ScaleWidth / 25
   Else
      DrawWidth = ScaleHeight / 25
   End If
   For I = 0 To 50 Step 2   ' Set up loop.
      F = I / 50   ' Perform interim
      F1 = 1 - F: F2 = 1 + F   ' calculations.
      Line (CX * F1, CY)-(CX, CY * F1)   ' Draw upper-left.
      Line -(CX * F2, CY)   ' Draw upper-right.
      Line -(CX, CY * F2)   ' Draw lower-right.
      Line -(CX * F1, CY)   ' Draw lower-left.
      Forecolor = QBColor(I Mod 15)   ' Change color each time.
   Next I
   DoEvents   ' Yield for other processing.
End Sub


PSet Method

Sets a point on an object to a specified color.

Syntax

object.PSet [Step] (x, y), [color]

The PSet method syntax has the following object qualifier and parts:

Part | Description
object | Optional. Object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with the focus is assumed to be object.
Step | Optional. Keyword specifying that the coordinates are relative to the current graphics position given by the CurrentX and CurrentY properties.
(x, y) | Required. Single values indicating the horizontal (x-axis) and vertical (y-axis) coordinates of the point to set.
color | Optional. Long integer value indicating the RGB color specified for point. If omitted, the current ForeColor property setting is used. You can use the RGB function or QBColor function to specify the color.

Remarks

The size of the point drawn depends on the setting of the DrawWidth property. When DrawWidth is 1, PSet sets a single pixel to the specified color. When DrawWidth is greater than 1, the point is centered on the specified coordinates.

The way the point is drawn depends on the setting of the DrawMode and DrawStyle properties.

When PSet executes, the CurrentX and CurrentY properties are set to the point specified by the arguments.

To clear a single pixel with the PSet method, specify the coordinates of the pixel and use the BackColor property setting as the color argument.

This method cannot be used in an With…End With block.


PSet Method Example

This example uses the PSet method to draw confetti on a form. To try this example, paste the code into the General section of a form. Then press F5 and click the form.

Sub Form_Click ()
   Dim CX, CY, Msg, XPos, YPos   ' Declare variables.
   ScaleMode = 3   ' Set ScaleMode to
         ' pixels.
   DrawWidth = 5   ' Set DrawWidth.
   ForeColor = QBColor(4)   ' Set foreground to red.
   FontSize = 24   ' Set point size.
   CX = ScaleWidth / 2   ' Get horizontal center.
   CY = ScaleHeight / 2   ' Get vertical center.
   Cls   ' Clear form.
   Msg = "Happy New Year!"
   CurrentX = CX - TextWidth(Msg) / 2   ' Horizontal position.
   CurrentY = CY - TextHeight(Msg)   ' Vertical position.
   Print Msg   ' Print message.
   Do
      XPos = Rnd * ScaleWidth   ' Get horizontal position.
      YPos = Rnd * ScaleHeight   ' Get vertical position.
      PSet (XPos, YPos), QBColor(Rnd * 15)   ' Draw confetti.
      DoEvents   ' Yield to other
   Loop   ' processing.
End Sub


Data Tips Window

A box that displays the value of the variable over which your cursor is placed.

For example, if you set x=5 and then set breakpoint before the end of your code, when you run your code and place your cursor over the "x", the value 5 appears in the Data Tips window.

Available in break mode.


Data View Window

Use the Data View Window to access the structure of your database and manipulate it. You can:

  • create and modify tables and views.

  • create and modify database diagrams.

  • create and modify stored procedures and triggers.

It also lets you create and manipulate Oracle functions and synonyms.

The Data Environment, on the other hand, is used in the project to access data from within your application.

The Data View Window looks at all of the Data Environments added to your project and displays the connections from the Data Environments.

You can also:

  • drag and drop objects from the Data View Window into the Data Environment to automatically create commands in the Data Environment.

  • Drag and drop commands from the Data Environment Window onto Forms and Reports.

You can open a Data View Window from:

  • The toolbar.

  • The View menu.


Margin Indicators

Visual Basic contains margin indicators that provide visual cues to certain actions during the editing of your code. If more than one action occurs on a line, the appropriate indicators also appear.

The margin indicators appear in the Margin Indicator bar on left side of the Code window.

You can turn the Margin Indicator Bar on and off in the Editor Format tab of the Options dialog box.

Margin Indicator | Margin Indicator Name | Description
Breakpoint | Indicates that you have set a breakpoint using the Toggle Breakpoint command on the Debug menu. You can toggle the breakpoint by placing your mouse pointer in the margin indicator region and clicking.
Current line of execution | Indicates the line of code that will be executed next. You can drag this margin indicator to a new location within any running code module. If you drag the Current line of execution margin indicator to any non-valid region or line, nothing happens and the indicator returns to the original location.
Bookmark | Indicates the location of a bookmark set using the Toggle Bookmark command on the Edit menu.
Call Stack Marker | Indicates lines that are currently in the call stack. The Call Stack Marker indicator appears only in break mode.


Align Commands (Microsoft Data Report Shortcut Menu)

Aligns selected Data Report designer controls with each other.

Lefts

Horizontally aligns the position of the selected controls, putting the leftmost edges in line with that of the leftmost control.

Centers

Horizontally aligns the position of the selected controls, putting the center of each control in line with that of the others.

Rights

Horizontally aligns the position of the selected controls, putting the rightmost edges in line with that of the rightmost control.

Tops

Vertically aligns the position of the selected controls, putting the top of each control in line with that of the topmost control.

Middles

Vertically aligns the position of the selected controls, putting the middle of each control in line with that of the others.

Bottoms

Vertically aligns the position of the selected controls, putting the bottom of each control in line with that of the bottommost control.

To Grid

Aligns the top left of the selected controls to the closest grid. The control is not resized.


Bring Forward Command (Microsoft Data Report Shortcut Menu)

Moves the selected Data Report designer control one step higher in the z-order.


Bring to Front Command (Microsoft Data Report Shortcut Menu)

Moves the selected Data Report designer controls to the front of all other controls on the section.


Center in Section Command (Microsoft Data Report Shortcut Menu)

Centers selected Data Report designer controls on the central axes of the section.

Horizontally

Aligns the middles of the selected controls to a horizontal line in the middle of the section.

Vertically

Aligns the centers of the selected controls to a vertical line in the center of the section.


Cut, Copy, and Paste Commands (Microsoft Data Report Shortcut Menu)

Cut

Removes the selected Data Report designer control and places it on the Clipboard. You must select at least one control for this command to be available.

Copy

Copies the selected Data Report designer control onto the Clipboard. You must select at least one control for this command to be available.

Paste

Inserts the contents of the Clipboard at the current location.


DataMembers Property, Add Method Example

The example adds two data members to a DataMembers collection using the Add method.

Option Explicit
' Declare object variables for ADO recordsets, and a Connection object.
Private WithEvents rsProducts As ADODB.Recordset
Private WithEvents rsSuppliers As ADODB.Recordset
Private cnNwind As ADODB.Connection

Private Sub Class_Initialize()
   ' Add DataMember names to the DataMembers collection.
   With DataMembers
      .Add "Products"
      .Add "Suppliers"
   End With

   ' Set Recordset objects.
   Set rsProducts = New ADODB.Recordset
   Set rsSuppliers = New ADODB.Recordset

   ' Code to open recordsets not shown.

End Sub


Microsoft Data Report Window

Microsoft Data Report Window (Design Time)

Allows you to determine where information appears in each section, by placing Data Report designer controls, such as labels and text boxes.

Window Elements

Report Header

Appears once at the beginning of a report. Use for items such as a logo, report title, or print date. The report header is printed before the page header on the first page of the report.

Page Header

Appears at the top of every page. Use to display items such as column headings, page numbers, or the report title.

Group Header

Associated with a DataMember of the DataSource, each group header delineates a repeating section of the final report. Data-bound TextBox controls placed in the group header can be bound to fields in the DataMember associated with the group header. Each group header is matched with a group footer.

Detail Section

The innermost repeating section of the report is, like group headers/footers, associated with a DataMember. Like group headers and footers, the detail section can contain controls bound to fields in the associated DataMember. If the DataSource is the Data Environment, the detail section is bound to the lowest Command object in the hierarchy.

Group Footer

Like group headers and the Detail section, each group footer delineates a repeating section of the final report. Data-bound TextBox controls in a group footer can be bound to fields in the DataMember associated with the group footer. Function controls can also be placed in the group footer section.

Page Footer

Appears at the bottom of every page in the report. Use to display items such as page numbers.

Report Footer

Appears once at the end of the report. Use to display items such as report totals. The Report Footer is the last section in the report design but appears before the Page Footer on the last page of the printed report.


Microsoft Data Report Window (Run Time)

Allows you to view the report as it will look when printed and to export your report to HTML or text.

Uses halftone palette.

Options

Print

Begins printing a hard copy of the report. You can print only to the current printer. Change the printer from your operating system and then return to the Microsoft Data Report and print.

Export

Exports selected range to an HTML file or text file.

Zoom

Allows you to view your report from 10% to 500% of the actual size of the printout.

Next Page

Moves you to the next page of the report.

Previous Page

Moves you to the previous page of the report.


Delete Group Header/Footer Command (Microsoft Data Report Shortcut Menu)

Deletes the Group Header and the Group Footer sections and any Data Report designer controls on them. This action cannot be undone.


Horizontal Spacing Commands (Microsoft Data Report Shortcut Menu)

Changes the horizontal space between selected Data Report designer controls.

Make Equal

Moves the selected controls so that there is equal space between them.

Increase

Increases horizontal spacing by one grid unit.

Decrease

Decreases horizontal spacing by one grid.

Remove

Removes the horizontal space so that the objects are aligned with their edges touching.


Insert Control Command (Microsoft Data Report Shortcut Menu)

Adds the selected Data Report designer control to the report.

Data Report Designer controls

Label

Insert a label that allows you to have text that cannot change, such as a caption under a graphic. You cannot use the Label control to display the contents of a field.

TextBox

Inserts a text box that can be data-bound by setting the DataField and DataMember properties.

Image

Displays an image from a bitmap, icon, or metafile on your report.

Line

Inserts a line that is used to draw a variety of line styles that you can use to separate sections of your report and make it easier to read. Horizontal lines appear as HTML <HR> tags when exporting to an HTML file.

Shape

Inserts a shape that allows you to draw a variety of shapes on your report. You can choose a rectangle, rounded rectangle, square, rounded square, oval, or circle.

Function

Inserts a control that calculates and displays figures using built-in functions: Sum, Average, Minimum, Maximum, Row Count, Value Count, Standard Error, and Standard Deviation.

Current Page Number

Inserts a Label control with code (%p) to display the current page number in the report.

Total Number of Pages

Inserts a Label control with code (%P) to display the total number of pages.

Current Date (Short Format)

Inserts a Label control with code (%d) to display the current date in the short date format recognized by your computer.

Current Date (Long Format)

Inserts a Label control with code (%D) to display the current date using your system's long date format.

Current Time (Short Format)

Inserts a Label control with code (%t) to display the current time using the 24-hour format, for example, 17:45.

Current Time (Long Format)

Inserts a Label control with code (%T) to display the current time using your system's long time format; includes hours, minutes, seconds.

Report Title

Inserts a Label control with code (%i) to display the title of the report, as set with the Title property.


Insert Group Header/Footer Command (Microsoft Data Report Shortcut Menu)

Displays the Insert Group Header/Footer dialog box with a New Group Header and New Group Footer. You can change the position of the header and footer.


Insert New Group Header/Footer Dialog Box (Microsoft Data Report)

Inserts a new Group Header and new Group Footer and lets you position it on the report. Group Headers and Group Footers can only appear between the detail section and the Page Header and Page Footer sections.

Options

List of sections

Lists the sections in the order in which they appear on the report. The new Group Header and Group Footer sections appear below the current Group Headers and Group Footers. Use the arrow keys to position the selected New Group Header and New Group Footer where you want them.

Moves the selected Group Header and Group Footer one position away from the detail section each time you click it. The Group Header moves until it is positioned below the Page Header section and the Group Footer move until it is positioned above the Page Footer section. When you cannot move them further the button becomes inactive.

Moves the selected Group Header and Group Footer one position toward the detail section each time you click it. The Group Header moves until it is positioned above the detail section and the Group Footer moves until it is positioned below the detail section. Then you cannot move them further and the button becomes inactive.


Make Same Size Command (Microsoft Data Report Shortcut Menu)

Makes the selected Data Report designer controls the same size in the dimension you select.

Width

Adjusts width.

Height

Adjusts height.

Both

Adjusts both the width and the height.


Microsoft Data Report

Helps you design a report that displays fields and records from the underlying table or query.

A report is an effective way to present data in a printed format. You can display the information the way you want to see it.

You create the report using graphical objects called Data Report designer controls. Data Report designer controls include: a data-bound TextBox control, a Function control which displays calculated figures, an Image control for inserting graphics, labels that display captions, and a Line and a Shape control that graphically organizes the data.

Note Although the Data Report designer controls are similar to Visual Basic intrinsic controls, Data Report Designer controls have a limited subset of features. When the Data Report designer is added to a project, the designer's controls are placed in the Visual Basic Toolbox on a new tab named DataReport and can be used only in the Microsoft Data Report.


Microsoft Data Report Shortcut Menu

Undo

Select All

Align

Make Same Size

Size to Grid

Horizontal Spacing

Vertical Spacing

Center in Section

Bring to Front

Send to Back

Bring Forward

Send Backward

Insert Control

Delete Group Header/Footer

Insert Group Header/Footer

Show Report Header/Footer

Show Page Header/Footer

Show Grid

Show Rulers

Snap to Grid

Retrieve Structure

Clear Structure Command


Select All Command (Microsoft Data Report Shortcut Menu)

Selects all of the Data Report designer controls in the report.


Send Backward Command (Microsoft Data Report Shortcut Menu)

Moves the selected Data Report Designer control one step lower in the z-order.


Send to Back Command (Microsoft Data Report Shortcut Menu)

Moves the selected Data Report designer controls behind all other controls on the section.


Show Grid Command (Microsoft Data Report Shortcut Menu)

Displays the Microsoft Data Report grid. Use the grid to size and position the Data Report Designer controls.


Show Page Header/Footer Command (Microsoft Data Report Shortcut Menu)

Displays or deletes the page header and page footer. Clearing the check mark deletes the page header and page footer and all Data Report designer controls they contain.

Deletion of page headers and footer cannot be undone.


Show Report Header/Footer Command (Microsoft Data Report Shortcut Menu)

Displays or deletes the report header and report footer. Clearing the check mark deletes the report header and report footer and all Data Report designer controls they contain.

Deletion of the report header and footer cannot be undone.


Show Rulers Command (Microsoft Data Report Shortcut Menu)

Displays the rulers. The scale of the ruler is determined by the computer's system.


Size to Grid Command (Microsoft Data Report Shortcut Menu)

Adjusts the height and width of the selected Data Report designer control to fit the nearest gridlines in the section.


Snap to Grid Command (Microsoft Data Report Shortcut Menu)

Aligns a control's upper-left corner to the grid. When moving or resizing an existing control, constrains movement from grid point to grid point only.


Toolbar (Webclass Designer)

Contains buttons that are shortcuts to some menu items frequently used when creating webclasses. You can click a toolbar button once to carry out the action represented by that button.

Toolbar Buttons

Cut

Removes the selected webitem or event and places it on the Clipboard.

Copy

Copies the selected webitem or event onto the Clipboard.

Paste

Inserts the contents of the Clipboard at the current location.

Delete

Deletes the currently selected webitem or event.

Add HTML Template WebItem

Displays the Add HTML Template dialog box, from which you can select an HTML template file to insert into the webclass. The designer displays the template and all of the attributes of HTML tags within it that are capable of launching server requests.

Add Custom WebItem

Adds a custom webitem to the webclass. You can create events for the custom webitem and write code for it.

Add Custom Event

Adds a custom event to the selected template or custom webitem.


Data Report Designer Controls (Microsoft Data Report)

Controls that you can use with your Microsoft Data Report.

Note Although the Data Report designer controls appear in the Visual Basic toolbox, they do not work the same way as their analogous Visual Basic controls. These controls can be used only in the Microsoft Data Report.

At design time, you can change the properties of the controls in the Properties window. You can change the:

  • ForeColor and BackColor

  • Caption and text

  • Fonts

  • Size

  • Location and alignment

  • Border color and Border style

Data Report Designer Controls

Pointer

The only item in the Microsoft Data Report Toolbox that doesn't draw a control. When you select the pointer, you can only resize or move a control that has already been drawn on a report.

rptLabel

Allows you to have text that cannot change, such as a caption under a graphic. You cannot use the Label control to display the contents of a field.

rptTextBox

Bound to a field in a database. Set the field using the DataField property after setting the DataMember property. The control is always in multiline mode.

rptImage

Displays a graphical image from a bitmap, icon, or metafile on your report.

rptLine

Used to draw a variety of line styles that you can use to separate sections of your report and make it easier to read. Horizontal lines appear as HTML <HR> tags when exporting to an HTML file.

rptShape

Allows you to draw a variety of shapes on your report. You can choose a rectangle, rounded rectangle, square, rounded square, oval, or circle.

rptFunction

Calculates and displays figures using one of four built-in functions: Sum, Average, Minimum, Maximum, Row Count, Value Count, Standard Error, and Standard Deviation.


Undo Command (Microsoft Data Report Shortcut Menu)

Undoes the last editing action, such deleting Data Report designer controls. When you delete one or more controls, you can use the Undo command to restore the controls and all their properties.

The Undo command only works after the following actions:

  • Delete control(s)

  • Cut control(s)

  • Retrieve Structure

  • Clear Structure


Vertical Spacing Command (Microsoft Data Report Shortcut Menu)

Changes the vertical space between the selected Data Report designer controls, based on the control with focus.

Make Equal

Moves the selected controls so that there is equal space between them.

Increase

Increases the vertical spacing by one grid unit.

Decrease

Decreases the vertical spacing by one grid unit.

Remove

Removes the vertical spacing so that the control’s borders are touching.


Add Custom Event Command (Webclass Shortcut Menu)

Adds a custom event to the selected template or custom webitem.

Available only when you select the HTML Template WebItems or Custom WebItems folders in the Treeview panel of the Webclass designer.


Add Custom WebItem Command (Webclass Shortcut Menu)

Adds a custom webitem to the webclass. You can create events for the custom webitem and write code for it.

Available only when you select the webclass, the HTML Template WebItems folder, or the Custom WebItems folder in the Treeview panel of the Webclass designer.


Add File Command (Project Menu)

Adds an existing file to the current project. You can share files between projects. If you add a file to a project, you are simply including a reference to the existing file in the project; you are not adding a copy of the file to the project. Therefore, if you make changes to the file and save it, your changes will affect any project that includes the file.

Available at design time only.

Keyboard shortcut: CTRL+D.

Note Use the Components command on the Project menu to add ActiveX controls and insertable objects to your project's Toolbox.

If you have connected to a source code control program, such as Microsoft SourceSafe (available with the Enterprise Edition), when you add a file to a Visual Basic project, a dialog may prompt you to add the file in the version control project.

With Microsoft SourceSafe, if the .vbp file is checked out, the references to the newly added file(s) are automatically added. If the .vbp file isn't checked out, when you add a file, the .vbp file will not contain a reference to the new file, and thus, it will not load the next time you open your project.

Dialog Box Options

Look in

Select the location from which you want to add the file.

Up One Level

Shows a list of folders or drives one level above the current folder.

Create New Folder

Creates a new folder.

List

Shows the folders or documents in a list format that includes the folder or document icon and its name.

Details

Shows the folder or documents in a list that includes the folder or document icon and name, its size (documents only), type, and the date and time it was last modified.

File name

Select or type the name of a file you want to open. This box lists documents with the filename extension selected in the List Files of Type box.

List files of type

Select a file type from the list:

  • VB Files (*.frm; *.ctl, *.pag, *.bas; *.cls; *.res) — Lists all valid Visual Basic file types.

  • Form Files (*.frm) — Lists all form modules.

  • User Defined Control Files (*.clt) — Lists all user defined controls.

  • Property Page Files (*.pag) — Lists all property pages.

  • User Document Files (.dob) — Lists all user documents.

  • Basic Files (*.bas) — Lists all standard modules.

  • Class Files (*.cls) — Lists all class modules.

  • Resource Files (*.res) — Lists all resource files. There can be only one resource file in a single project.

  • All Files (*.*) — Lists all files.

Open

Adds the file to the project.

Cancel

Closes the dialog box without adding the file to the project.

Add As Related Document

Adds items such as Microsoft Excel worksheets or Microsoft Word document to the Related Documents folder in the Project Explorer.


Add HTML Template Command (Webclass Shortcut Menu)

Displays the Add HTML Template dialog box, from which you can select an HTML template file to insert into the webclass. The template and all of the attributes of HTML tags within it that are capable of launching server requests are displayed in the designer window.

Available only when you select the webclass, the HTML Template WebItems folder, or the Custom WebItems folder in the Treeview panel of the Webclass designer.


Add-In Manager Command (Add-Ins Menu)

Displays the Add-In Manager dialog box, which you use to load and unload add-ins which extend the Visual Basic development environment.


Add Module and Add Class Module Commands (Project Menu)

Displays the Add Module or Add Class Module dialog box so you can insert a new or existing module or class module into your active project.

Toolbar shortcuts: (Add Module command) and [image] (Add Class Module command).


Add <ActiveX Designer> Command (Project Menu)

Displays the first four kinds of ActiveX designers that are loaded for a project. If more than four designers are loaded, the later ones will be displayed from the More ActiveX Designers submenu on the Project menu.

Note You must add an ActiveX designer using the Designer tab of the Components dialog from the Project menu before designers are available.


Add Procedure Command (Tools Menu)

Inserts a new Sub, Function, Property, or Event procedure into the active module.

Not available if the module is not active.

Toolbar shortcut: .


Add Project Command (File Menu)

Displays the Add Project dialog box so that you can add a new or existing project to the currently open project group. If you have only one project open, Visual Basic adds the project and creates a project group. A project group exists only if there is more than one project.

Note If you do not have a project group opened, Visual Basic automatically creates a project group containing the existing open project and the project you add.

A project group can contain any number of other projects. It is an easy way to load more than one project at a time

The first EXE project you add to your project group is automatically set as Startup unless you change it using the Set as Start Up command on the Project Explorer shortcut menu.

When you add an in-process project to the project group and reference it, the project appears in the References dialog box and is stored in the project file.

When you add a project to a group, Visual Basic checks if any of the other projects in the group have a reference to the binary version of the newly added group. If they do, the references automatically are changed to the source version.


Add Property Page Command (Project Menu)

Displays the Add Property Page dialog box so you can insert new or existing property pages into your active project. Use the Property Page Wizard to build new property pages.

Toolbar shortcut: .


Add Tab, Rename Tab, and Delete Tab Commands (Shortcut Menu)

Allows you to add, rename, or modify the tabs in the Toolbox. You cannot rename or delete the General tab.

Add Tab

Opens a dialog box where you can add and name a new tab. The new tab appears below the General tab.

Rename Tab

Opens a dialog box where you can type a new name for the selected tab.

Delete Tab

Deletes the selected tab.


Add Command (Shortcut Menu)

Displays a submenu where you can choose which of the following items you want to add to your project.

  • Form

  • MDI Form

  • Module

  • Class Module

  • User Control

  • Property Page

  • User Document

  • ActiveX Designer

  • File


Add Watch Command (Debug Menu)

At design time or in break mode, this command displays the Add Watch dialog box in which you enter a watch expression. The expression can be any valid Basic expression. Watch expressions are updated in the Watch window each time you enter break mode.

Toolbar shortcut: .


Align Commands (Format Menu)

Aligns selected objects with each other using the last selected object, the one with the solid color grab handles, as the reference.The color of the grab handles is based on the color you set from Selected Items on the Appearance tab of the Display Properties dialog box in the Control Panel.

Lefts

Aligns the horizontal position of the selected objects, putting the left-most edges in line with the last selected object, the one with the solid color grab handles.

Toolbar shortcut: .

Centers

Aligns the horizontal position of the selected objects, putting the centers in line with the last selected object, the one with the solid color grab handles.

Toolbar shortcut: .

Rights

Aligns the horizontal position of the selected objects, putting the right-most edges in line with the last selected object, the one with the solid color grab handles.

Toolbar shortcut: .

Tops

Aligns the vertical position of the selected objects, putting the tops in line with the last selected object, the one with the solid color handles.

Toolbar shortcut: .

Middles

Aligns the vertical position of selected objects, putting the middles in line with the last selected object, the one with the solid color grab handles.

Toolbar shortcut: .

Bottoms

Aligns the vertical position of the selected objects, putting the bottoms in line with the last selected object, the one with the solid color grab handles.

Toolbar shortcut: .

To Grid

Aligns the top left of the selected objects to the closest grid. The object is not resized.

Toolbar shortcut: .


Align To Grid Command (Shortcut Menu)

Aligns the top left of the selected objects on your form to the closest grid. The object is not resized.

You can change the grid settings from the General tab of the Options dialog box.

Toolbar shortcut:


Data Bindings Dialog Box

Allows you to set the Data Field for each property that is marked as Bindable or DisplayBind.

Dialog Box Options

Property Name

Displays a list of the properties that are marked as Bindable and DisplayBind.

A property that has a data field assigned to it appears in Bold text.

Data Field

Lists all of the fields from the source specified in the DataSource property of the control.


Bookmarks Commands (Edit Menu)

Displays a menu that you can use to create or remove placeholders in the Code window, move to the next or preceding bookmark, or clear all of the bookmarks. Bookmarks mark lines of code so that you can easily return to them at a later time.

When you add a bookmark, a [image] appears next to the line of code where the bookmark is inserted.

Toggle Bookmark

Toggles a bookmark on or off.

Toolbar button:

Next Bookmark

Moves the insertion point to the next bookmark.

Toolbar button:

Previous Bookmark

Moves the insertion point to the previous bookmark.

Toolbar button:

Clear All Bookmarks

Removes all bookmarks.

Toolbar button:


Break Command (Run Menu)

Stops execution of a program while it's running and switches to break mode. Any statement being executed when you choose this command is displayed in the Code window with [image] in the left margin if you checked Margin Indicator Bar in the Editor Format tab of the Options dialog box. If the application is waiting for events in the idle loop (no statement is being executed), no statement is highlighted until an event occurs.

Some editing changes made in break mode may require you to restart your program for the changes to take effect.

This command is available only at run time.

Toolbar button: Keyboard shortcut: CTRL+BREAK.


Call Stack Command (View Menu)

Displays the Calls dialog box, which lists the procedures calls in the application that have started but are not completed. Available only in break mode.

When Visual Basic is executing the code in a procedure, that procedure is added to a list of active procedure calls. If that procedure then calls another procedure, there are two procedures on the list of active procedure calls. Each time a procedure calls another Sub, Function, or Property procedure, it is added to the list. Each procedure is removed from the list as execution is returned to the calling procedure. Procedures called from the Immediate window are also added to the calls list.

You can also display the Calls dialog box by clicking the Calls button (...) next to the Procedure box in the Locals window.

Toolbar shortcut: . Keyboard shortcut: CTRL+L.


Center in Form Commands (Format Menu)

Centers selected objects on the central axes of the form.

Horizontally

Aligns the middles of the selected objects to a horizontal line in the middle of the form.

Toolbar shortcut: .

Vertically

Aligns the centers of the selected objects to a vertical line in the center of the form.

Toolbar shortcut: .


Clear All Breakpoints Command (Debug Menu)

Removes all breakpoints in your project. Your application may still interrupt execution, however, if you have set a watch expression or selected the Break on All Errors option in the General tab of the Options dialog box. You cannot undo the Clear All Breakpoints command. Not available at run time.

Toolbar shortcut: . Keyboard shortcut: CTRL+SHIFT+F9.


Code Command (View Menu)

Displays or activates the Code window for a currently selected object.

Toolbar shortcut: . Keyboard shortcut: F7.


Color Palette Command (View Menu)

Displays or activates the Color palette, which enables you to change a form or control's colors and set up a custom color scheme.

Available only at design time.


Toolbars Command (View Menu)

Lists the toolbars that are built into Visual Basic and the Customize command. You can:

  • Toggle the toolbars on and off.

  • Drag the toolbars to different locations on you desktop.

Debug

Displays the Debug toolbar which contains buttons for common debugging tasks.

Edit

Displays the Edit toolbar which contains buttons for common editing tasks.

Form Editor

Displays the Form Editor toolbar which contains buttons specific to editing a form.

Standard

Displays the Standard toolbar which is the default toolbar.

UserForm

Displays the UserForm toolbar which contains buttons specific to the form.

Customize

Displays the Customize dialog box where you can customize or create toolbars and your menu bar.


Comment Block and Uncomment Block Commands

Adds and removes the comment character, an apostrophe, for each line of a selected block of text. If you do not have text selected and you choose the Comment Block or Uncomment Block command, the comment character is added or removed in the line where the pointer is located.

Comment Block

Adds the comment character to each line of a selected block of text.

Uncomment Block

Removes the comment character from each line of a selected block of text.


Complete Word Command (Edit Menu)

Fills in the rest of the word you are typing once you have entered enough characters for Visual Basic to identify the word you want.

Toolbar shortcut: . Keyboard shortcut: CTRL+SPACEBAR.


Continue Command (Run Menu)

Resumes execution of a program that is in break mode.

Replaces the Start command when the program is in break mode.


Add User Control Command (Project Menu)

Displays the Add User Control dialog box so you can insert a new or existing user control into your active project.

Toolbar shortcut: .


Cut, Copy, Paste, and Delete Commands (Edit Menu)

Cut

Removes the selected control or text and places it on the Clipboard. You must select at least one character or control for this command to be available. You can undo the Cut command only in the Code window.

Toolbar shortcut: . Keyboard shortcut: CTRL+X or SHIFT+DELETE.

Copy

Copies the selected control or text onto the Clipboard. You must select at least one character or control for this command to be available. You cannot undo the Copy command in the Code window.

Toolbar shortcut: . Keyboard shortcut: CTRL+C or CTRL+INSERT

Paste

Inserts the contents of the Clipboard at the current location. Text is placed at the insertion point.

Pasted controls are placed at the upper-left corner of the active form. You can keep the same control name and create a control array, or paste the control with a different name.

You can undo the Paste command only in the Code window.

Toolbar shortcut: . Keyboard shortcut: CTRL+V or SHIFT+INS.

Delete

Deletes the currently selected control, text, or watch expression. You can undo the Delete command only in the Code window.

Note To delete a file from your disk, use the standard deletion procedures for your operating system.

Toolbar shortcut: . Keyboard shortcut: DEL.

Not available at run time.


Cut, Copy, and Paste Commands (Webclass Shortcut Menu)

Cut

Cuts the selected item and places it on the Clipboard. You must select at least one webitem or event for this command to be available.

Copy

Copies the selected item onto the Clipboard. You must select at least one webitem or event for this command to be available.

Paste

Inserts the contents of the Clipboard at the current location.


Data Form Designer Command (VisData Utility Menu)

Displays the Data Form Designer so you can create and add forms to your current Visual Basic project.


Debug Toolbar

Contains buttons that are shortcuts to some commonly used menu items frequently used in debugging code.

You can click a toolbar button once to carry out the action represented by that button. You can select the Show ToolTips option in the General tab of the Options dialog box if you want to display ToolTips for the toolbar buttons.

Toolbar Buttons

Start

Runs the application from the startup form (or Sub Main) specified in the Project tab of the Options dialog box. The Command button changes to Continue if in break mode.

Break

Stops execution of a program temporarily. Click the Continue button to resume running a program.

End

Stops running the program and returns to design time.

Toggle Breakpoint

Sets or removes a breakpoint at the current line.

Step Into

Executes code one statement at a time.

Step Over

Executes code as a unit when the current statement contains a call to a procedure, and then steps to the next statement in the current procedure.

Step Out

Executes the remaining lines of a function in which the current execution point lies.

Locals Window

Displays the Locals window.

Immediate Window

Displays the Immediate window.

Watch Window

Displays the Watch window.

Quick Watch

Displays the Quick Watch dialog box with the current value of the selected expression.

Call Stack

Displays the Calls dialog box, which lists the currently active procedure calls–procedures in the application that have started but are not completed.


Default Command (Color Palette Shortcut Menu)

Changes the colors to those specified in the Control Panel.


Delete Command (Webclass Shortcut Menu)

Deletes the currently selected event, HTML template webitem, or custom webitem.


Description Command (Shortcut Menu)

Turns the description pane of the Properties window off and on.


Form Editor Toolbar

Contains buttons that are shortcuts to some commonly used menu items useful for working with forms.

You can click a toolbar button once to carry out the action represented by that button. You can select the Show ToolTips option in the General tab of the Options dialog box if you want to display ToolTips for the toolbar buttons.

Toolbar Buttons

Bring To Front

Moves the selected objects to the front of all other objects on a form.

Send To Back

Moves the selected objects behind all other objects on a form.

Align

Lefts — Aligns the horizontal position of the selected objects, putting the left-most edges in line with the last selected object, the one with the black grab handles.

Centers — Aligns the horizontal position of the selected objects, putting the centers in line with the last selected object, the one with the black grab handles.

Rights — Aligns the horizontal position of the selected objects, putting the right-most edges in line with the last selected object, the one with the black grab handles.

Tops — Aligns the vertical position of the selected objects, putting the tops in line with the last selected object, the one with the black grab handles.

Middles — Aligns the vertical position of selected objects, putting the middles in line with the last selected object, the one with the black grab handles.

Bottoms — Aligns the vertical position of the selected objects, putting the bottoms in line with the last selected object, the one with the black grab handles.

To Grid — Aligns the top left of the selected objects to the closest grid. The object is not resized.

Center

Horizontally — Aligns the middles of the selected objects to a horizontal line in the middle of the form.

Vertically — Aligns the middles of the selected objects to a vertical line in the center of the form.

Make Same Size

Width — Adjusts width.

Height — Adjusts height.

Both — Adjusts both the width and the height.

Lock Controls Toggle

Locks and unlocks controls. When controls are locked, all controls on the form are kept in their current positions so you don't inadvertently move them once they are in the desired location.


Add User Document Command (Project Menu)

Displays the Add User Document dialog box so you can insert a new or existing User Document into your active project.

Only available if you have an ActiveX EXE or ActiveX DLL project.

Toolbar shortcut: .


Edit Toolbar

Contains buttons that are shortcuts to some commonly used menu items frequently used when editing code.

You can click a toolbar button once to carry out the action represented by that button. You can select the Show ToolTips option in the General tab of the Options dialog box if you want to display ToolTips for the toolbar buttons.

Toolbar Buttons

List Properties/Methods

Displays a box in the code window that contains the properties and methods available for the selected object.

List Constants

Displays a box in the Code window that contains the constants that are valid choices for the property you typed and that precede the equals sign (=).

Quick Info

Provides the syntax for a function, method, or procedure based on the location of your pointer within the name of the function, method, or procedure.

Parameter Info

Shows a popup in the Code window that contains information about the parameters of the function in which the pointer is located.

Complete Word

Accepts the characters that Visual Basic automatically adds to the word you are typing.

Indent

Shifts all lines in the selection to the next tab stop.

Outdent

Shifts all lines in the selection to the previous tab stop.

Toggle Breakpoint

Sets or removes a breakpoint at the current line.

Comment Block

Adds comment character to the beginning of each line of a selected block of text.

Uncomment Block

Removes the comment character from each line of a selected block of text.

Toggle Bookmark

Toggles a bookmark on or off for the active line in the Code window.

Next Bookmark

Moves the focus to the next bookmark.

Previous Bookmark

Moves the focus to the previous bookmark.

Clear All Bookmarks

Removes all bookmarks set in a project.


Edit HTML Template Command (Webclass Shortcut Menu)

Opens Notepad or your computer's default HTML editor and displays the contents of the .htm file associated with the selected template webitem. You can make changes to the contents of the file and save it.

Available only when you select a template file in the Treeview panel of the Webclass designer.


Edit Watch Command (Debug Menu)

Displays the Edit Watch dialog box in which you can edit or delete a watch expression. Available when the watch is set even if the Watch window is hidden. Not available at run time.

Toolbar shortcut: . Keyboard shortcut: CTRL+W.


Exit Command (File Menu)

Closes the current project and quits Visual Basic. If you try to quit Visual Basic before saving changes to your work, you'll be prompted to save your work first.

Note When you exit Visual Basic, you may be prompted to check in the Visual Basic files to the source code control project if you are using an integrated source code control program, such as Microsoft SourceSafe (available with the Enterprise Edition), and you have any files checked out.

Keyboard shortcut: ALT+Q.


File 1, 2, 3, 4 Command (File Menu)

Lists the four most recently used projects (.vbp) or project groups (.vbg).


Find Command (Edit Menu)

Find and Find Next Commands (Edit Menu)

Find

Searches for the specified text in a search range specified in the Find dialog box.

If a search is successful, the Find dialog box closes and Visual Basic selects the located text. If no match is found, Visual Basic displays a message stating that the text was not found.

Toolbar shortcut: . Keyboard shortcut: CTRL+F.

Find Next

Finds and selects the next occurrence of the text specified in the Find What box of the Find dialog box.

Toolbar shortcut: . Keyboard shortcuts: SHIFT+F4 (Find Next) or SHIFT+F3 (Find Previous).

Dialog Box Options

Find What

Type or insert the information you want to find, or click the down arrow and select from the last four entries. If any text is selected or the cursor is on a word when you choose the command, this text is displayed in the Find What box.

Search

Specifies the search range.

  • Current Procedure — Searches only the current procedure.

  • Current Module — Searches only the current module.

  • Current Project — Searches all the modules in your project.

  • Selected Text — Searches a selected range of code in your project.

Direction

Sets the direction of the search to Down or Up from the location of the cursor, or All in the selected search range.

Find Whole Word Only

Searches for the full word by itself and not as part of a larger word.

Match Case

Finds all occurrences with the exact combination of uppercase and lowercase letters specified in the Find What box.

Use Pattern Matching

Searches using pattern-matching characters.

Find Next

Finds and selects the next occurrence of the text specified in the Find What box.

Cancel

Closes the dialog box without performing the search.

Replace

Displays the Replace dialog box, retaining the information typed in the Find What dialog box.


Format Menu

Align

Make Same Size

Size to Grid

Horizontal Spacing

Vertical Spacing

Center in Form

Order

Lock Controls


Add Form Command (Project Menu)

Displays the Add Form dialog box so you can insert a new or existing form into your active project.

Only available at design time.

Toolbar shortcut: .


Form Layout Window Command (View Menu)

Displays the Form Layout window where you can preview and position your form as it will appear in your application. Use the Resolution Guide command on the shortcut menu to preview it using different resolutions.

Note You can view only those resolutions lower than the resolution at which your monitor is set.

Toolbar shortcut: .


Horizontal Spacing Commands (Format Menu)

Changes the horizontal space between selected objects.

Make Equal

Moves the selected objects so that there is equal space between them using the outermost objects as endpoints. The outermost objects do not move.

Toolbar shortcut: .

Increase

Increases horizontal spacing by one grid unit based on the object with focus. When an object has focus, black handles appear on its borders. You can change the size of your grid units in the General tab of the Options dialog box.

Toolbar shortcut: .

Decrease

Decreases horizontal spacing by one grid unit based on the object with focus. When an object has focus, black handles appear on its borders. You can change the size of your grid units in the General tab of the Options dialog box.

Toolbar shortcut: .

Remove

Removes the horizontal space so that the objects are aligned with their edges touching based on the object with focus. When an object has focus, black handles appear on its borders.

Toolbar shortcut: .

Note The object with focus does not move but the other objects move around it.

Note If using the Horizontal Spacing command does not produce the results you want, try to manually rearrange some of the objects and repeat the command. Also, try the using the Vertical Spacing command.


Immediate Window Command (View Menu)

Displays the Immediate window and displays information resulting from debugging statements in your code or from commands typed directly into the window.

Available in break mode.

Use the Immediate window to:

  • Test problematic or newly written code.

  • Query or change the value of a variable while running an application. While execution is halted, assign the variable a new value as you would in code.

  • Query or change a property value while running an application.

  • Call procedures as you would in code.

  • View debugging output while the program is running.

Toolbar shortcut: . Keyboard shortcut: CTRL+G.


Indent Command (Edit Menu)

Shifts all lines in the selection to the next tab stop. If you place the cursor anywhere in a line and choose the Indent command, the entire line is shifted to the next tab stop. All lines in the selection are moved the same number of spaces to retain the same relative indentation within the selected block.

You can change the tab width on the Editor tab of the Options dialog box.

Toolbar shortcut: . Keyboard shortcuts: CTRL+M.


Insert File Command (Edit Menu)

Opens the Insert File dialog box so that you can insert text from an existing file at the current pointer position in the Code window.

Not available at run time or when no editor is open.


Quick Watch Command (Tools Menu)

Quick Watch Command (Debug Menu)

Displays the Quick Watch dialog box with the current value of the selected expression. Available only in break mode.Use this command to check the current value of a variable, property, or other expression for which you have not defined a watch expression. Select the expression from either the Code window or the Immediate window, and then choose the Quick Watch command. To add a watch expression based on the expression in the Quick Watch dialog box, choose the Add button.

Toolbar shortcut: . Keyboard shortcut: SHIFT+F9.


Last Position Command (View Menu)

Allows you to quickly navigate to a previous location in your code. Enabled only if you edited code or made a Definition command call and only when the Code window is displayed. Visual Basic only keeps track of the last 8 lines that were accessed or edited. Available at design time and in break mode.

Keyboard shortcut: CTRL+SHIFT+F2.


Locals Window Command (View Menu)

Displays the Locals window and automatically displays all of the variables in the current stack and their values.

The Locals window is automatically updated every time you change from run time to break mode and every time the stack context changes.

Toolbar shortcut: .


Lock Controls Command (Format Menu)

Locks all controls on the form in their current positions so you don't inadvertently move them once they are in the desired location. Because the Lock Controls command works on a form-by-form basis, it locks controls only on the selected form; controls on other forms are untouched. Visual Basic keeps track of which forms have controls locked in position and which don't. When the controls on the form are locked, the Lock Controls command toolbar button appears dimmed.

Toolbar shortcut: .


Make Project Group Command (File Menu)

Creates a separate executable file for each project in the group you select.

This is the same as using the /make flag in the command line and specifying a .vbg file.


Make <Project> Command (File Menu)

Opens the Make Project dialog box so that you can build one or more projects contained in the project group into an executable file – EXE, DLL, or OCX.

Note You can have only one main project. If you want to debug other projects in the design environment, you must add the .vbp files to the group project.


Make Same Size Commands (Format Menu)

Using the last object selected, the object with the solid color grab handles, makes the selected objects the same size in the dimension you select. The color of the grab handles is based on the color you set from Selected Items on the Appearance tab of the Display Properties dialog box in the Control Panel.

Width

Adjusts width.

Toolbar shortcut: .

Height

Adjusts height.

Toolbar shortcut: .

Both

Adjusts both the width and the height.

Toolbar shortcut: .


Add MDI Form Command (Project Menu)

Displays the Add MDI Form dialog box so you can insert a new or existing MDI form into your active project. A project can have only one MDI form. This command is unavailable if a project already has an MDI form. The MDI form command is also unavailable for ActiveX .exes and ActiveX .dlls if the threading is set to Thread per Object on the General tab on the Project Properties dialog box.

Only available at design time.

Toolbar shortcut: .


Menu Editor Command (Tools Menu)

Displays the Menu Editor dialog box.

Use the Menu Editor command to create custom menus for your application ,and to define some of their properties. Available only at design time.

Toolbar shortcut: . Keyboard shortcut: CTRL+E.


Move Up and Move Down Commands (Shortcut Menu)

Moves the selected tab of the Toolbox up or down one position each time you click it.


New Project Command (File Menu)

Displays the New Project dialog box where you choose the type of project you want to create.

If there is currently another project open when you create a new project, you will be prompted to save your work.

Available only at design time.


Object Browser Command (View Menu)

Displays the Object Browser, which lists the object libraries, the type libraries, classes, methods, properties, events, and constants you can use in code, as well as the modules and procedures you defined for your project. Not available at run time.

Toolbar shortcut: . Keyboard shortcut: F2.


Object Command (View Menu)

Displays the active item.

Only available at design time and when the cursor is on a valid object.

Toolbar shortcut: . Keyboard shortcut: SHIFT+F7.


Components Command (Project Menu)

Displays the Components dialog box from which you can add controls, designers, or insertable objects (such as a Microsoft Word Document) to the Toolbox. You can also reference loaded control projects.


Open Project Command (File Menu)

Closes the current project or group project, if one is loaded, and opens an existing project or group of projects.

You can open as many projects as your system resources permit.

Toolbar shortcut: . Keyboard shortcut: CTRL+O.

Note If you are using an integrated source code control program, such as Microsoft SourceSafe (available with the Enterprise Edition), and have checked the project files out of the version control project, when you close a project (before opening a new one), a dialog may prompt you to check in the files you have checked out.

When you open a project in Visual Basic, a dialog may prompt you to get or check out the Visual Basic project files.


Options Command (Tools Menu)

Displays the Options dialog box, from which you can choose a tab to set attributes of the Visual Basic programming environment. Available only at design time.

Tabs

  • Editor

  • Editor Format

  • General

  • Docking

  • Environment

  • Advanced


Outdent Command (Edit Menu)

Shifts all lines in the selection to the previous tab stop. If you place the cursor anywhere in a line and choose the Outdent command, the entire line is shifted to the previous tab stop. All lines in the selection are moved the same number of spaces to retain the same relative indentation within the selected block.

You can change the tab width on the Editor tab of the Options dialog box.

Toolbar shortcut: . Keyboard shortcuts: CTRL+SHIFT+M.


Parameter Info Command (Edit Menu)

Shows a popup in the Code window that contains information about the parameters of the initial function or statement. If you have a function or statement that contains functions as its parameters, choosing Parameter Info provides information about the first function. Quick Info provides information about each embedded function.

As you type a parameter it is bold until you type the comma used to delineate it from the next parameter.

The Parameter Info, once activated, will not close until:

  • All of the required parameters are entered.

  • The function is ended without using all of the optional parameters.

  • You press ESC.

Toolbar shortcut: . Keyboard shortcut: CTRL+SHIFT+I.


Paste Link Command (Edit Menu)

Supports pasting a link to a valid DDE source. Active only when the Clipboard contains a valid DDE source, and the selected control is a valid DDE link.

You can also use Paste Link to link data from another application using the OLE container control. Once you copy valid data onto the Clipboard (a paragraph from a word processor or a range of cells from a spreadsheet), you can select the OLE container control on your form, and then choose Paste Link to link the data.

Available only at design time.


Print Command (File Menu)

Prints forms and code to the printer specified in the Microsoft Windows Control Panel. Available only at design time.

Toolbar shortcut: . Keyboard shortcut: CTRL+P.

Dialog Box Options

Printer

Identifies the printer to which you are printing.

Range

Determines the range you print:

  • Selection — Prints the currently selected code.

  • Current Module — Prints the forms and/or code for the currently selected module.

  • Current Project — Prints the forms and/or code for the entire project.

Print What

Determines what you print. You can select as many options as you like, depending on what you selected as the Range.

  • Form Image — Prints the form images.

  • Code — Prints the code for the selected range.

Print Quality

Determines whether you print high, medium, low, or draft output quality.

Print to File

If selected, print is sent to the file specified in the Print To File dialog box. This dialog box appears after you choose OK in the Print dialog box.

OK

Prints your selection.

Cancel

Closes the dialog box without printing.

Setup

Displays the standard Print Setup dialog box.


Print Setup Command (File Menu)

Displays the standard Print Setup dialog box with options to specify the printer, page orientation, paper size, and paper source, as well as other printing options.

Available only at design time.

Toolbar shortcut: .


Procedure Attributes Command (Tools Menu)

Opens the Procedure Attributes dialog box where you can set the attributes for each property and method specified for an item.

You can also use this command when you want to set the Value property for classes.

Note You must use this command to set the Value property as the default if you want the control host to find it.


Definition Command (View Menu)

Displays the location in the Code window where the variable or procedure under the pointer is defined. If the definition is in a referenced library, it is displayed in the Object Browser.

Keyboard shortcut: SHIFT+F2.


Project Explorer Command (View Menu)

Displays the Project Explorer, which displays a hierarchical list of the currently open projects and their contents.

The Project Explorer is a navigational and management tool only. You cannot build an application from the Project Explorer. You can close a project by choosing the Remove Project command from the shortcut menu.

Toolbar shortcut: . Keyboard shortcut: CTRL+R.


<Project Name> Properties Command (Project Menu)

Displays the Project Properties dialog box where you view the project properties for the selected project.

Toolbar shortcut: .


Properties Command (Shortcut Menu)

Displays the Properties window.

If you select your form in the Object Browser, the Properties command displays the Member Options dialog box.


Properties Window Command (View Menu)

Displays the Properties window, which lists the design-time properties for a selected form, control, class, user control, property page, user document, or menu. Available only at design time.

Toolbar shortcut: . Keyboard shortcut: F6.


Property Pages Command (View Menu)

Displays the property pages for a user control which to change a control's properties at design time.

Keyboard shortcut: SHIFT+F4.


Quick Info Command (Edit Menu)

Provides the syntax for a variable, function, statement, method, or procedure selected in the Code window.

Quick Info shows the syntax for the item and highlights the current parameter. For functions and procedures with parameters, the parameter appears bold as you type it, until you type the comma used to delineate it from the next parameter.

To have Quick Info automatically appear as you type your code, select Auto Quick Info on the Editor tab in the Options dialog box.

Toolbar shortcut: . Keyboard shortcut: CTRL+I.


References Command (Project Menu)

Displays the References dialog box. This dialog box allows you to add an object library or type library, or project reference to your project. This makes another application's objects available in your code. Once a reference is set, the referenced objects are displayed in the Object Browser.

You can also add references to other loaded and saved projects. If a project has not been saved, it appears as "UNSAVED: <ProjectName>" and you will be unable to make a reference to it.

Only available at design time

Toolbar shortcut: .


Refresh HTML Template Command (Webclass Shortcut Menu)

Updates the webclass with any changes made to the .htm file that is the source of the template. Any new attributes of HTML tags for the template that are capable of acting as events are added to the Detail panel of the treeview.

Available only when you select a template file in the Treeview panel of the Webclass designer.


Remove Project Command (File Menu)

Removes the selected project from the currently open project group.

If there are pending changes to the project, you will be prompted to save them and then the project will be closed and removed from the project group.

If you remove a project with a reference to any of the EXEs or other projects in the group, Visual Basic automatically switches the reference to the binary version of the component, if one is available. If a binary version is not available, the reference is marked as missing.


Remove <Item> Command (Project Menu)

Removes the currently selected item from your project. If you made changes to it since last saving it, you are asked whether you want to save the changes first.

The file remains in all the other projects to which it has been added. Files that have been removed from a project remain stored on your hard disk until you delete them, following the standard procedures of your operating system.

When removing a module or resource file from a project, make sure the remaining code doesn't refer to the removed item.

Note Use the Components dialog box to remove an ActiveX control from the Toolbox. If you still have an ActiveX control on a form, you can't remove the control from the Toolbox.

Available only at design time.

Note If you are using an integrated source code control program, such as Microsoft SourceSafe (available with the Enterprise Edition), when you remove a file from your Visual Basic project, a dialog may prompt you to remove the file from the version control project.

With Microsoft SourceSafe, if the .vbp file is checked out, the references to the removed file(s) are automatically deleted. If the .vbp file isn't checked out, when you remove a file, the .vbp file will still contain a reference to the deleted file, causing an error the next time you load your project.


Remove Project Command (Shortcut Menu)

Closes the selected project and removes it from the Project Explorer. Using this command also removes the project from the currently open project group.


Rename Command (Webclass Shortcut Menu)

Allows you to change the name of the currently selected event, HTML template webitem, or custom webitem.


Replace Command (Edit Menu)

Searches code in the project for the specified text and replaces it with the new text specified in the Replace dialog box.

Toolbar shortcut: . Keyboard shortcut: CTRL+H.

Dialog Box Options

Find What

Type or insert the information you want to find, or click the down arrow and select from the last four entries. If any text is selected or the cursor is on a word when you choose the command, this text is displayed in the Find What box.

Replace With

Type the text you want to use as the replacement text or paste it from the Clipboard. To delete the text in the Find What box from the document, leave the Replace With box empty.

Search

Specifies the search range.

  • Current Procedure — Searches only the current procedure.

  • Current Module — Searches only the current module.

  • Current Project — Searches all the modules in your project.

  • Selected Text — Searches a selected range of code in your project.

Direction

Sets the direction of the search to Down, Up, or All in the selected search range.

Find Whole Word Only

Searches for the full word by itself and not as part of a larger word.

Match Case

Finds all occurrences with the exact combination of uppercase and lowercase letters specified in the Find What box.

Use Pattern Matching

Searches using pattern-matching characters.

Find Next

Finds and selects the next occurrence of the text specified in the Find What box.

Cancel

Closes the dialog box without replacing text.

Replace

Confirms before replacing the search text with the replacement text.

Replace All

Replaces all occurrences of the search text with the replacement text without stopping for confirmation.


Resolution Guide (Form Layout Window Shortcut Menu)

Displays dotted lines showing the right and lower borders of standard resolutions based on the resolution of your monitor. You can size and position your forms so that they fit appropriately with the resolution for which you are creating your application.

Note If your monitor is set for 640x480, you will not see the guidelines. The guidelines only appear with resolutions lower than those of your monitor.


Restart Command (Run Menu)

Restarts your application after any kind of interruption. An interruption can be caused by run-time errors, a Stop statement, a breakpoint in your code, choosing the Break command, and a Break expression changing or becoming true.

This command is available only in break mode.

Keyboard shortcut: SHIFT+F5.


Revert to Original Order Command (Webclass Shortcut Menu)

When selected for any column in the Webclass designer's Detail panel, this option returns the list of attributes to their original order prior to any sorting you performed. The original sort order of the attributes indicates the order in which attribute's HTML tags occur in the HTML template file. You can alphabetically sort the list of attributes by selecting any of the column headings.

Available only when you right-click on a column heading after sorting the attributes.


End Command (Run Menu)

Stops running the program and returns to design time. This command is available at run time and in break mode.

Toolbar shortcut: .


Run to Cursor Command (Debug Menu)

When your application is in break mode, use Run To Cursor to select a statement further down in your code where you want execution to stop. Your application will run from the current statement to the selected statement and the current line of execution margin indicator, [image] appears in the Margin Indicator bar.

You can use this command, for example, to avoid stepping through large loops.

Available only in break mode.

Keyboard shortcut: CTRL+F8.


Save and Save As Commands (File Menu)

Saves the current or selected project files to the location you specified. The Save command displays the Save File As dialog box if this is the first time the file is being saved.

The dialog box enables you to specify a new name for a component. Available only at design time.

Keyboard shortcut: CTRL+S (Save).

Note If you are using an integrated source code control program, such as Microsoft SourceSafe (available with the Enterprise Edition), when you save a file with the Save As command, a dialog may prompt you to add the file to the version control project. You can add a file to a SourceSafe project only if the Visual Basic project file (.vbp) is checked out.

When you use Save As to rename a file that is checked out of a source code control program, ensure that the source code control program also renames the file in the version control project.

Dialog Box Options

Save in

Select the folder where you want to store the file.

Up One Level

Shows a list of folders or drives one level above the current folder.

Create New Folder

Creates a new folder.

Details

Shows the folder or documents in a list that includes the folder or document icon and name, its size (documents only), type, and the date and time it was last modified.

List

Shows the folders or documents in a list format that includes the folder or document icon and its name.

Filename

Unless you specify a filename extension, Visual Basic automatically adds the default filename extension.

Save astype

Select a file type from the list:

  • All Files (*.*) — Lists files of all types.

  • Form Files (*.frm) — Lists all forms and MDI forms.

  • Class Files (*.cls) — Lists all class modules.

  • Basic Files (*.bas) — Lists all standard modules.

  • Property Page Files (*pag) — List all property pages.

  • User Defined Control Files (*.ctl) — Lists all user controls.

  • Document Object Files (*.dob) — Lists all document objects.

Save

Saves the file under the specified name.

Cancel

Closes the dialog box without saving the file.


Save Project, Save Project As, Save Project Group, and Save Project Group As Commands (File Menu)

Save Project

Saves the current project and all its components.

Save Project As

The Save Project command displays the Save Project As dialog box if this is the first time the project is being saved.

Save Project Group

The Save Project command changes to Save Project Group if you add a project to the project group.

Save Project Group As

The Save Project As command displays the Save Project Group As dialog box if this is the first time the project group is being saved.

Available only at design time.

Toolbar shortcut: .

Dialog Box Options

SaveIn

Select the location where you want to store the project file.

Up One Level

Shows a list of folders or drives one level above the current folder.

Create New Folder

Creates a new folder.

List

Shows the folders or documents in a list format that includes the folder or document icon and its name.

Details

Shows the folder or documents in a list that includes the folder or document icon and name, its size (documents only), type, and the date and time it was last modified.

List

Shows the list of folders or documents.

Filename

Give your project a name. To save a project with a new name, or in a different location, type a new filename. To save a project with an existing filename, select the name in a list or type the current name. When you choose Save, Visual Basic asks if you want to overwrite the existing file.

Save as type

Select a file type from the list; the default is Project (*.vbp). Files of the selected type will appear in the File Name list box.

Save

Saves the project group under the specified name.

Cancel

Closes the dialog box without saving the project.


Select All Command (Edit Menu)

Selects all of the code in the active Code window.


Select Constant Command (Edit Menu)

List Constants Command (Edit Menu)

Opens a dropdown list box in the Code window that contains the valid constants for a property that you typed, and that preceded the equal sign (=). The List Constants command also works for functions with arguments that are constants. To have the list box automatically open as you type your code, select Auto List Members on the Editor tab in the Options dialog box.

You can find the constant you want by:

  • Typing the name.

  • Using the up and down arrow keys to move up and down in the list.

  • Scrolling through the list and selecting the constant you want.

You can insert the constant into your code statement by:

  • Double-clicking the constant.

  • Selecting the constant and pressing TAB to insert the selection or pressing ENTER to insert the selection and move to the next line.

Toolbar shortcut: . Keyboard shortcut: CTRL+SHIFT+J.


Select Member Command (Edit Menu)

List Properties/Methods Command (Edit Menu)

Opens a dropdown list box in the Code window that contains the properties and methods available for the object that precedes the period (.). The List Properties/Methods command also displays a list of the globally available methods when the pointer is on a blank space. To have the list box automatically open as you type your code, select Auto List Members on the Editor tab in the Options dialog box.

You can find the property or method you want in the list box by:

  • Typing the name. As you type, the property or method that matches the characters you type is selected and moves to the top of the list.

  • Using the up and down arrow keys to move up and down in the list.

  • Scrolling through the list and selecting the property or method you want.

You can insert the property or method into your statement by:

  • Double-clicking the property or method.

  • Selecting the property or method and pressing TAB to insert the selection or pressing ENTER to insert the selection and move to the next line.

Note Objects of the type Variant do not show a list after the period (.).

Toolbar shortcut: . Keyboard shortcut: CTRL+J.


Set as Start Up Command (Shortcut Menu)

Makes the selected project the project to run when the user presses F5 or the Start button on the Standard or Debug toolbar. The start up project appears in bold text in the Project Explorer.

If you do not identify a project as the start up project, the first EXE project that is added to the group is identified, by default, as the start up project. Adding additional EXE project to the project group does not change the start up project.


Set Next Statement Command (Debug Menu)

Sets the execution point to the line of code you choose. You can set a different line of code to execute after the currently selected statement by selecting the line of code you want to execute and choosing the Set Next Statement command or by dragging the Current Execution Line margin indicator to the line of code you want to execute.

Using Set Next Statement, you can choose a line of code located before or after the currently selected statement. When you run the code, any intervening code isn't executed. Use this command when you want to rerun a statement within the current procedure or to skip over statements you don't want to execute. You can't use Set Next Statement for statements in different procedures.

Toolbar shortcut: . Keyboard shortcut: CTRL+F9.


Code Window Keyboard Shortcuts

You can use the following shortcut keys to access commands in the Code window.

Description | Shortcut Keys
View Code window | F7
View Object Browser | F2
Find | CTRL+F
Replace | CTRL+H
Find Next | SHIFT+F4
Find Previous | SHIFT+F3
Next procedure | CTRL+DOWN ARROW
Previous procedure | CTRL+UP ARROW
View definition | SHIFT+F2
Shift one screen down | CTRL+PAGE DOWN
Shift one screen up | CTRL+PAGE UP
Go to last position | CTRL+SHIFT+F2
Beginning of module | CTRL+HOME
End of module | CTRL+END
Move one word to right | CTRL+RIGHT ARROW
Move one word to left | CTRL+LEFT ARROW
Move to end of line | END
Move to beginning of line | HOME
Undo | CTRL+Z
Delete current line | CTRL+Y
Delete to end of word | CTRL+DELETE
Indent | TAB
Outdent | SHIFT+TAB
Clear all breakpoints | CTRL+SHIFT+F9
View shortcut menu | SHIFT+F10


Show Next Statement Command (Debug Menu)

Highlights the next statement to be executed. Use the Show Next Statement command to place the cursor on the line that will execute next.

Available only in break mode.

Toolbar shortcut: .


Size to Grid Command (Format Menu)

Adjusts the height and width of the selected object to fit the nearest gridlines in the form. You can change the size of your grid on the General tab of the Options dialog box.

Not available in break mode

Toolbar shortcut: .


Standard Toolbar

Contains buttons that are shortcuts to some commonly used menu items.

You can click a toolbar button once to carry out the action represented by that button. You can select the Show ToolTips option in the General tab of the Options dialog box if you want to display ToolTips for the toolbar buttons.

Toolbar Buttons

Add Project

Displays a submenu listing the types of projects you can add to the currently open project group. The icon changes to the last project type you added. The default is the Standard EXE.

— Standard EXE

— ActiveX EXE

— ActiveX DLL

— ActiveX Control

Add <item>

Displays a submenu listing the items you can add to your active project. The icon changes to the last object you added. The default is the Form.

Form

MDI Form

Module

Class Module

User Control

Property Page

User Document

<ActiveX Designer>

Can add up to four such commands. Open the Project menu, choose Components, and select the Designers tab.

More ActiveX Designers

Visible if there are more than four designers selected in the Designers dialog box options.

Add File

Show Menu

Displays the Menu Editor dialog box.

Open Project

Closes the current project and project group, if one is loaded, and displays an existing group project and it accompanying projects.

Save Project

Saves the current project and all its components–forms and modules.

Cut

Removes the selected control or text and places it on the Clipboard.

Copy

Copies the selected control or text onto the Clipboard.

Paste

Inserts the contents of the Clipboard at the current location.

Find

Searches for the specified text in a search range specified in the Find dialog box.

Undo

Reverses the last editing action, such as typing text in the Code window or deleting controls.

Redo

Restores the last text editing if no other actions have occurred since the last Undo.

Start

Runs the application starting with the Startup Object identified on General tab of the Project Properties dialog box.

Break

Stops execution of a program while it's running and switches to break modedefBreakMode.

End

Stops running the program and returns to design time

Project Explorer

Displays the Project Explorer, which displays a hierarchical list of the currently open projects and their contents.

Properties Window

Displays the Properties window so you can view the properties of the selected control.

Form Layout Window

Displays the Form Layout window where you can preview position your form within the window.

Object Browser

Displays the Object Browser, which lists the object libraries, the type library, classes, methods, properties, events, and constants you can use in code, as well as the modules and procedures you defined for your project.

Toolbox

Displays the Toolbox, which contains the controls and insertable objects (such as a Microsoft Excel Chart) currently available to your application.

Data View Window

Displays the Data View Window. Use the Data View Window to access the structure of your database and manipulate it. The Data View Window looks at all of the Data Environments added to your project and displays the connections from the Data Environments.


Start Command (Run Menu)

Runs the application marked as the Start Up project in the Project Explorer. All forms being designed are closed, variables are initialized, and the startup form (if any) is loaded. You cannot run control projects at design time. DLL project types can be run by another EXE project creating an instance of them, and group projects cannot be run unless an EXE project exists in the group.

The first EXE project added to a project group is automatically set as the Start Up project unless you change it using the Set as Start Up command on the shortcut menu.

Available only at design time. The Start command becomes the Break command at run time, and begins executing the code from the current execution line margin indicator, [image]. It becomes the Continue command in break mode.

Note If you are working on a sub project and choose the Start command, the main project changes to run mode. The sub project is compiled but is not executed until the main project makes a call to it.

Toolbar shortcut: . Keyboard shortcut: F5.


Startup Position Commands (Form Layout Window Shortcut Menu)

Displays the startup position of the form over which your cursor was placed when you got the shortcut menu and allows you change the startup position of this form.

Manual

Allows you to manually move the forms around the Form Layout Window. The form has a colored bar at the top and a single border around it.

Center Owner

Places the form in the center of the monitor with another window underneath it. The additional window represents the host or owner window. Both form and host window have a colored bar at the top.

Center Screen

Places the form in the center of the monitor. This form has an extra border around it.

Windows Default

Places the form in the upper left quadrant of the monitor with an extra border around it.


Start With Full Compile (Run Menu)

Performs a full compile on the project.

The application is fully compiled before starting, regardless of the current setting of the Compile on Demand and Background Compile options on the General tab of the Options dialog box. Choosing Start With Full Compile does not alter the Compile on Demand or Background compile settings.

Use Start With Full Compile to start ActiveX server projects. Starting an ActiveX server project with the Start command when Compile on Demand checked may result in compile-time errors being detected after you have test applications running. If correcting an error requires restarting the ActiveX server, your test applications may be left holding invalid object references.

This command is available only at design time.

Keyboard shortcut: CTRL+F5.


Step Into, Step Over, Step Out Commands (Debug Menu)

Step Into, Step Over, and Step Out Commands (Debug Menu)

Step Into

Executes code one statement at a time.

Step Into executes the statement at the current execution point. If the statement is a call to a procedure, the next statement displayed is the first statement in the procedure.

At design time, this menu item begins execution and enters break mode before the first line of code is executed. Not available at run time.

Toolbar button: . Keyboard shortcut: F8.

Step Over

Similar to Step Into. The difference in use occurs when the current statement contains a call to a procedure.

Step Over executes the procedure as a unit, and then steps to the next statement in the current procedure. Therefore, the next statement displayed is the next statement in the current procedure regardless of whether the current statement is a call to another procedure. Available in break mode only.

Toolbar button: . Keyboard shortcut: SHIFT+F8.

Step Out

Executes the remaining lines of a function in which the current execution point lies. The next statement displayed is the statement following the procedure call. All of the code is executed between the current and the final execution points. Available in break mode only.

Toolbar button: . Keyboard shortcut: CTRL+SHIFT+F8.


Toggle Breakpoint Command (Debug Menu)

Sets or removes a breakpoint at the current line. You can't set a breakpoint on lines containing nonexecutable code such as comments, declaration statements, or blank lines.

A line of code in which a breakpoint is set appears in the colors specified in the Editor Format tab of the Options dialog box.

Not available at run time.

Toolbar shortcut: . Keyboard shortcut: F9.


Toolbars Command (View Menu)

Displays a submenu with a list of the toolbars – Debug, Edit, Form Editor, Standard, any custom toolbars and the Customize command. You can choose a toolbar or use the Customize command to modify or create your own toolbar or menu.


Toolbox Command (View Menu)

Displays or hides the Toolbox, which contains the controls and insertable objects (such as a Microsoft Excel Chart) currently available to your application. Available only at design time.

Toolbar shortcut: .


T-SQL Debugging Options Command (Tools Menu)

Displays the T-SQL Debugging Options dialog box so you can customize the T-SQL debugger.


Redo, Undo Commands (Edit Menu)

Redo and Undo Commands (Edit Menu)

Undo

Reverses the last editing action, such as typing text in the Code window or deleting controls. When you delete one or more controls, you can use the Undo command to restore the controls and all their properties. For forms, Undo is unavailable if the form has been edited since the last control deletion.

Toolbar shortcut [image]. Keyboard shortcuts: CTRL+Z or ALT+BACKSPACE.

Note You can't undo a Cut operation using the Undo command.

Redo

Restores the last text editing if no other actions have occurred since the last Undo.

Toolbar shortcut [image].

For text edits, you can use Undo and Redo to restore up to twenty edits.

These commands are unavailable at runtime, or if there was no previous edit, or if any other action has been performed after the last edit. Also, some large edits may cause low memory conditions that could prevent an Undo action.


Update User Controls Command (Shortcut Menu)

Updates the user controls on your form. Use this command to make sure that the changes you make to your user controls are reflected on the forms using them.

Using the Update User Controls command closes and re-opens the form.


Vertical Spacing Commands (Format Menu)

Changes the vertical space between the selected objects, based on the object with focus. When an object has focus, black handles appear on its borders.

Make Equal

Moves the selected objects so that there is equal space between them using the top and bottom objects as the endpoints.

Toolbar shortcut: .

Increase

Increases the vertical spacing by one grid based on the object with focus. You can change the size of your grid units in the General tab of the Options dialog box.

Toolbar shortcut: .

Decrease

Decreases the vertical spacing by one grid based on the object with focus. You can change the size of your grid units in the General tab of the Options dialog box.

Toolbar shortcut: .

Remove

Removes the vertical spacing so that the object’s borders are touching, based on the object with focus

Toolbar shortcut: .

Note The object with focus does not move but the other objects move around it.

Note If using the Vertical Spacing command does not produce the results you want, try to manually rearrange some of the objects and repeat the command. Also, try the using the Horizontal Spacing command.


View Code Command (Webclass Shortcut Menu)

Opens the Code window and displays the event procedure for the selected item. If that item is a template file or custom webitem, the Code window shows the default event for the item.


Visual Data Manager Command (Add-Ins Menu)

Opens the Visual Data Manager application so you can access and manage data.


Watch Window Command (View Menu)

Displays the Watch window and displays the current watch expressions. The Watch window appears automatically if watch expressions are defined in the project.

If the context of the expression isn’t in scope when going to break mode, the current value isn’t displayed.

Toolbar shortcut: .


Window Menu Commands

Split

Toggles splitting the Code window in half horizontally. Only available when the Code window is active.

Toolbar shortcut: .

Tile Horizontally

Tiles the Object and Code windows and the Object Browser horizontally when you are in MDI mode.

Toolbar shortcut: .

Tile Vertically

Tiles the Object and Code windows and the Object Browser vertically when you are in MDI mode.

Toolbar shortcut: .

Cascade

Rearranges the Object and Code windows and the Object Browser in your project so they overlap in a cascade. Available only in MDI mode.

Toolbar shortcut: .

Arrange Icons

Arranges the icons of the windows you have minimized, neatly at the bottom left of the window.

Window List

Lists all open form windows.


BindingCollection Object

A collection of Binding objects.

Syntax

BindingCollection

Remarks

The BindingCollection object allows you to bind any data provider to any data consumer. To bind a consumer to data provider, use the Add method to add a Binding object to the collection. Each Binding object represents the binding of a specific consumer to the DataSource supplied by the BindingCollection object.

Data sources that have no design time interface, such as a Class configured as a data source (by setting its DataSourceBehavior property to VbDataSource) or an ADO Recordset can be bound at run time using the BindingObject collection.

Use standard collection syntax to return or set properties of the members of the collection.


Binding Object, BindingCollection Object Example

The example uses the BindingCollection object to bind a data source to two TextBox controls. The example first opens an ADODB recordset object, then sets the DataSource property of the BindingCollection to the recordset. The code then adds two Binding objects to the collection, thereby binding two TextBox controls to different fields of the recordset.

To try the example, in the References dialog box set a reference to the Microsoft Data Binding Collection. In the same dialog box, set a reference to the Microsoft ActiveX Data Objects Library. Draw two TextBox controls on a Form, and paste the code into the Declarations section. Press F5, and click the form to advance through the recordset.

Option Explicit
Private colBndNwind As New BindingCollection
Private rsNwind As New ADODB.Recordset
Private cn As New ADODB.Connection

Private Sub Form_Load()

   ' Set the Connection object parameters.
   With cn
      ' The following connection may or may not work on your computer.
      ' Alter it to find the Nwind.mdb file, which is included with
      ' Visual Basic.
      .Provider = "Microsoft.Jet.OLEDB.3.51"
      .Open "C:\Program Files\DevStudio\VB\Nwind.mdb"
   End With

   ' Open the recordset object.
   rsNwind.Open "Select * From Products", cn

   ' Set the DataSource of the Bindings collection to the recordset.
   Set colBndNwind.DataSource = rsNwind

   ' Add to the Bindings collection.
   With colBndNwind
      .Add Text1, "Text", "ProductName", , "product"
      .Add Text2, "Text", "SupplierID", , "ID"
   End With

   ' Print the properties of the objects in the collection.
   Dim bndObj As Binding
   For Each bndObj In colBndNwind
      Debug.Print "DataField", "PropertyName", "Key"
      Debug.Print bndObj.DataField, bndObj.PropertyName, bndObj.Key
      Debug.Print
   Next
End Sub

Private Sub Form_Click()
   ' Move to the next record by clicking the form.
   rsNwind.MoveNext
End Sub


ContainedControls Collection

A collection that allows access to the controls contained within a control that were added by the developer who uses the control.

Syntax

ContainedControls(index)

The placeholder index represents an integer with a range from 0 to ContainedControls.Count - 1.


ContainedVBControls Collection

The ContainedVBControls collection represents a collection of VBControl objects.


DataMembers Collection

A collection of data members for a data source.

Syntax

DataMembers

Remarks

A data provider can have multiple sets of data that a data consumer can choose to bind to. Each set of data is called a "data member," and be either an ADO Recordset, a Class that implements the OLE Simple Provider (OSP) interface, or an OLEDB Provider created with Visual Basic. In any case, an arbitrary but unique string can be associated with the data member, and it is this identifying string that is added to the DataMembers collection using the Add method.

When configuring a data consumer to use a complex data source, you must set both the DataSource and the DataMember properties to fully qualify the data source. For example, if you configure a TextBox control to use the Data Environment as a data source, you must set its DataSource property to the Data Environment, and its DataMember property to a specific Command object. Conversely, when you create your own complex data source, the DataMembers collection allows your data source to serve multiple data sets to any data consumer.

For example, you can create a User Control configured as a data source by setting its DataSourceBehavior to vbDataSource. In the Initialize event, use the Add method to add the identifying strings of each data member to the DataMembers collection. Consequently, when the end user sets the DataSource property to your user control, and clicks DataMembers on the Properties window, those members added to the DataMembers collection will appear in the drop-down list.

Similarly, when creating a Class configured as a data source, in the Initialize event, invoke the Add method to add the identifying strings to the DataMembers collection. Then, to configure a data consumer to use the class, set its DataSource property to the class and its DataMember property to a member of the DataMembers collection.

When a data consumer's DataSource property is set to a class or User control configured as a data source, the GetDataMember event occurs. The event contains an argument, the DataMember argument, that passes the value of the DataMember property. The event also features an argument, the Data argument, that you can use to return the data to the consumer. In other words, in the GetDataMember event, query the DataMember value to determine which data member has been requested, and set the event's Data argument to the requested data source (i.e. an ADO Recordset, OLEDB provider, or class implementing the OSP interface).

A data member can also be an empty string. When programming the GetDataMember event, be sure handle this possibility by setting a default data member.


DataObjectFiles Collection

A collection of strings which is the type of the Files property on the DataObject object.

Syntax

object.DataObjectFiles

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The DataObjectFiles collection is a collection of strings which represent a set of files which have been selected either through the GetData method, or through selection in an application such as the Windows Explorer.

Although the DataObjectFiles collection has methods and properties of its own, you should use the Files property of the DataObject object to view and manipulate the contents of the DataObjectFiles collection.

Here are some code examples showing the use of the Files property to view and manipulate data contained in the DataObjectFiles collection (where "Data" represents an object of type DataObject):

Debug.Print Data.Files(index)
For Each v in Data.Files
 Debug.Print v
Next v
Data.Files.Add "autoexec.bat"
Data.Files.Remove index
Data.Files.Clear
For i = 1 to Data.Files.Count
 Debug.print Data.Files(i)
Next i

Note This collection is used by the Files property only when the data in the DataObject object is in the vbCFFiles format.


DEAggregates Collection

A collection whose elements represent each DEAggregate object within the DECommand object.

Note This collection's Count property specifies the number of DEAggregate objects that exist in the collection.

Syntax

DEAggregates(index)

The index placeholder represents an integer with a range from 1 to DEAggregates.Count.

Remarks

Use the following code to access the members of the DEAggregates collection by their individual names.

MyDEExt.DEAggregates("SumOrders").Name


DECommands Collection

A collection whose elements represent each DECommand object within a DataEnvironment object.

Note This collection's Count property specifies the number of DECommand objects that exist in the collection.

Syntax

DECommands(index)

The index placeholder represents an integer with a range from 1 to DECommands.Count.

Remarks

This collection is used in the Data Environment Extensibility Object Model and is different from the Commands collection used at run time.

Use the following code to access members of the DECommands collection by their individual names.

DEExtObj.DECommands("Command1").Name


DEConnections Collection

A collection whose elements represent each DEConnection object within a DataEnvironment object.

Note This collection's Count property specifies the number of DEConnection objects in the collection.

Syntax

DEConnections(index)

The index placeholder represents an integer with a range from 1 to DEConnections.Count.

Remarks

The DEConnections collection is used in the Data Environment Extensibility Object Model and is different from the Connections collection used at run time.

Use the following code to access members of the DEConnections collection by their individual names.

DEExtObj.DEConnections("Connection1").Name


DEFields Collection

A collection whose elements represent each DEField object within the DECommand object.

Note This collection's Count property specifies the number of DEField objects in the collection.

Syntax

DEFields(index)

The index placeholder represents an integer with a range from 1 to DEFields.Count.

Remarks

The DEFields collection is used in the Data Environment Extensibility Object Model and is different from the Fields collection used at run time.

Insert the following code to access members of the DEFields collection by their individual names.

DEExt.DECommands("CustID").DEFields("CustID")


DEGroupingFields Collection

A collection whose elements represent each DEGroupingField object within the DECommand object.

Note This collection's Count property specifies the number of DEGroupingField objects in the collection.

Syntax

DEGroupingFields(index)

The index placeholder represents an integer with a range from 1 to DEGroupingFields.Count.

Remarks

The DEGroupingFields collection is used to specify the DEField objects by which the DECommand is grouped.

Insert the following code to access members of the DEGroupingFields collection by their individual names.

DEExt.DECommands("CustID").DEGroupingFields("CustID")


DEParameters Collection

A collection whose elements represent each DEParameter object within the DECommand object.

Note This collection's Count property specifies the number of DEParameter objects in the collection.

Syntax

DEParameters(index)

The index placeholder represents an integer with a range from 1 to DEParameters.Count.

Remarks

The DEParameters collection is used in the Data Environment Extensibility Object Model and is different from the Parameters collection used at run time.

Use the following code to access members of the DEParameters collection by their individual names.

DEExt.DECommands("Param1").DEParameters("Param1").Name


DERelationConditions Collection

A collection whose elements represent each DERelationCondition object within the DECommand object.

Note This collection's Count property specifies the number of DERelationCondition objects in the collection.

Syntax

DERelationConditions(index)

The placeholder index represents an integer with a range from 1 to DERelationConditions.Count.

Remarks

Insert the following code to access members of the DERelationConditions collection by their individual names.

DEExt.DECommands("Relation1")DERelationConditions("Relation1").Name


ExportFormats Collection

A collection of ExportFormat objects.

Syntax

ExportFormats

Remarks

Use the ExportFormat object in conjunction with the ExportReport method to create customized exported reports. When invoking the ExportReport method, specify which ExportFormat object to use, as shown below:

' Use the ExportFormat object named MyReport.
DataReport1.ExportReport "MyReport"

Each object in the collection can represent a different template. To create a template use the Template property.

When the end user invokes the ExportReport method, the FileFormatString property determines what text is displayed in the Save As Type box.


Licenses Collection

A collection of LicenseInfo objects that contain license key information required when adding a licensed control to the Controls collection.

Syntax

Licenses

Remarks

If a user control requires a license key, you must add the key to the Licenses collection before you add the control.


EventParameters Collection

A collection of EventParameter objects.

Syntax

EventParameters

Remarks

Use the EventParameters collection to determine what values have been assigned to any parameters in an event raised by a control.


ParentControls Collection

A collection that allows access to controls in another control's container.

Syntax

ParentControls(index)

The placeholder index represents an integer with a range from 0 to ParentControls.Count - 1.


Sections Collection (Data Report Designer)

A collection of Section objects.

Syntax

Sections

Remarks

You must use standard collection syntax to retrieve a reference to a Section object and any controls on the Data Report designer.


Sections Collection Example

The example prints the name of each Section object in the Data Report designer as well as the names of each control in the section. To try the example, create a Data Report. Place a CommandButton control on a form, and paste the code into the Declarations section of the code module. Press F5 to run the project and click the button.

Private Sub Command1_Click()
   Dim sect, ctl
   For Each sect In DataReport1.Sections
      Debug.Print "Section", sect.Name
      For Each ctl In sect.Controls
         Debug.Print , ctl.Name
      Next ctl
   Next sect
End Sub


SelectedControls Collection

A collection that allows access to all of the currently selected controls on an object.

Syntax

SelectedControls(index)

The placeholder index represents an integer with a range from 0 to SelectedControls.Count - 1.


Command Line Arguments

Determines whether Visual Basic complies and runs a program, compiles and makes an executable (.exe) file or ActiveX DLL (.dll), or sets the argument part of the command line returned by the Command function.

Syntax

vb5[.exe] [[{/run | /r} projectname] [[{/d compileconst}] {/make | /m } projectname] [{/makedll | /l} projectname] {/cmd argument | /c argument}][{/runexit} projectname][{/m} or {/runexit} projectname /out filename}][{/m}][/sdi] or [/mdi]

The parts of the command line switch syntax are:

Argument | Description
projectname | The name of your project (.vbp) file.
/run or /r | Tells Visual Basic to compile and run projectname using the arguments stored in the Command Line Arguments field of the Make tab of the Project Properties dialog box. You can run more than one project using this command. Replace projectname with projectgroupname.
/make or /m | Tells Visual Basic to compile projectname and make an executable (.exe) file, using the existing settings of the Path, EXEName, and Title properties of the APP object. You can compile and make an executable (.exe) file from more than one project using this command. Replace of the projectname with projectgroupname.
/makedll or /l | Tells Visual Basic to compile projectname and make an in-process ActiveX server (.dll) file from it.
/d or /D | Tells Visual Basic which values to use for conditional compilation constants when making an .EXE with the /make switch or an ActiveX DLL with the /makedll switch.
compileconst | The names and values of conditional compilation constants used in the project file.
/cmd or /c | Puts argument in the Command Line Arguments field in the Make tab of the Project Properties dialog box. When used, this must be the last switch on the command line.
/runexit | Tells Visual Basic to run projectname. If for any reason the file is changed in the process of running, all changes are ignored and no dialog appears on exit to design mode.
filename | The name of the file to receive errors when you build an executable using the /m or /runexit option.
/out | Allows you to specify a file to receive errors when you build using the /m or /runexit option. The first error encountered is placed in this file with other status information. If you do not use the /out option, command line build errors are displayed in a message box. This option is useful if you are building multiple projects.
/? Lists the available Command Line arguments.
/sdi | Changes the Visual Basic environment to SDI (Single Document Interface) mode. Visual Basic remains in SDI mode until you change it. You can change to MDI mode by using the /mdi argument or by clearing the SDI Development Environment option in the Advanced tab of the Options dialog box.
/mdi | Opens Visual Basic in MDI (Multiple Document Interface) mode. Visual Basic remains in MDI mode until you change it. You can change to SDI mode by using the /sdi argument or by selecting the SDI Development Environment option in the Advanced tab of the Options dialog box. MDI mode is the default.

When used, these arguments must be in a command line to run Visual Basic. For example, you might use them in the Run dialog box from the Run command of the Windows 95 Start Menu. Here is a valid command line that runs Visual Basic, loads a specific project, and runs it:

C:\vb5.exe /r MyProj.vbp


CtlsAdd (CtlCfg.vbp and CtlView.vbp)

The two sample applications work together to demonstrate dynamic control addition, or the Add Method for the Controls collection. The first sample, CtlCfg.vbp, adds control license keys to the Controls.mdb database using the Licenses.Add method. The second sample, CtlView, uses the information (license keys) stored in the database to dynamically load controls.

File | Description
Controls.mdb | Access database that holds license key information.
CtlCfg.frm | Control configuration form.
CtlCfg.frx | Control configuration binary data.
CtlCfg.vbp | Control configuration project file.
CtlView.frm | Control view form.
CtlView.frx | Control view binary data.
CtlView.vbp | Control view project file.

To Run

First open and run the CtlCfg.vbp project. If you have any user controls (that require license keys), you can add the keys to the database using the application.

To Add A Control's License Key

  1. Open a second instance of Visual Basic.

  2. Add a user control (that requires a license key) to the Toolbox using the Components dialog box.

  3. Press F2 to display the Object Browser.

  4. In the Object Browser, note the Library and Class name of the control. This is the progID of the control.

  5. Switch to the CtlCfg application.

  6. On the Edit menu, click New Entry.

  7. In the new row, fill in the Description column.

  8. In the ControlType column, type the progID of the user control.

  9. If there is a property of the control you would like to set, type the property name in the PropertyName column. Then type an appropriate value in the PropertyValue column.

  10. In the ControlHeight and ControlWidth columns, type in (optional) values.

  11. On the File menu, click Save. The control's license (if it has one) will appear in the ControlLicense column.

  12. Close the application.

Open and run the CtlView.vbp project. A grid on the form displays the names of controls that can be dynamically added. Click the control name to add it to the form.


Data Report (DataRept)

The Data Report sample demonstrates the functionality in the Data Report designer. Using a Data Environment as a data source, the application displays a hierarchical report of customers and their orders. The report further uses the Grouping feature of the Data Environment to group the companies by country.

File | Description
deNwind.Dsr | Data Environment designer file.
frmShowReport.frm | Main project form.
prjNwind.vbp | Project file.
rptNwind.Dsr | Data Report designer file.
rptNwind.dsx | Binary data for the designer file.

To Run

The Data Report uses the Northwind database (Nwind.mdb). The Data Environment is configured to access the database from its default location when installed from the Visual Studio CD. If Nwind.mdb is moved, you must change the ConnectionString property of the Data Environment's Connection.

To change the ConnectionString

  1. Open the Data Environment designer.

  2. Right click the deNwind icon to display, and click Connections to display the deNwind Properties dialog box.

  3. Next to the ConnectionString box, click Build.

  4. Click the Data Source box, and type the full path to the new location of the Nwind.mdb file.

  5. Click Test Connection. If the connection passes, the path is correct.

Once the ConnectionString property is correct, run the project. On the form, click the Show Report button to display the data report.

Click the Export Report button to export the report to an HTML file.

Click the Templates button to print (to the Immediate window) the templates contained by the designer.


Message Queue

The work-flow sample consists of a system simulating a simplified 'insurance claim processing' system. Claims are entered using a Visual Basic front end. When submitted, these claims are placed in a 'insurance claims queue.' A second Visual Basic application allows an 'insurance claims processor' to approve the claims. Once approved, the claims are moved to a second 'accounting queue.' A third Visual Basic application is used to process the claims in the accounting queue. When these are approved the messages are removed from the second queue and the work-flow is complete.

File | Description
Accounting_Step3.vbp | Allows the processing of claims from the second queue (finishes the work-flow).
Administer_Step0.vbp | Sets up the queues for the sample. Allows the viewing of queue contents.
ClaimEntry_Step1.vbp | Allows the submission of claims (starts the work-flow)
clsStringBag.cls | Class module for PropertyBag strings.
frmAdminister.frm | Form to create a new queue.
frmClaimProcessing.frm | Opens a "claims" message queue.
frmProcessClaim.frm | Submits a claim.
frmQueueMonitoring.frm | Message monitoring form.
fromAdminTitleScreen.frm | Show other forms.
MessageArrival.cls | Monitors message arrivals.
modInsuranceMQ.bas | Global constants.
modQueueSupport.bas | Contains functions useful for message queues. These functions are intended to be called from applications to create, destroy, manage, and access queues.
modQueueSupportHelper.bas | Contains HELPER functions useful for message queue access.
Processing_Step2.vbp | Allows the processing of claims from the first queue and moves them to the second queue.

To Run

See the Readme.htm file for details on running the sample.


Using Add-In Designer

Use the Add-In Designer to begin the development process for an add-in by setting the properties that determine load behavior, name, description, target application and version. The designer contributes code to the add-in's dll or exe file to register the add-in correctly for the target application.

Initializing a new add-in

  1. Create an Add-In project by selecting New Project from the File menu and then AddIn in the New Project dialog box.

  2. On the General tab enter basic information about the add-in like description, load behavior, and indicate which applications host the add-in.

  3. Select the Advanced tab to enter additional information on localization resources, and registry settings.

  4. To add code to your add-in, double-click the Add-In Designer.

  5. To build your add-in, select Make exe or Make dll from the File menu.


Add-In Constants

Code Pane View

Constant | Value | Description
vbext_cv_ProcedureView | 0 | Displays the code pane in Procedure-level view.
vbext_cv_FullModuleView | 1 | Displays the code pane in full module view (all modules displayed).

Component Types

Constant | Value | Description
vbext_ct_StdModule | 1 | The component is a standard module.
vbext_ct_ClassModule | 2 | The component is a class module.
vbext_ct_MSForm | 3 | The component is a form.
vbext_ct_ResFile | 4 | The component is a standard resource file.
vbext_ct_VBForm | 5 | The component is a Visual Basic form.
vbext_ct_VBMDIForm | 6 | The component is an MDI form.
vbext_ct_PropPage | 7 | The component is a property page.
vbext_ct_UserControl | 8 | The component is a user control.
vbext_ct_DocObject | 9 | The component is a user form.
vbext_ct_RelatedDocument | 10 | The component is a RelatedDocument.
vbext_ct_ActiveXDesigner | 11 | The component is an ActiveX designer.

Connection Mode

Constant | Value | Description
vbext_cm_AfterStartup | 0 | Add-in is connected after IDE startup.
vbext_cm_Startup | 1 | Add-in is connected on IDE startup.
vbext_cm_External | 2 | Add-in is connected externally.

Control Type

Constant | Value | Description
vbext_ct_Light | 1 | Light-weight control.
vbext_ct_Standard | 2 | Standard control.
vbext_ct_Container | 3 | Container control.

Disconnection Mode

Constant | Value | Description
vbext_dm_HostShutDown | 0 | Add-in is disconnected when the host shuts down.
vbext_dm_UserClosed | 1 | Add-in is disconnected by the user.

File Type

Constant | Value | Description
vbext_ft_Form | 0 | The file is of type Form.
vbext_ft_Module | 1 | The file is of type Module.
vbext_ft_Class | 2 | The file is of type Class.
vbext_ft_Project | 3 | The file is of type Project.
vbext_ft_Exe | 4 | The file is of type Exe.
vbext_ft_Frx | 5 | The file is of type Frx.
vbext_ft_Res | 6 | The file is of type Res.
vbext_ft_UserControl | 7 | The file is of type User Control.
vbext_ft_PropertyPage | 8 | The file is of type Property Page.
vbext_ft_DocObject | 9 | The file is of type User Document.
vbext_ft_Binary | 10 | The file is of type Binary.
vbext_ft_GroupProject | 11 | The file is of type Group Project.
vbext_ft_Designers | 12 | The file is of type Designers.

Member Type

Constant | Value | Description
vbext_mt_Method | 1 | The member is of type Method.
vbext_mt_Property | 2 | The member is of type Property.
vbext_mt_Variable | 3 | The member is of type Variable.
vbext_mt_Event | 4 | The member is of type Event.
vbext_mt_Const | 5 | The member is of type Constant.

Procedure Type

Constant | Value | Description
vbext_pk_Proc | 0 | Specifies all procedures other than property procedures.
vbext_pk_Let | 1 | Specifies a procedure that assigns a value to a property.
vbext_pk_Set | 2 | Specifies a procedure that assigns a reference to a property.
vbext_pk_Get | 3 | Specifies a procedure that returns the value to a property.

Project Start Mode

Constant | Value | Description
vbext_psm_StandAlone | 0 | Startup mode is standalone.
vbext_psm_OleServer | 1 | Startup mode is ActiveX component.

Project Type

Constant | Value | Description
vbext_pt_StandardExe | 0 | Project is a standard .exe project.
vbext_pt_ActiveXExe | 1 | Project is an ActiveX .exe project.
vbext_pt_ActiveXDll | 2 | Project is an ActiveX .dll project.
vbext_pt_ActiveXControl | 3 | Project is an ActiveX control project.

Reference Type

Constant | Value | Description
vbext_rk_TypeLib | 0 | Represents a reference to a type library.
vbext_rk_Project | 1 | Represents a reference to a project.

Scope

Constant | Value | Description
vbext_Private | 1 | Member has private scope.
vbext_Public | 2 | Member has public scope.
vbext_Friend | 3 | Member has friend scope.

Startup Object

Constant | Value | Description
vbext_so_SubMain | 0 | Startup object is sub Main.
vbext_so_None | 1 | There is no startup object.

VBA Display Model

Constant | Value | Description
vbext_dm_SDI | 0 | Display mode is single document interface.
vbext_dm_MDI | 1 | Display mode is multiple document interface.

VBA Mode

Constant | Value | Description
vbext_vm_Run | 0 | Project is in Run mode.
vbext_vm_Break | 1 | Project is in Break mode.
vbext_vm_Design | 2 | Project is in Design mode.

Window State

Constant | Value | Description
vbext_ws_Normal | 0 | Window is normal.
vbext_ws_Minimize | 1 | Window is minimized (to an icon).
vbext_ws_Maximize | 2 | Window is maximized (largest size).

File Type

Constant | Value | Description
vbext_wt_CodeWindow | 0 | Window is a code window.
vbext_wt_Designer | 1 | Window is a designer window.
vbext_wt_Browser | 2 | Window is a browser window.
vbext_wt_Watch | 3 | Window is a watch window.
vbext_wt_Locals | 4 | Window is a locals window.
vbext_wt_Immediate | 5 | Window is an immediate window.
vbext_wt_ProjectWindow | 6 | Window is a project window.
vbext_wt_PropertyWindow | 7 | Window is a property window.
vbext_wt_Find | 8 | Window is a find window.
vbext_wt_FindReplace | 9 | Window is a find & replace window.
vbext_wt_ToolBox | 10 | Window is a toolbox window.
vbext_wt_LinkedWindowFrame | 11 | Window is a linkedwindowframe window.
vbext_wt_MainWindow | 12 | Window is a main window.
vbext_wt_Preview | 13 | Window is a preview window.
vbext_wt_ColorPalette | 14 | Window is a color palette window.
vbext_wt_ToolWindow | 15 | Window is a tool window.

Menu Shortcuts

Constant | Value | Description
vbextMenuShortcutCtrlA | 1 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlB | 2 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlC | 3 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlD | 4 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlE | 5 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF | 6 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlG | 7 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlH | 8 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlI | 9 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlJ | 10 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlK | 11 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlL | 12 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlM | 13 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlN | 14 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlO | 15 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlP | 16 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlQ | 17 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlR | 18 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlS | 19 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlT | 20 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlU | 21 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlV | 22 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlW | 23 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlX | 24 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlY | 25 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlZ | 26 | User-defined shortcut keystrokes.
vbextMenuShortcutF1 | 27 | User-defined shortcut keystrokes.
vbextMenuShortcutF2 | 28 | User-defined shortcut keystrokes.
vbextMenuShortcutF3 | 29 | User-defined shortcut keystrokes.
vbextMenuShortcutF4 | 30 | User-defined shortcut keystrokes.
vbextMenuShortcutF5 | 31 | User-defined shortcut keystrokes.
vbextMenuShortcutF6 | 32 | User-defined shortcut keystrokes.
vbextMenuShortcutF7 | 33 | User-defined shortcut keystrokes.
vbextMenuShortcutF8 | 34 | User-defined shortcut keystrokes.
vbextMenuShortcutF9 | 35 | User-defined shortcut keystrokes.
vbextMenuShortcutF10 | 36 | User-defined shortcut keystrokes.
vbextMenuShortcutF11 | 37 | User-defined shortcut keystrokes.
vbextMenuShortcutF12 | 38 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF1 | 39 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF2 | 40 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF3 | 41 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF4 | 42 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF5 | 43 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF6 | 44 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF7 | 45 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF8 | 46 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF9 | 47 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF10 | 48 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF11 | 49 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlF12 | 50 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF1 | 51 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF2 | 52 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF3 | 53 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF4 | 54 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF5 | 55 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF6 | 56 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF7 | 57 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF8 | 58 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF9 | 59 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF10 | 60 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF11 | 61 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftF12 | 62 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF1 | 63 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF2 | 64 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF3 | 65 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF4 | 66 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF5 | 67 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF6 | 68 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF7 | 69 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF8 | 70 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF9 | 71 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF10 | 72 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF11 | 73 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlShiftF12 | 74 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlIns | 75 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftIns | 76 | User-defined shortcut keystrokes.
vbextMenuShortcutCtrlDel | 77 | User-defined shortcut keystrokes.
vbextMenuShortcutShiftDel | 78 | User-defined shortcut keystrokes.
vbextMenuShortcutAltBksp | 79 | User-defined shortcut keystrokes.

Source Code Control Status

Constant | Value | Description
vbextSCCStatusNotControlled | 0 | File isn't under source code control.
vbextSCCStatusControlled | 1 | File is under source code control.
vbextSCCStatusCheckedOut | 2 | File is checked out to the current user.
vbextSCCStatusOutOther | 3 | File is checked out to another user.
vbextSCCStatusOutOfDate | 32 | File isn't the most recent.
vbextSCCStatusShared | 512 | File is shared between projects.


Asynchronous Constants

AsyncType

Constant | Value | Description
vbAsyncTypePicture | 0 | The data is provided in a Picture object.
vbAsyncTypeFile | 1 | The data is provided in a file that is created by Visual Basic.
vbAsyncTypeByteArray | 2 | The data is provided as a byte array that contains the retrieved data. It is assumed that the control author will know how to handle the data.

AsyncStatusCode

Constant | Value | Description
vbAsyncStatusCodeError | 0 | An error occurred during the asynchronous download.
vbAsyncStatusCodeFindingResource | 1 | AsyncRead is finding the resource specified in AsyncProperty.Status that holds the storage being downloaded.
vbAsyncStatusCodeConnecting | 2 | AsyncRead is connecting to the resource specified in AsyncProperty.Status that holds the storage being downloaded.
vbAsyncStatusCodeRedirecting | 3 | AsyncRead has been redirected to a different location specified in AsyncRead.Property.Status.
vbAsyncStatusCodeBeginDownloadData | 4 | AsyncRead has begun receiving data for the storage specified in AsyncProperty.Status.
vbAsyncStatusCodeDownloadingData | 5 | AsyncRead has received more data for the storage specified in AsyncProperty.Status.
vbAsyncStatusCodeEndDownloadData | 6 | AsyncRead has finished receiving data for the storage specified in AsyncProperty.Status.
vbAsyncStatusCodeUsingCashedCopy | 10 | AsyncRead is retrieving the requested storage from a cached copy. AsyncProperty.Status is empty.
vbAsyncStatusCodeSendingRequest | 11 | AsyncRead is requesting the storage specified in AsyncProperty.Status.
vbAsybcStatusCodeMIMETypeAvailable | 13 | The MIME type of the requested storage is specified in AsyncProperty.Status.
vbAsyncStatusCodeCacheFileNameAvailable | 14 | The filename of the local file cache for requested storage is specified in AsyncProperty.Status.
vbAsyncStatusCodeBeginSyncOperation | 15 | The AsyncRead will operate synchronously.
vbAsyncstatusCodeEndSyncOperation | 16 | The AsyncRead has completed synchronous operation.


Button Constants

The Style property settings for the Checkbox, CommandButton, and OptionButton controls are:

Constant | Value | Description
vbButtonStandard | 0 | (Default) Standard. The control displays as it did in previous versions of Visual Basic. That is, a Checkbox control displays as a checkbox with a label next to it, an OptionButton as an option button with a label next to it, and a CommandButton as standard CommandButton without an associated graphic.
vbButtonGraphical | 1 | Graphical. The control displays in a graphical style. That is, a Checkbox control displays as a CommandButton-like button which can be toggled either up or down, an OptionButton displays as a CommandButton-like button which remains toggled up or down until another OptionButton in its option group is selected, and a CommandButton displays as a standard CommandButton that can also display an associated graphic.


ComboBox Constants

The Style property settings for the ComboBox control are:

Constant | Value | Description
vbComboDropDown | 0 | (Default) Dropdown Combo. Includes a drop-down list and a text box. The user can select from the list or type in the text box.
vbComboSimple | 1 | Simple Combo. Includes a text box and a list, which doesn't drop down. The user can select from the list or type in the text box. The size of a Simple combo box includes both the edit and list portions. By default, a Simple combo box is sized so that none of the list is displayed. Increase the Height property to display more of the list.
vbComboDrop-DownList | 2 | Dropdown List. This style allows selection only from the drop-down list.


Data Control Constants

Error Event Constants

Constant | Value | Description
vbDataErrContinue | 0 | Continue
vbDataErrDisplay | 1 | (Default) Display the error message

Validate Event Action Constants

Constant | Value | Description
vbDataActionCancel | 0 | Cancel the operation when the Sub exits
vbDataActionMoveFirst | 1 | MoveFirst method
vbDataActionMovePrevious | 2 | MovePrevious method
vbDataActionMoveNext | 3 | MoveNext method
vbDataActionMoveLast | 4 | MoveLast method
vbDataActionAddNew | 5 | AddNew method
vbDataActionUpdate | 6 | Update operation (not UpdateRecord)
vbDataActionDelete | 7 | Delete method
vbDataActionFind | 8 | Find method
vbDataActionBookmark | 9 | The Bookmark property is set
vbDataActionClose | 10 | Close method
vbDataActionUnload | 11 | The form is being unloaded

Beginning-Of-File Action Constants

Constant | Value | Description
vbMoveFirst | 0 | Move to first record
vbBOF | 1 | Move to beginning of file

End-Of-File Action Constants

Constant | Value | Description
vbMoveLast | 0 | Move to last record
vbEOF | 1 | Move to end of file
vbAddNew | 2 | Add new record to end of file

Recordset-Type Constants

Constant | Value | Description
vbRSTypeTable | 0 | Table-type recordset
vbRSTypeDynaset | 1 | Dynaset-type recordset
vbRSTypeSnapShot | 2 | Snapshot-type recordset


Data Report Designer Constants

Alignment Constants

Constant | Value | Description
rptJustifyLeft | 0 | The text is aligned left.
rptJustifyRight | 1 | The text is aligned right.
rptJustifyCenter | 2 | The text is centered.

AsyncType Constants

Constant | Value | Description
rptAsyncPreview | 0 | Preview mode. Occurs after invoking the Show method.
rptAsyncPrint | 1 | Indicates a job has been sent to the printer.
rptAsyncExport | 2 | Indicates a file is being exported.

BackStyle Constants

Constant | Value | Description
rptBkTransparent | 0 | The control is transparent.
rptBkOpaque | 1 | The control is opaque.

BorderStyle Constants

Constant | Value | Description
rptBSTransparent | 0 | The border is transparent.
rptBSSolid | 1 | The border is solid.
rptBSDashes | 2 | The border consists of dashes.
rptBSDots | 3 | The border consists of dots.
rptBSDashDot | 4 | The border consists of dashes and dots.
rptBSDashDotDot | 5 | The border consists of a dash followed by two dots.

Error Constants

Constant | Value | Description
rptErrAccessDenied | 8513 (&H2141) | Access denied.
rptErrBoundCtlNotAllowed | 8551 (&H2167) | The control can't be placed in this section.
rptErrChapterInit | 8521 (&H2149) | Unable to initialize the chapter.
rptErrCollectionIsEmpty | 8573 (&H217D) | The collection is empty.
rptErrCreatingFont | 8556 (&H216C) | An error occurred creating the font.
rptErrCreatingWindow | 8572 (&H217C) | An error occurred creating the window.
rptErrDuplicateKey | 8500 (&H2134) | There is a duplicate key value in the collection.
rptErrExportFormatsEmpty | 8506 (&H213A) | The ExportFormats collection is empty.
rptErrFileAlreadyExists | 8512 (&H2140) | The file already exists.
rptErrGeneralFileIO | 8510 (&H213E) | File I/O error.
rptErrInvalidArg | 8507 (&H213B) | An argument is invalid.
rptErrInvalidColIndex | 8523 (&H214B) | The column index is invalid.
rptErrInvalidDataField | 8526 (&H214E) | The data field can't be found.
rptErrInvalidDateSource | 8520 (&H2148) | The data source is invalid.
rptErrInvalidFileFilter | 8517 (&H2145) | The file filter is invalid, or in an invalid format.
rptErrInvalidFileVersion | 8511 (&H213F) | The file version is invalid.
rptErrInvalidKey | 8504 (&H2138) | The key is invalid.
rptErrInvalidName | 8503 (&H2137) | The name is invalid.
rptErrInvalidPropertyValue | 380 (&H17C) | A property value is invalid.
rptErrInvalidRowIndex | 8524 (&H214C) | The row index is invalid.
rptErrInvalidRowset | 8522 (&H214A) | The rowset is invalid.
rptErrInvalidTemplate | 8516 (&H2144) | The ExportFormat template is invalid.
rptErrKeyNotFound | 8501 (&H2135) | The key can't be found.
rptErrLineBreak | 8553 (&H2169) | An error occurred wrapping lines of text in the control.
rptErrMarginsTooTall | 8541 (&H215D) | Top and bottom margins are higher than the paper height.
rptErrMarginsTooWide | 8540 (&H215C) | Left and right margins are wider than the paper width.
rptErrNotAllowedInReportGenerating | 8576 (&H2180) | This property or method cannot be accessed during the generation of the report.
rptErrObjectNotFoundInCollection | 8574 (&H217E) | The object can't be found in the collection.
rptErrOutOfMemory | 7 | Out of memory.
rptErrPathNotFound | 8514 (&H2142) | The path can't be found.
rptErrPrint | 8558 (&H216E) | An error occurred during printing.
rptErrPrinterInfo | 8555 (&H216B) | Error obtaining printer information.
rptErrPrintInit | 8557 (&H216D) | An error occurred initializing the printer.
rptErrReportTooTall | 8571 (&H217B) | Sections do not fit vertically on the page.
rptErrReportTooWide | 8542 (&H215E) | Report width is larger than the paper width.
rptErrSectDontMatchData | 8570 (&H217A) | Report sections do not match data source.
rptErrSharingViolation | 8515 (&H2143) | Cannot access the file because it is being used by another process.
rptErrSubscriptRange | 9 | The subscript is out of range.
rptErrTempFileName | 8550 (&H2166) | Error generating temporary filename.
rptErrTempFileRead | 8554 (&H216A) | Error opening or reading from temporary file.
rptErrTempFileWrite | 8552 (&H2168) | Error creating or writing to temporary file.
rptErrTypeMismatch | 13 | Type mismatch.
rptErrUnexpected | 8505 (&H2139) | Unexpected error.
rptErrUnknown | 8502 (&H2136) | General error.

ExportFormat Constants

Constant | Value | Description
rptFmtHTML | 0 | HTML format.
rptFmtText | 1 | Text format.
rptFmtUnicodeText | 2 | Unicode.
rptFmtUnicodeHTML_UTF8 | 3 | HTML encoded in Universal Character Set (UTF - 8)

FunctionType Constants

Constant | Value | Description
rptFuncSum | 0 | Sum function.
rptFuncAve | 1 | Average.
rptFuncMin | 2 | Minimum
rptFuncMax | 3 | Maximum.
rptFuncRCnt | 4 | Counts the rows in the section.
rptFuncVCnt | 5 | Counts the fields with non-null values.
rptFuncSDEV | 6 | Calculates the standard deviation.
rptFuncSERR | 7 | Calculates the standard error.

LineSlant Constants

Constant | Value | Description
rptSlantNWSE | 0 | Line slants from northwest to southeast.
rptSlantNESW | 1 | Line slants from northeast to southwest.

PageBreak Constants

Constant | Value | Description
rptPageBreakNone | 0 | No page breaks on the section.
rptPageBreakBefore | 1 | Page break occurs before the section.
rptPageBreakAfter | 2 | Page break occurs after the section.
rptPageBreakBeforeAndAfter | 3 | Page break occurs before and after the section.

PageRange Constants

Constant | Value | Description
rptRangeAllPages | 0 | Print or export all pages.
rptRangeFromTo | 1 | Print or export only the named range of pages.

PictureAlignment Constants

Constant | Value | Description
rptPATopLeft | 0 | The picture appears at the top left.
rptPATop | 1 | The picture appears at the top.
rptPATopRight | 2 | The picture appears at the top right.
rptPARight | 3 | The picture appears at the right.
rptPABottomRight | 4 | The picture appears at the bottom right.
rptPABottom | 5 | The picture appears at the bottom.
rptPABottomLeft | 6 | The picture appears at the bottom left.
rptPALeft | 7 | The picture appears at the left.
rptPACenter | 8 | The picture appears centered.

Shape Constants

Constant | Value | Description
rptShpRectangle | 0 | Rectangle shape.
rptShpSquare | 1 | Square shape.
rptShpOval | 2 | Oval shape.
rptShpCircle | 3 | Circle shape.
rptShpRoundedRectangle | 4 | Rounded rectangle shape.
rptShpRoundedSquare | 5 | Rounded square shape.


DefaultCursorType Property Constants

The DefaultCursorType settings for the Data control are:

Setting | Value | Description
vbUseDefaultCursor | 0 | Let the ODBC driver determine which type of cursors to use.
vbUseODBCCursor | 1 | Use the ODBC cursor library. This option gives better performance for small result sets, but degrades quickly for larger result sets.
vbUseServerSideCursor | 2 | Use server side cursors. For most large operations this gives better performance, but might cause more network traffic.


ListBox Constants

The Style property settings for the ListBox control are:

Constant | Value | Description
vbListBoxStandard | 0 | (Default) Standard. The ListBox control displays as it did in previous versions of Visual Basic; That is, as a list of text items.
vbListBoxCheckbox | 1 | CheckBox. The ListBox control displays with a checkbox next to each text item. Multiple items in the ListBox can be selected by selecting the checkbox beside them.


Menu Shortcut Constants

Menu Accelerator Constants

Constant | Value | Description
vbMenuAccelCtrlA | 1 | User-defined shortcut keystrokes
vbMenuAccelCtrlB | 2 | User-defined shortcut keystrokes
vbMenuAccelCtrlC | 3 | User-defined shortcut keystrokes
vbMenuAccelCtrlD | 4 | User-defined shortcut keystrokes
vbMenuAccelCtrlE | 5 | User-defined shortcut keystrokes
vbMenuAccelCtrlF | 6 | User-defined shortcut keystrokes
vbMenuAccelCtrlG | 7 | User-defined shortcut keystrokes
vbMenuAccelCtrlH | 8 | User-defined shortcut keystrokes
vbMenuAccelCtrlI | 9 | User-defined shortcut keystrokes
vbMenuAccelCtrlJ | 10 | User-defined shortcut keystrokes
vbMenuAccelCtrlK | 11 | User-defined shortcut keystrokes
vbMenuAccelCtrlL | 12 | User-defined shortcut keystrokes
vbMenuAccelCtrlM | 13 | User-defined shortcut keystrokes
vbMenuAccelCtrlN | 14 | User-defined shortcut keystrokes
vbMenuAccelCtrlO | 15 | User-defined shortcut keystrokes
vbMenuAccelCtrlP | 16 | User-defined shortcut keystrokes
vbMenuAccelCtrlQ | 17 | User-defined shortcut keystrokes
vbMenuAccelCtrlR | 18 | User-defined shortcut keystrokes
vbMenuAccelCtrlS | 19 | User-defined shortcut keystrokes
vbMenuAccelCtrlT | 20 | User-defined shortcut keystrokes
vbMenuAccelCtrlU | 21 | User-defined shortcut keystrokes
vbMenuAccelCtrlV | 22 | User-defined shortcut keystrokes
vbMenuAccelCtrlW | 23 | User-defined shortcut keystrokes
vbMenuAccelCtrlX | 24 | User-defined shortcut keystrokes
vbMenuAccelCtrlY | 25 | User-defined shortcut keystrokes
vbMenuAccelCtrlZ | 26 | User-defined shortcut keystrokes
vbMenuAccelF1 | 27 | User-defined shortcut keystrokes
vbMenuAccelF2 | 28 | User-defined shortcut keystrokes
vbMenuAccelF3 | 29 | User-defined shortcut keystrokes
vbMenuAccelF4 | 30 | User-defined shortcut keystrokes
vbMenuAccelF5 | 31 | User-defined shortcut keystrokes
vbMenuAccelF6 | 32 | User-defined shortcut keystrokes
vbMenuAccelF7 | 33 | User-defined shortcut keystrokes
vbMenuAccelF8 | 34 | User-defined shortcut keystrokes
vbMenuAccelF9 | 35 | User-defined shortcut keystrokes
vbMenuAccelF11 | 36 | User-defined shortcut keystrokes
vbMenuAccelF12 | 37 | User-defined shortcut keystrokes
vbMenuAccelCtrlF1 | 38 | User-defined shortcut keystrokes
vbMenuAccelCtrlF2 | 39 | User-defined shortcut keystrokes
vbMenuAccelCtrlF3 | 40 | User-defined shortcut keystrokes
vbMenuAccelCtrlF4 | 41 | User-defined shortcut keystrokes
vbMenuAccelCtrlF5 | 42 | User-defined shortcut keystrokes
vbMenuAccelCtrlF6 | 43 | User-defined shortcut keystrokes
vbMenuAccelCtrlF7 | 44 | User-defined shortcut keystrokes
vbMenuAccelCtrlF8 | 45 | User-defined shortcut keystrokes
vbMenuAccelCtrlF9 | 46 | User-defined shortcut keystrokes
vbMenuAccelCtrlF11 | 47 | User-defined shortcut keystrokes
vbMenuAccelCtrlF12 | 48 | User-defined shortcut keystrokes
vbMenuAccelShiftF1 | 49 | User-defined shortcut keystrokes
vbMenuAccelShiftF2 | 50 | User-defined shortcut keystrokes
vbMenuAccelShiftF3 | 51 | User-defined shortcut keystrokes
vbMenuAccelShiftF4 | 52 | User-defined shortcut keystrokes
vbMenuAccelShiftF5 | 53 | User-defined shortcut keystrokes
vbMenuAccelShiftF6 | 54 | User-defined shortcut keystrokes
vbMenuAccelShiftF7 | 55 | User-defined shortcut keystrokes
vbMenuAccelShiftF8 | 56 | User-defined shortcut keystrokes
vbMenuAccelShiftF9 | 57 | User-defined shortcut keystrokes
vbMenuAccelShiftF11 | 58 | User-defined shortcut keystrokes
vbMenuAccelShiftF12 | 59 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF1 | 60 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF2 | 61 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF3 | 62 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF4 | 63 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF5 | 64 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF6 | 65 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF7 | 66 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF8 | 67 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF9 | 68 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF11 | 69 | User-defined shortcut keystrokes
vbMenuAccelShiftCtrlF12 | 70 | User-defined shortcut keystrokes
vbMenuAccelCtrlIns | 71 | User-defined shortcut keystrokes
vbMenuAccelShiftIns | 72 | User-defined shortcut keystrokes
vbMenuAccelDel | 73 | User-defined shortcut keystrokes
vbMenuAccelShiftDel | 74 | User-defined shortcut keystrokes
vbMenuAccelAltBksp | 75 | User-defined shortcut keystrokes


StateManagement Property Constants

Constant | Value | Description
WcNoState | 1 | The WebClass instance will be created and destroyed for every HTTP request that is processed. Any state required by the WebClass object must be stored externally, as in a database management system. Alternatively, state or key information for the state can be saved within the Session object, the URL itself using the URLData property or cookies using the Response.Cookies collection.
wcRetainInstance | 2 | The WebClass object instance is created when the first HTTP request is received. The instance is not destroyed until either the WebClass object calls SetComplete or the Active Server Pages session times out. State can be safely kept within properties of the WebClass object; however, this will increase the size and decrease the scalability of your application.


Control Class

Visual Basic provides the Control class as a generic variable type for controls. When you declare a variable As Control, you can assign it a reference to any control. You cannot create an instance of the Control class.

Note Accessing properties and methods of a control is faster if you use a variable declared with the same type as the control (for example, As TreeView or As CommandButton), because Visual Basic can use early binding. Visual Basic must use late binding to access properties and methods of a control assigned to a variable declared As Control.


Controls Collection

A collection whose elements represent the controls on a component. The Controls collection has a Count property which specifies the number of controls in the collection, and an Item method which returns a member of the collection.

Syntax

object.Controls.Count

object.Controls(index)

The Controls collection syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
Index | An integer with a range from 0 to Controls.Count - 1.

Note If the component is a Visual Basic module, such as a Form or UserControl, you don't have to supply the object expression when writing code within the module. If the container is a compiled ActiveX control, such as a ToolBar control, however, you must always supply the object expression.

Remarks

The Controls collection enumerates loaded controls on a component and can be useful for iterating through them. For example, you might use it to change the BackColor property of all the Label controls on a Form.

The Controls collection identifies an intrinsic form-level variable named Controls. If you omit the optional object placeholder, you must include the Controls keyword. However, if you include object, you can omit the Controls keyword. For example, the following two lines of code have the same effect:

MyForm.Controls(6).Top = MyForm.Controls(5).Top + increment
MyForm(6).Top = MyForm(5).Top + increment

You can pass Controls(index) to a function whose argument is specified as a Controls class. You can also access members using their name. For example:

Controls("Command1").Top

You can use the TypeOf keyword with the If statement, or the TypeName function, to determine the type of a control in the Controls collection.

Note The Controls collection is not a member of the Visual Basic Collection class. It has a smaller set of properties and methods than a Collection object, and you cannot create instances of it.


Function Control (Data Report Designer)

A Function control displays figures calculated at run time using various built-in functions.

Syntax

rptFunction

Remarks

The functions contained by the Function control include:

Function | Description
Sum | Sums the values of a field.
Min | Displays the minimum value of a field.
Max | Displays the maximum value of a field.
Average | Displays the average of values.
Standard Deviation | Displays the standard deviation for a column of figures.
Standard Error | Displays the standard error for a column of figures.
Value Count | Displays the number of fields containing non-null values.
Row Count | Displays the number of rows in a section of the report.

The Function control can only be placed in a group footer section of a Data Report designer.

The Data Environment also features an aggregate field that has some similar functions as the Function control.


Image Control (Data Report Designer)

An Image control can display a graphic from a bitmap, icon, or metafile, as well as enhanced metafile, .jpeg, or .gif files.

Syntax

RptImage

Remarks

The Data Report designer version of the Image control is similar to the standard Visual Basic intrinsic Image control in displaying images on any application. Beyond this basic capability, however, some of the standard Image control's properties are unavailable on the Data Report version.


Label Control (Data Report Designer)

A Label control is a graphical control you can use to display text that a user can't change directly.

Syntax

RptLabel

Remarks

The Data Report designer version of the Label control is similar to the standard Visual Basic intrinsic Label control in providing a method of displaying text on any application. Beyond this basic capability, however, some of the standard Label control's properties are unavailable on the Data Report version.


Line Control (Data Report Designer)

A Line control is a graphical control displayed as a horizontal, vertical, or diagonal line.

Syntax

RptLine

Remarks

The Data Report designer version of the Line control is similar to the standard Visual Basic intrinsic Line control in displaying lines on any application. The Data Report version, however, uses a LineSlant property to determine which direction the line slopes instead of an X, Y coordinate system to determine the appearance of the line.


Shape Control (Data Report Designer)

The Shape control is a graphical control displayed as a rectangle, square, oval, circle, rounded rectangle, or rounded square.

Syntax

Shape

Remarks

The Data Report designer version of the Shape control is conceptually similar to the standard Visual Basic Shape control in providing a method of displaying certain shapes on any application. However, the Data Report designer version does not support the BorderWidth, FillColor, or FillStyle properties.


TextBox Control (Data Report Designer)

The Data Report designer's TextBox control is a data-bound control that can only display text from a database at run time.

Syntax

RptTextBox

The Data Report designer's TextBox control cannot display information entered by the user at design time, and cannot be used for data input at run time.


Add File Dialog Box

Allows you to insert a file into your project.

Dialog Box Options

Look in

Select the location of the project you want to open.

Up One Level

Shows a list of folders or drives one level above the current folder.

Create New Folder

Creates a new folder.

List

Shows the folders or documents in a list format that includes the folder or document icon and its name.

Details

Shows the folder or documents in a list that includes the folder or document icon and name, its size (documents only), type, and the date and time it was last modified.

File name

Select or type the name of a project you want to open.

Files of type

Select a file type; the default is Text Files (*.txt). Files of the selected type will appear in the File Name list box.

Add As Related Document

Adds items such as Microsoft Excel worksheets or Microsoft Word documents to the Related Documents folder in the Project Explorer.

Open

Inserts the selected file.

Cancel

Closes the dialog box without inserting a new project.


Add <item> Dialog Box

Allows you to locate and add a form, MDI form, module, class module, user control, property page, user document, or ActiveX designer to your project.

Dialog Box Tabs

New

Lists the available items.

Existing

Displays the common Open dialog box where you can locate and open the item you want to add.

Don't show this dialog in the future

When selected automatically adds an new item to your project without showing the Add <item> dialog box. To view the Add <item> dialog box in the future select the Prompt for project option on the Environment tab of the Options dialog box.


Add Procedure Dialog Box

Inserts a new Sub, Function, or Property procedure. The Insert Procedure dialog box also allows you to set the scope to public or private, and make all local variables in the procedure static.

Dialog Box Options

Name

Lists a name for the new procedure.

Type

Identifies the type of procedure to create.

  • Sub — Creates a new Sub procedure.

  • Function — Creates a new Function procedure.

  • Property — Creates a new Let property and Get property procedure pair.

Scope

Sets the procedure's scope to either Public or Private.

All Local Variables as Statics

Adds the Static keyword to the procedure definition.

OK

Inserts the procedure template in the Code window.

Cancel

Closes the dialog box without inserting a new procedure.


Add Project Dialog Box

Displays the project types or existing projects you can add to your project. When you add a project, a project group is created, if one does not already exist. A project group is useful if you want to load a set of related projects at the same time.

Dialog Box Options

New Tab

Displays the project types you can add.

Existing Tab

Displays a dialog box where you can locate and select the project that you want to add.

Recent Tab

Lists the most recently opened projects and their location.


Advanced Tab (Command Properties Dialog Box)

The Command Properties dialog box is divided into six tabs. The General, Parameters, and Advanced tabs are used for setting properties of the Command and Parameter objects, while the Relation, Grouping, and Aggregates tabs are used for setting properties that are specific to Command hierarchies.

On the Advanced tab, specify Recordset management and other information relating to the current Command object.

RecordSet Management

This frame contains the control group pertaining to the management of the Recordset objects.

Cursor Type

Specifies the type of cursor to use for the Command object: Forward Only, Keyset, Dynamic, or Static. The default is Forward Only.

Cursor Location

Specifies the location of the cursor library for the Command object.

Lock Type

Specifies the type of lock that the provider uses to open a Command object: Read Only, Pessimistic, Optimistic, or Batch Optimistic. The default is Read Only.

Cache Size

Specifies the cache size to use for the Command object. The default is 10 records.

Recordset Returning

Specifies whether the Recordset object returns information.

Note If you want to return both a Recordset and an output parameter, you must create two Command objects, one with Recordset returning selected, and the other with it not selected.

Command Configuration

This frame contains the control group that specifies timeout and record configuration information.

Command Timeout

The number of seconds to timeout when the Command cannot be executed. The default is 30 seconds.

Max Records

The maximum number of records that can return from a data source. The default is 0, which means infinite.

Prepare Before Execution

Specifies whether the command is prepared on the first invocation. Valid values are True or False. The default is False.

All Records

Specifies whether all records are returned upon execution of the Command object. If selected, Max Records is set to 0 and the edit control is disabled.

Call Syntax

The call syntax that ADO uses to call the stored procedure. This can be edited to adjust the number of parameters and presence of the return value.


Advanced Optimizations Dialog Box

Allows you to add the following optimizations to your compile.

Note Enabling these optimizations may prevent the correct execution of your program.

Dialog Box Options

Assume No Aliasing

Tells the compiler that your program does not use aliasing. Aliasing provides a name that refers to a memory location that is already referred to by a different name. Using this option allows the compiler to apply optimizations that it could not otherwise use, for example storing variables in registers and performing loop optimizations. This occurs when using ByRef arguments. For example:

Dim y as integer
Sub Foo(x as integer)
x=5        'Code is referring to the same variable (the
y=6        'global y)via two different names
End Sub
Sub Main
Foo y
End Sub

Remove Array Bound Checks

By default in Visual Basic, a check is made on every access to an array to determine if the index is within the range of the array. If the index is not within array bounds an error message is displayed. Selecting this option turns off the array bounds error checking and removes checks for the correct number of dimension of the array.

Note This may speed up array manipulation but invalid memory locations may be accessed and result in unexpected behavior or program crashes.

Remove Integer Overflow Checks

By default in Visual Basic, a check is made on every calculation for integer-style data types – byte, integer, and long – to be sure that the value is within the range of the data type. If the magnitude of the value being put into the data type is incorrect an error occurs. Selecting this option turns off the error checking which can speed up integer calculations. However, if data type capacities are overflowed, no error occurs and you may get incorrect results.

Remove Floating Point Error Checks

By default in Visual Basic, a check is made on every calculation of a floating point data type – Singe and Double – to be sure that the value is within range for that data type and that there are no divide by zero or invalid operations. If the magnitude of the value being put into the data type is incorrect, an error occurs. Selecting this option turns off the error checking which can speed up floating [point calculations. However, if data type capacities are overflowed, not error occurs and you may get incorrect result.

Allow Unrounded Floating Point Operations

When selected, allows the compiler to:

  • Use floating point registers more efficiently

  • Avoid loads and stores from memory

  • Do floating point comparisons more efficiently

    Note Using this option may result in calculations being maintained to a higher precision than expected and may cause the comparison of two floating point values to show them unequal when you expect them to be equal.

Remove Safe Pentium™ FDIV Checks

Removes the checking so that the code for floating point division is faster and smaller but may produce slightly incorrect results on Pentium™ processors with the FDIV bug. If cleared, the code generated for floating point division operations is not affected by the FDIV bug on Pentium™ processor.


Advanced Tab (Add-In Designer)

Allows you to add further options when using the Add-In Designer to begin the development process for an add-in.

To display the Add-In Designer

  1. Select the AddInDesigner Object on the Designers tab of the Components dialog on the Project menu.

  2. Select the AddInDesigner Object from the Add ActiveX Designer command on the Project menu.

Window Elements

Satellite DLL Name

Enter the name of the file containing resources for the add-in. The resource file must be in the same folder as the registered .dll containing the add-in itself.

Registry Key for Additional Add-In Data

Enter the full path of the registry key containing the values listed in the list box below.

Add-In Specific Data

Enter values you want stored in the registry key listed in the list box above. The only two types of data permitted are String and DWORD.


Aggregates Tab (Command Properties Dialog Box)

The Command Properties dialog box is divided into six tabs. The General, Parameters, and Advanced tabs are used for setting properties of the Command and Parameter objects, while the Relation, Grouping, and Aggregates tabs are used for setting properties that are specific to Command hierarchies.

On the Aggregates tab, define the aggregates associated with a relation or group-based hierarchy.

Note The properties on this tab do not apply to Visual InterDev.

Aggregates

Lists the aggregates defined for the Command object.

Add

Inserts additional aggregates into the Aggregates box.

Note Once an aggregate is added, you can define it in the Aggregate Settings and Grand Total Command frames.

Remove

Deletes the selected aggregate from the Aggregates box. If no aggregate is selected, this is disabled.

Aggregate Settings

This frame contains the control group used to change the aggregate properties of the selected aggregate. When no aggregate is selected, this is disabled.

Name

This is the name of the Field object that will be added to the Command object. At run time, this field will contain the calculated aggregate value.

You can change this to a more meaningful, unique name that describes the aggregate. For example, if you are creating an aggregate that provides the average number of items on each order, an appropriate name could be "AverageOrderNumber."

Function

Contains the aggregate function to perform on a field object, you can use one of the following operations for each aggregate that you create:

Operation | Description
Any | Returns the default operation of the selected field.
Average | Obtains the average of the values in a particular field.
Count | Returns the count of the number of records in the selection.
Maximum | Returns the highest value in a selected field.
Minimum | Returns the smallest value in a selected field.
Standard Deviation | Returns the standard deviation of the selection.
Sum | Returns the sum of all the values in the selected field.

Aggregate On

Specifies what the aggregate is based upon — grand total, grouping, or child command.

The contents of this list vary, depending on the definition of the Command object. Grouping is only available if the Command object is grouped, child Command objects are listed only if the current Command object is a parent, and Grand Total is listed only if the current Command object is a top-level object.

Field

Fields upon which you can create an aggregate. The fields listed are dependent upon the Aggregate On selection.

Grand Total Command

This frame contains the control group used if the Grand Total constraint is selected in Aggregate On.

Name

A name you specify for the Grand Total Command. It is recommended that you change this to a more meaningful, unique name. The Grand Total Command Name can be the same as the Aggregate Settings Name.


Authentication Tab (Connection Properties Dialog Box)

Using the Connection Properties dialog box you can set the required and optional properties of a Connection object. The properties are divided between three tabs: General, Authentication, and Miscellaneous.

Note The Connection Properties dialog box is only used by Visual InterDev.

On the Authentication tab, specify a user name and password for the connection, and designate how and where this information is stored.

Design-time Authentication Information

This frame contains information used in the connection string. These values help build the connection string that the Connection object uses to connect to a data source.

Note The keywords used for the user name and password depend on the data source selected on the General tab, as described in User Name and Password.

The properties in this frame are for both design time and run time unless Run-time Authentication Information is provided, in which case the properties set in this frame apply only to design time.

User Name (Design-time Authentication Information frame)

The name of a user to authenticate. If the data source is an ODBC DSN, the keyword is UID; if the data source is an OLE DB file or a connection string, the keyword is User ID. If saved, this is used at design time.

Password (Design-time Authentication Information frame)

The password which authenticates the user. If the data source is an ODBC DSN, the keyword is PWD; if the data source is an OLE DB file or a connection string, the keyword is Password. If saved, this is used at design time.

Prompt Behavior (Design-time Authentication Information frame)

Specifies the prompting behavior by the Connection object, such as when to request logon information.

For Visual Basic, this option specifies both design- and run-time behavior. For Microsoft® Visual InterDev™, the selected prompt behavior is for design time, while at run time the prompt behavior is always Never, and this option is disabled.

Save Design-time Authentication (Design-time Authentication Information frame)

When selected, the authentication information is saved, causing the specified logon data to persist at design and run time. However, if Run-time Authentication Information is provided, the properties set in the Design Authentication Information frame apply only to design time.

Run-time Authentication Information

This frame contains information used in the connection string at run time only.

The properties in this frame help build the connection string that the Connection object uses to connect to a data source at run time. The properties are either stored in the actual class, or are persisted in the build executable file or DLL.

User Name (Run-time Authentication Information frame)

The name of a user to authenticate. If the data source is an ODBC DSN, the keyword is UID; if the data source is an OLE DB file or a connection string, the keyword is User ID. If saved, this is used at run time.

Password (Run-time Authentication Information frame)

The password which authenticates the user. If the data source is an ODBC DSN, the keyword is PWD; if the data source is an OLE DB file or a connection string, the keyword is Password. If saved, this is used at run time.

Prompt Behavior (Run-time Authentication Information frame)

Specifies the prompting behavior by the Connection object, such as when to request logon information.

This option is used for Visual Basic only. When using Visual InterDev, the run-time prompt behavior is always Never, and this option is disabled.

Save Run-time Authentication (Run-time Authentication Information frame)

When selected, the authentication information is saved, causing the specified logon data to persist at run time.


Batch Query Tab (Visual Basic Batch T-SQL Debugger Dialog Box)

Tab Options

Batch Text

Displays the SQL text of the stored procedure.


Visual Basic Batch T-SQL Debugger Dialog Box

Allows you to create, edit, and interactively debug stored procedures written in Microsoft SQL Server’s Transact SQL dialect within the Visual Basic development environment.

To view this dialog, add the T-SQL Debugger to the development environment via the Add-In Manager command on the Add-Ins menu. Then, with the debugger loaded, select T-SQL Debugger on the Add-Ins menu.

Use the T-SQL debugger to:

  • Display the SQL call stack, local variables, and parameters for a SQL stored procedure.

  • Control and manage breakpoints.

  • View local variables and parameters.

  • View global variables.

Note In order to use the T-SQL debugger, you must have SQL Server version 6.5 with Service Pack 3 or later installed as your database server.

Settings Tab

Stored Procedure Tab

Batch Query Tab


Make Tab (Project Properties Dialog Box)

Sets the attributes for the executable file you make. Displays the name of the current project in the title so you can determine which project will be affected by any changes you make. The current project is the item currently selected in the Project Explorer.

Tab Options

Version Number

Creates the version number for the project.

  • Major — Major release number of the project; 0 – 9999.

  • Minor — Minor release number of the project; 0 – 9999.

  • Revision — Revision version number of the project; 0–9999.

  • Auto Increment — If selected, automatically increases the Revision number by one each time you run the Make Project command for this project.

Application

Let’s you identify a name and icon for your project.

  • Title — Name of the application.

  • Icon — Icon for the application.

Version Information

Let’s you provide specific information about the current version of your project.

  • Type — Information you can use to set a value. You can enter information for your company name, file description, legal copyright, legal trademarks, product name and comments.

  • Value — The value for the type of information selected in the Type box.

Command Line Arguments

Allows you to enter the command-line arguments that Visual Basic sends to an application only when you choose Start from the Run menu.

Conditional Compilation Arguments

Allows you to enter the constant declarations used for conditional compilation.


Compile Tab (Project Properties Dialog Box)

Allows you to set conditions for compiling your project.

Tab Options

Compile to P-Code

Compiles a project using p-code. The settings stored in the .vbp file are overridden.

Compile to Native Code

Compiles a project using native code with selected optimizations. The settings stored in the .vbp file are overridden.

  • Optimize for Fast Code — Maximizes the speed of the .exe and .dll files by instructing the compiler to favor speed over size. The compiler can reduce many constructs to functionally similar sequences of machine code. In some cases, the differences offer a trade off of size versus speed.

  • Optimize for Small Code — Minimizes the size of the .exe and .dll files by instructing the compiler to favor size over speed. The compiler can reduce many constructs to functionally similar sequences of machine code. If you do not select this option, you may have code that is larger in size but faster.

  • No Optimization — Compile without optimizations.

  • Favor Pentium Pro™ — Optimizes the code created to favor the Pentium Pro™ processor. Use this option for programs meant only for the Pentium Pro ™ processor. Code generated with this option will still run on earlier processors but it does not perform as well.

  • Create Symbolic Debug Info — Generates symbolic debug information in the executable or DLL file. An executable file created using this option can be debugged using Visual C++ or debuggers that use CodeView style of debug information. Setting this option generates a .pdb file with the symbol information for your executable.

Advanced Optimizations

Displays the Advanced Optimizations dialog box.

DLL Base Address

Sets a base address for the program, overriding the default location for a .dll file (at 0X10000000). The operating system first attempts to load a program at its specified or default address. If there is insufficient space, the system relocates the program.


Components Dialog Box

Allows you to add components – controls, designers, or insertable objects – to your project.

You can reference loaded control projects from the Components dialog box.

Note Pressing SHIFT while clicking OK removes unused control references from your project.

Dialog Box Options

Tabs

List components you can add by their category.

  • Controls

  • Designers

  • Insertable Objects

Apply

Adds the selected controls, designers, or insertable objects to the Toolbox without closing the dialog box.

OK

Adds the selected controls, designers, or insertable objects to the Toolbox and closes the Components dialog box.


Connect Property Pages Dialog Box

Allows you to set the property pages at design time.

Dialog Box Options

Available Property Pages

Lists the available property pages. You check the pages that you want to appear on the control.

If you delete a property page from the project that was selected to be used with a control, it appears with the word, MISSING, as a prefix. The next time you open this box, the deleted property page does not appear in the list.

Page Order

Sets the order that the pages appear in the Properties window. The page at the top of the list is the first page that appears when you open the Properties window.

Moves the selected Property Page up one level each time you click it.

Moves the selected Property Page down one level each time you click it.


Connect to WebItem Dialog Box

Allows you to choose a custom or template webitem with which you want to associate the selected HTML tag attribute. The process of connecting an attribute to a webitem tells the webclass to invoke the webitem's Respond event whenever the element represented by the attribute's HTML tag is selected in the browser.

Dialog Box Options

WebItem List Box

Lists the available templates and custom webitems for the webclass. You can select any of these webitems to associate your HTML tag attribute with it. When an attribute is associated with a webitem, it fires that webitem's Respond event when the tag element is selected in the browser.

OK

Associates the attribute with the selected webitem.


Controls Tab (Components Dialog Box)

Allows you to add controls to your project's Toolbox.

Tab Options

Available Controls List

Displays the available controls. You add a control by selecting the check box next to its name.

Note You can't remove a control that is used in your project.

Path

Displays the path of the control selected in the Available Controls box.

Browse

Displays the Add ActiveX Control dialog box where you can locate and open the control you want.

Selected Items Only

When selected, displays only those controls in the Available Controls list which you have selected to include in the project.

Apply

Adds the selected controls to the Toolbox without closing the dialog box.

OK

Adds the selected controls to the Toolbox and closes the Components dialog box.


Custom Control Upgrade Dialog Box

Allows Visual Basic to automatically upgrade old custom controls that you are using with appropriate ActiveX controls that are available on your system.

Dialog Box Options

Controls that can be upgraded

Lists the controls that can be upgraded to their newer version.

Controls without upgrade keys

Lists controls that have no upgrade keys and will be converted to PictureBoxes.

OK

Replaces the controls with ActiveX controls.

Cancel Load

Visual Basic does not replace the controls and cancels loading the project.

Note Replacement compatibility is determined by the ActiveX control vendor. Before replacing a custom control with an ActiveX control, be sure to check the ActiveX control vendor's documentation to see if you need to modify event procedures or other code associated with your project's use of the replacement controls.


DatabaseName Dialog Box

Allows you to look for and open the database you want to use as the source of data for your Data control.

Dialog Box Options

Look in

Displays the computers, servers, drives, and folders available on your computer that you can use to locate the database you want to open.

Up One Level

Shows a list of folders or drives one level above the current server, computer, or folder.

Create New Folder

Creates a new folder.

List

Shows the folders or documents in a list format that includes the folder or document icon and its name.

Details

Shows the folder or documents in a list that includes the folder or document icon and name, its size (documents only), type, and the date and time it was last modified.

File name

Select or type the name of the database you want to use.

Files of type

Select a file type; the default is Databases (*.mdb). Files of the selected type will appear in the File Name list box.

Open

Adds the path to the selected database to DatabaseName in the Properties window.

Cancel

Closes the dialog box without adding the database path to the DatabaseName in the Properties window.


Define Color Dialog Box

Allows you to create customized colors.

Dialog Box Options

Color Screen with Slider

Allows you to choose your color by sliding the bar up and down, from white to black.

Color Preview Box

Allows you to preview your color.

Hue

Adjusts the hue from 0-239 with 0 representing black and 239 representing white.

Sat

Adjusts the color saturation from 0-240 with 0 representing black and 240 representing black.

Lum

Adjusts the luminescence from 0-240 with 0 representing black and 240 representing white.

Red

Adjusts the amount of red in the color from 0-255.

Green

Adjusts the amount of green in the color from 0 to 255.

Blue

Adjusts the amount of blue in the color from 0 to 255.

Add Color

Adds your custom color to the Color Palette.


Designers Tab (Components Dialog Box)

Allows you to add designers to your project's Toolbox.

Tab Options

Available Designers List

Displays the available designers. You add a designer by selecting the check box next to its name.

Note You can't remove a designer that is used in your project.

Path

Displays the path of the designer selected in the Available Designers List.

Selected Items Only

When selected, displays only those designers in the Available Designers list which you have selected to include in the project.

Apply

Adds the selected designers to the Toolbox without closing the dialog box.

OK

Adds the selected designers to the Toolbox and closes the Components dialog box.


Docking Tab (Options Dialog Box)

Allows you to choose which windows you want to be dockable.

A window is docked when it is attached or "anchored" to other windows that are dockable or to the main window when you are in MDI mode. When you move a dockable window, it "snaps" to the location. A window is not dockable when you can move it anywhere on the screen and leave it there.

Tab Options

Dockable

Lists the windows that are dockable.

Select the windows you want to be dockable and clear those that you do not. You can have any, none, or all of the windows in the list dockable.


Existing Tab (Add, New, and Open Projects Dialog Boxes)

Displays a dialog box that looks like the Open common dialog box where you can locate and select the project that you want to add. When you add project groups, they merge into one project group.

You can add as many projects as your system resources and memory can accommodate.


Field Mapping Tab (Options Dialog Box)

The Options dialog box enables you to change the Data Environment designer's global settings. The properties are divided between two tabs: General and Field Mapping.

On the Field Mapping tab, change the association of a control with a data type. This information is used when a Command or Field object is dragged from the Data Environment designer and dropped onto a form or report.

Default Control Association

This frame contains the control group that specifies drag information.

Show all data types

If selected, all specific field types display in the list, in addition to the field type categories. For example, the Category/Data Type contains both general and detailed information such as Binary, adBinary, adLongBinary, adVarBinary, Boolean, and so forth, and Control shows TextBox, <Use default>, <Use default>, <Use default>, CheckBox, and so forth.

If not selected (the default), only the field type categories display in the box. For example, the Category/Data Type contains general information such as Binary and Boolean, while Control shows TextBox and CheckBox.

Category/Data type

Once an item is selected in the Category/Data Type and Control list, this shows the field type category or specific field data as read-only data.

Control

Once an item is selected in the Category/Field Type and Control list, this shows the control associated with the selected field type category or specific field data. The list contains all ActiveX controls available on your system as well as a base set of intrinsic controls. You can select a control from this list.

Drag and Drop Field Captions

If selected, when a Command or Field object is dragged to a form, a label control is automatically created next to it. The caption is specified in the Caption field from the General tab of the Field Properties dialog box.

If not selected, no label control is created. The type of control created is based on the Caption field type; therefore, you can change the type of control created for the captions.


General Tab (Command Properties Dialog Box)

The Command Properties dialog box is divided into six tabs. The General, Parameters, and Advanced tabs are used for setting properties of the Command and Parameter objects, while the Relation, Grouping, and Aggregates tabs are used for setting properties that are specific to Command hierarchies.

On the General tab, set the required properties of a Command object.

Command Name

The name of the Command object. This name references an individual Command object within a DataEnvironment object. The default is "Command" plus a unique number (for example, Command1). It is recommended that you change this to a more meaningful name, such as the name of the database object on which the Command object is based.

Note For child Command objects in a relation hierarchy, the Command Name is the field name of the parent Command object that contains a reference to the child.

Connection

The Connection object to which the Command object is related. You can view a list of all Connection objects in the current DataEnvironment object through the combo box.

Note Since the child and parent Command objects must have the same source connection, this feature is disabled in the child's Command Properties dialog box.

Source of Data

This frame contains the control group that specifies the type of data that is retrieved for the Command object.

Database Object

Specifies the database item on which the Command object is based. The options are Stored Procedure, Table, View, or Synonym.

Object Name

Provides a list of all database items of the specified Database Object.

SQL Statement

The SQL command that the Command object uses for its data source. Use the edit control to enter a SQL command.

SQL Builder

Accesses the query designer for a Command object when the command source is text.


General Tab (Connection Properties Dialog Box)

Using the Connection Properties dialog box you can set the required and optional properties of a Connection object. The properties are divided between three tabs: General, Authentication, and Miscellaneous.

Note The Connection Properties dialog box is only used by Visual InterDev.

On the General tab, specify the source of data and set the required properties of the Connection object.

Connection Name

The name of the Connection object. This name references an individual Connection object within a DataEnvironment object. The default is "Connection" plus a unique number (for example, Connection1). It is recommended that you change this to a more meaningful name, such as the name of the target database.

Source of Connection

This frame contains the control group used to specify the type of connection to use. This can be an ODBC data source name (the default), a Data Link file, or a connection string.

Use Data Link File

Specifies that you are using a custom connection string that connects to the data source. When this is selected, you can click Browse to access the Organize Data Sources dialog box, from which you can select your Data Link file.

Use ODBC Data Source Name

Specifies that a system-defined data source name (DSN) is used for the connection string. You can access a list of all system-defined DSNs via the combo box.

When this option is selected, you can click New to access the Create New Data Source wizard dialog box to add to or modify DSNs on the system.

Use Connection String

Specifies that you are using a connection string to access data. If the Use Connection String text box is empty, the wizard appears, or you can click Build to access the Data Link Properties dialog box. Use this dialog box to specify the connection, authentication, and advanced information required to access data using an OLE DB provider.

Test Connection

Once the connection source is selected, click this button to test the specified connection, ensuring that the properties are correctly set in the Connection Properties dialog box.

Note If the connection is invalid, ensure that all properties are specified correctly on each tab of the dialog box, and then retest the connection.


General Tab (Field Properties Dialog Box)

Using the Field Properties dialog box you can set the properties of a Field object.

On the General tab, set the general properties of the Field object. This tab is available for all Field objects.

Field Name

The name of the Field object. This is a read-only field.

Field Mapping

This frame contains the control group that is used for drag and drop.

Control

Specifies the control that is created when dragging and dropping a Field object onto a form. This can be <use default> or any other control listed in the drop-down box.

Caption

Specifies the set value of the caption control when dragging and dropping the Field object onto a form.

Details

This frame contains the control group information about the Field object that you may find useful when setting the Field Mapping controls.

DataType

Specifies the ADO type of the Data Environment Field object. This is a read-only field.

Size

Specifies the size, in bytes, of the Data Environment Field object value, as defined by the structure of the database. This is a read-only field.

Scale

Specifies the numeric scale (the maximum number of digits to the right of the decimal point separator) of the Data Environment Field object. This is a read-only field.

Precision

Specifies the precision (maximum total number of digits) of the Data Environment Field object. This read-only property applies only to numeric fields.


General Tab (Add-In Designer)

Allows you to begin the development process for an add-in by registering it, and setting properties.

To display the Add-In Designer

  1. Select the AddInDesigner Object on the Designers tab of the Components dialog on the Project menu.

  2. Select the AddInDesigner Object from the Add ActiveX Designer command on the Project menu.

Window Elements

Add-In Display Name

Enter the display name of the add-in. This name identifies the add-in in the Add-In Manager Dialog. You can also add a resource ID here by entering a pound sign (#) followed by an integer. Enter the filename of the .dll containing the resource on the Advanced tab of this designer.

Add-In Description

Enter a description of the add-in. You can also add a resource ID here by entering a pound sign (#) followed by an integer. Enter the filename of the .dll containing the resource on the Advanced tab of this designer.

Application

Select the add-in's host application. The dropdown lists registered applications capable of hosting add-ins.

Application Version

Enter the version number of the add-in's host application.

Initial Load Behavior

Select the add-in's load behavior.

  • None - No load behavior is specified.

  • On Startup - The add-in loads on normal Visual Basic startup

  • Command Line - The add-in loads when Visual Basic starts from the DOS prompt

  • Command Line/On Startup - The add-in loads whenever Visual Basic starts, whether from the command line or not.

Note The options for load behavior depend on the host selected under Application. For example, if Microsoft Office is selected you'll see a different list.


General Tab (Project Properties Dialog Box)

Specifies the settings for the current Visual Basic project. The name of the project is displayed in the title bar.

Tab Options

Project Type

Sets the project type. You can change any project type to another project type. When you change a project type, all associated changes are made automatically. If items are invalid in the new project type, they remain part of the project but you cannot add new instances. If you have properties in the current project that are not valid in the new project, you will get a message suggesting that you do not make the change.

Startup Object

Sets which form or Sub/Main in the current project runs first.

Project Name

Identifies your component in the Windows Registry and the Object Browser. It is important that it has a unique name.

The project name is the name of the type library for your component. The type library, or TypeLib, contains the description of the objects and interfaces provided by your component.

It is also used to qualify the names of classes. A combination of project name and class name is sometimes referred to as a fully qualified class name, or as a programmatic ID. The fully qualified class name may be required to correctly identify an object as belonging to your component.

Help File Name

Displays the name of the Help file associated with the project.

Project Help Context ID

Lists the context ID for the specific Help topic to be called when the user selects the [image] button while the application’s object library is selected in the Object Browser.

Project Description

Sets the descriptive text that is displayed in the Description pane at the bottom of the Object Browser.

You can use the Project Description as the description for ActiveX components. If you are creating an ActiveX control, it is the text that appears in the Components dialog box.

If you are creating an ActiveX.dll or ActiveX.exe, this text appears in the References dialog box.

Unattended Execution

Indicates that the project is intended to run without user interaction. Unattended projects have no interface elements. Any run-time functions such as messages that normally result in user interaction are written to an event log.

Upgrade ActiveX Controls

When selected, the project automatically updates the ActiveX controls if you installed a newer version of them on your machine since the last time you opened the project. If a newer version of an ActiveX control is available and this option is not selected, a dialog box prompting you to upgrade the control appears. This option is selected by default.

Require License Key

Enables licensing for ActiveX Control projects (projects that compile to .ocx files), not to .exe or .dll files. A Visual Basic license file (*.vbl) will be created when you build the project. The *.vbl must be registered on the user’s machine for the components to be used in the design environment. The SetUp Wizard will build a setup program that properly registers the information in the *.vbl file on the end user's machine when that setup program is run.

Retained in Memory

Retains a project in memory. However, there is a performance cost: A project retained in memory is not unloaded until the process terminates.

Threading Model

  • Threading Model List —The threading model list box is only activated for ActiveX.dlls and ActiveX Control projects. The only options are single-threaded and apartment-threaded.

  • Thread per Object — Indicates that each instance of a class marked as Multiuse in the Instancing property will be created on a new and distinct thread. Each thread has a unique copy of all global variables and objects, and will not interfere with any other thread.

  • Thread Pool — Indicates that each instance of a class marked as Multiuse in the Instancing property will be created on a thread from the thread pool. The choice of thread is determined in a round-robin fashion. Each thread has a unique copy of all global variables, but multiple instances reside on a given thread and can potentially interfere with each other.

  • Number of threads — Determines the maximum number of threads created for the thread pool. When a Multiuse class is instantiated, threads are created as needed up to the number set here. After the maximum number is reached, Visual Basic begins assigning new instances to existing threads.


Get Template Name Dialog Box (Webclass Designer)

Allows you to enter a new name for a template in two situations:

  • When the template was marked read-only after it was added to your webclass.

  • When another template with the same name already exists in the same project.

Dialog Box Options

File name

Lets you enter a new file name for the template.


Create Virtual Root Dialog Box (Webclass Designer)

Allows you to confirm the name of the virtual directory that Visual Basic creates for your project when you first run a new project, if the project directory is not already configured as a virtual directory. A virtual directory, or virtual root, is a directory outside your Web server's home directory that appears to browsers as a subdirectory of the home directory.

Dialog Box Options

Virtual Root Name

Allows you to change the name of the virtual root that Visual Basic will create for your webclass. You cannot change the location.


Grouping Tab (Command Properties Dialog Box)

The Command Properties dialog box is divided into six tabs. The General, Parameters, and Advanced tabs are used for setting properties of the Command and Parameter objects, while the Relation, Grouping, and Aggregates tabs are used for setting properties that are specific to Command hierarchies.

On the Grouping tab, specify the properties for a grouping hierarchy. You can also create, modify, and delete the grouping of a Command object.

Note The properties on this tab do not apply to Visual InterDev.

Group Command Object

If selected, the Command object is grouped, and all controls on the tab are enabled. If not selected, the Command object is not grouped, and all controls on the tab are disabled.

Grouping Definition

This frame contains the properties for the grouping hierarchy. If Group Command Object is not selected, the contents of this frame are disabled.

Grouping Command Name

The name of the grouping Command object that is created when a Command object is grouped. This Command object contains the grouped data, while the current Command object contains the detail data. It is recommended that you change this to a meaningful, unique name. For example, if grouping by country, a logical name would be ByCountry.

Fields in Command

Lists all Field objects that exist in the source Command object.

Arrows

Use > to move the selected Field object from the Fields in Command list to the Fields Used for Grouping list. This is disabled if no items are listed in the Fields in Command list.

Use >> to move all Field objects from the Fields in Command list to the Fields Used for Grouping list. This is disabled if no items are listed in the Fields in Command list.

Use < to move the selected Field object from the Fields Used for Grouping list to the Fields in Command list. This is disabled if no items are listed in the Fields Used for Grouping list.

Use << to moves all Field objects from the Fields Used for Grouping list to the Fields in Command list. This is disabled if no items are listed in the Fields Used for Grouping list.

Fields Used for Grouping

Contains the Field objects by which the Command object is grouped.

Note If the Command object is a child in a relation hierarchy, the Field objects used in the relation are automatically included here and cannot be removed.


Hierarchy Information Dialog Box

You can view hierarchy-specific information for the selected Command object in the Hierarchy Information dialog box. This dialog box is only available for the top-level, parent Command object. The edit control box displays the information, as specified by View Shape Command or View ADO History.

View Shape Command

If selected, the display in the edit control is of the underlying SHAPE command for the hierarchy. For example:

RsCustomers
Orders

View ADO Hierarchy

If selected, the display in the edit control is an indented list of the underlying RecordSets that create the hierarchy. For example:

SHAPE {SELECT * FROM 'customers'}  AS Customers APPEND ({SELECT * FROM 'orders'}  AS Orders RELATE CustomerID TO CustomerID) AS Orders


Insertable Objects Tab (Components Dialog Box)

Allows you to add insertable objects to your project's Toolbox.

Tab Options

Available Insertable Objects

Displays the available insertable objects. You add an insertable object by selecting the check box next to its name.

Note You can't remove an insertable object that is used in your project.

Path

Displays the path of the insertable object selected in the Available Insertable Objects box.

Selected Items Only

When selected, displays only those insertable objects in the Available Insertable Objects list which you have selected to include in the project.

Apply

Adds the selected insertable objects to the Toolbox without closing the dialog box.

OK

Adds the selected insertable objects to the Toolbox and closes the Components dialog box.


Insert File Dialog Box

Allows you to look for and insert a file into a module in your project.

Dialog Box Options

Look in

Displays the computers, servers, drives, and folders available on your computer that you can use to locate the project you want to open.

Up One Level

Shows a list of folders or drives one level above the current server, computer, or folder.

Create New Folder

Creates a new folder.

List

Shows the folders or documents in a list format that includes the folder or document icon and its name.

Details

Shows the folder or documents in a list that includes the folder or document icon and name, its size (documents only), type, and the date and time it was last modified.

File name

Select or type the name of the file you want to insert.

Files of type

Select a file type; the default is Text Files (*.txt). Files of the selected type will appear in the File Name list box.

Open

Inserts the selected file.

Cancel

Closes the dialog box without inserting a new project.


Insert Stored Procedure Dialog Box

Insert Stored Procedures Dialog Box

When Insert Stored Procedures is selected, the Insert Stored Procedures dialog box appears and allows you to select one or more stored procedures to insert into your DataEnvironment object.

To insert stored procedures into your DataEnvironment object, use the arrows to move one or more stored procedures from the Available list to the Add list, and then click Insert. A new Command object is created for each selected stored procedure. The name of the Command object defaults to the name of the stored procedure.

Connection

The Connection object from which to display the available stored procedures.

Available

Contains all available stored procedures from the selected Connection object.

Arrows

Use > to move the selected stored procedure from the Available list to the Add list. This is disabled if no items are listed in the Available list.

Use >> to move all available stored procedures from the Available list to the Add list. This is disabled if no items are listed in the Available list.

Use < to move the selected stored procedure from the Add list to the Available list. This is disabled if no items are listed in the Add list.

Use << to moves all stored procedures from the Add list to the Available list. This is disabled if no items are listed in the Add list.

Add

The stored procedures listed here are added to the current DataEnvironment object once Insert is clicked.

Insert

Inserts the stored procedures in the Add list into the current DataEnvironment object.

Close

Closes the Insert Stored Procedures dialog box.

Note If you have not moved stored procedures to the Add list and clicked Insert, no stored procedures are added to your DataEnvironment object. In this case, clicking Close acts as a cancel operation.


Make Project Dialog Box

Allows you to build any combination of projects in the project group.

Dialog Box Options

Save in

Select the folder where you want to store the file.

Up One Level

Shows a list of folders or drives one level above the current folder.

Create New Folder

Creates a new folder.

Details

Shows the folder or documents in a list that includes the folder or document icon and name, its size (documents only), type, and the date and time it was last modified.

List

Shows the folders or documents in a list format that includes the folder or document icon and its name.

File name

Allows you type a name for your project. Visual Basic automatically adds the default filename extension .exe.

OK

Saves the project under the name and in the location specified.

Cancel

Closes the dialog box without saving the file.

Options

Displays the Project Properties dialog box with the Make tab active. You can indicate the version number, information, and compatibility and the icon for your project.


Make Project Group Dialog Box

Allows you to choose the available projects that you want to build.

Dialog Box Options

Project List

Lists the projects that are available. You can choose as many projects as you want to build together.

Use Default Build Options

When checked, uses the options set in the Make tab of the Project Properties dialog box. If you have not changed the options, Visual Basic will use the default values and the project name for the build file names.

Build

Builds the project files.


Miscellaneous Tab (Connection Properties Dialog Box)

Using the Connection Properties dialog box you can set the required and additional properties of a Connection object. The properties are divided between three tabs: General, Authentication, and Miscellaneous.

Note The Connection Properties dialog box is only used by Visual InterDev.

On the Miscellaneous tab, specify other connection properties.

Timeouts

This frame contains the timeout control group of the selected Connection object.

Connection Timeout

The amount of time, in seconds, the provider waits while trying to open the data source. The default is 15 seconds.

Command Timeout

The amount of time, in seconds, the provider waits for a command to return from the server. The default is 30 seconds.

Other

This frame contains the miscellaneous control group properties of the selected Connection object.

Cursor Location

Specifies the location of the cursor library for the Connection object.

Attributes

Specify any additional parameters for this connection string. This is useful when Use OLE DB File or Use ODBC Data Source Name is selected on the General tab of the Connection Properties dialog box, but is available for all three sources.

Note Any string placed here is appended to the ConnectionString property when connecting to the data source.


New Project Dialog Box

Allows you to select the type of project you want to create. If there is currently another project or project group open, you will be asked to save any changes before the new project and group are created.

If you want to add projects to a project group, use the Add Project command on the File menu.

Dialog Box Options

List of projects

Displays the valid projects that you can add.

  • Standard EXE — Creates a standard executable file.

  • ActiveX EXE — Creates an ActiveX executable file.

  • ActiveX DLL — Creates an ActiveX DLL file.

  • ActiveX Control — Creates an ActiveX control.

  • VB Application Wizard — Generates a new, fully functional application from which you build a more complex application.

  • Any project with a .vbp (project file), .vbz (wizard file), or .vbg (project group) extension that is in the vb\template\projects directory.


New Tab (New Project and Add Project Dialog Boxes)

Note This tab is only available on the New Project dialog box that appears when you start Visual Basic and not on the New Project dialog box that you see when you choose New Project from the File menu.

Displays the project types you can add.

  • Standard EXE — Creates a standard executable file.

  • ActiveX EXE — Creates an ActiveX executable file.

  • ActiveX DLL — Creates an ActiveX DLL file.

  • ActiveX Control — Creates an ActiveX control.

  • Data Project — Creates a data project.

  • DHTML Application — Creates a DHTML application.

  • IISApplication — Creates an IIS Application.

Any projects with a .vbp (project files) or .vbz (wizard files) extension that are in the vb\template\projects directory.


Open Project Dialog Box

Let’s you locate and open a project or project group.

Dialog Box Options

Existing Tab

Displays a dialog box where you can locate and select the project that you want to open.

Recent Tab

Lists the most recently opened projects and their location.

Open

Displays the selected file.

Cancel

Closes the dialog box without opening a new project.


Options Dialog Box (Data Environment)

General Tab (Options Dialog Box)

Using the Options dialog box you can change the global settings of your Data Environment designer. The properties are divided between two tabs: General and Field Mapping.

On the General tab, specify the display and operation options for your Data Environment designer.

Show properties immediately after object creation

Specifies whether the Properties dialog box appears immediately after the Command or Connection object is added.

If selected, the properties dialog box appears after an object is added. If not selected (the default), no properties dialog box appears after an object is added.

This setting is stored in the system registry.

Prompt before deleting object

Specifies whether a confirmation dialog box displays when you delete an object. If selected (the default), a confirmation displays after an object is deleted. If not selected, no confirmation displays after an object is deleted.

Show status bar

If selected (the default), the Data Environment designer's status bar displays. If not selected, no status bar displays.

Show system objects

If selected (the default), the database's system tables display in the Database Objects box. If not selected, only user-created tables show.

Disable Warnings

If selected, all warning messages are disabled for the Data Environment designer. If not selected (the default), warning messages display, as appropriate.

Note It is recommended that warning messages remain enabled. Once disabled, the system will not alert you of effects of your requests, such as a deletion that may result in a broken connection.

Prompt before executing command

If selected (the default), the system prompts you before executing a Command object. If not selected, the system executes Command objects without providing any notice.


Options Dialog Box

Allows you to change default settings for Visual Basic development environment.

The Options dialog box has the following tabs:

  • Editor

  • Editor Format

  • General

  • Docking

  • Environment

  • Advanced


General Tab (Options Dialog Box)

Specifies the settings, the error handling, and compile settings for your current Visual Basic project.

Tab Options

Form Grid Settings

Determines the appearance of the form grid at design time.

  • Show Grid — Determines whether to show the grid at design time.

  • Grid Units — Displays the grid units used for the form. The default is points.

  • Width — Determines the width of grid cells on a form (2 to 60 points).

  • Height — Determines the height of grid cells on a form (2 to 60 points).

  • Align Controls to Grid — Automatically positions the outer edges of controls on grid lines.

Show ToolTips

Displays ToolTips for the toolbar and Toolbox items.

Collapse Proj. Hides Windows

Determines whether the window are hidden when a project is collapsed in the Project Explorer.

Error Trapping

Determines how errors are handled in the Visual Basic development environment and sets the default state of error trapping for all subsequent instances of Visual Basic. To set the error trapping option for only the current session of Visual Basic without changing the default for future sessions, use the Toggle command on the Code window's shortcut menu.

  • Break on All Errors — Any error causes the project to enter break mode, whether or not an error handler is active and whether or not the code is in a class module.

  • Break in Class Module — Any unhandled error produced in a class module causes the project to enter break mode at the line of code in the class module which produced the error.

    When you debug an ActiveX component project by running an ActiveX client test program in another project, set this option in the ActiveX component project to break on errors in its class modules, instead of always returning the error to the client test program.

  • Break on Unhandled Errors — If an error handler is active, the error is trapped without entering break mode. If there is no active error handler, the error causes the project to enter break mode. An unhandled error in a class module, however, causes the project to enter break mode on the line of code that invoked the offending procedure of the class.

Compile

Determines how your project compiles.

  • Compile On Demand — Determines whether a project is fully compiled before it starts, or whether code is compiled as needed, allowing the application to start sooner. If you choose the Start With Full Compile command on the Run menu, Visual Basic ignores the Compile on Demand setting and performs a full compile.

  • Background Compile — Determines whether idle time is used during run time to finish compiling the project in the background. Background Compile can improve run time execution speed. This feature is not available unless Compile on Demand is also selected.


Parameters Tab (Command Properties Dialog Box)

The Command Properties dialog box is divided into six tabs. The General, Parameters, and Advanced tabs are used for setting properties of the Command and Parameter objects, while the Relation, Grouping, and Aggregates tabs are used for setting properties that are specific to Command hierarchies.

On the Parameters tab, add to a Command object's Parameters collection.

Parameters

This list box contains all the Parameter objects that are associated with the Command object. Select a parameter and edit its properties, as appropriate.

Parameter Properties

This frame contains the control group with which you can change the property values of the selected Parameter object. This is disabled when no Parameter object is selected.

Name

The name of the Parameter. It is recommended that you change this to a more meaningful, unique name.

Direction

Specifies whether the parameter is an input or output parameter, or both, or if the parameter is the return value from the procedure. Select a value from combo box: Input, Output, Input and Output, Return Value, or Unknown.

Data Type

Specifies the data type to which a Data Environment Parameter object is converted.

Precision

The maximum number of digits, or precision, of the Data Environment Parameter object.

Note This applies to numeric fields and is disabled when the parameter is of a non-numeric type.

Scale

The maximum number of digits to the right of the decimal point of a Data Environment Parameter object.

Note This only applies to numeric fields and is disabled when the parameter is of a non-numeric type.

Size

The maximum size, in bytes, of the Parameter object.

Host Data Type

The data type that is used when the Parameter object is referenced by the host application. Changing the host data type affects the data type used in building the typelib information for the host.

Required

When selected, this indicates that a parameter value is required when executing the Command object.

Value

A value for the Parameter object. The Data Environment uses this value for design-time data binding, and run-time Command object execution.


Print Setup Dialog Box

Appears whenever you select the Printer Setup command.

Use the Print Setup dialog box to select the printer, page orientation, and paper size.

Dialog box options

Printer

Allows you to specify the printer. If you don't select a printer, Visual Basic will print to the Windows default printer.

  • Name — Displays a list of available printers.

  • Status — Displays the status of the printer and whether it is ready to print.

  • Type — Displays the type of printer.

  • Where — Displays the location of the printer. If the printer is on a network, displays the path to the server.

  • Comment — Displays the physical location of the printer and additional information.

  • Properties — Opens the Properties dialog box specific to the printer where you can choose additional options such as paper and the way graphics are printed.

Paper

Allows you to select the paper size and source (from among those available for the printer). The sizes and sources available depend on the printer you have selected and they change when you change printers.

  • Size — Displays a list of the available paper sizes.

  • Source — Displays the available source of paper for the printer you choose.

Orientation

Allows you to specify whether the program is to print in Portrait or Landscape orientation.


Procedure Attributes Dialog Box

Allows you to set the attributes for properties, methods, and events specified for a an item.

Only available if you have one or more procedures defined.

Dialog Box Options

Name

Lists the properties, methods, and events defined. The property, method, or event in the Code window in which the cursor is currently positioned appears selected.

Description

Displays the description of the property, method, or event that you want to show up in the Object Browser.

Project Help File

Displays the path to the help file for the project that is specified on the General tab of the Project Properties dialog box. This option is read only.

Help Context ID

Specifies the help context ID specified on the General tab of the Project Properties dialog box for the selected property or method.

OK

Applies the options to the selected property or method on the user control and closes the dialog box.

Apply

Applies the options to the selected property or method on the user control without closing the dialog box.

Advanced

Expands the dialog box to include the following options:

Procedure ID

Allows you to choose a standard member ID for the selected property, event, or method. The member ID is used to identify a property, method, or event as a standard type that control hosts may know about. A procedure whose ProcedureID is 0 acts as the default property or method for the control. It is also referred to as the Value property.

Note When you set a property, method, or event as a standard type, it does not change the behavior of the control. It tells a control container that the property, method, or event will behave in the well-understood way but it does not create the behavior. It is up to you to make sure that the control behaves correctly.

Caution If you make a public property or method of a class the default member for that class, you cannot edit the declaration for the member and change Public to Friend or Private without first removing the default attribute. If you inadvertently edit the declaration, make the member Public, remove the Default attribute, and then reset the declaration to Friend or Public.

Use this Page in Property Browser

Lists the Property Pages that are in the current project so you can select one to act as a builder when the property is chosen in the Property window. The property in the Property window is marked with a button and an ellipsis (…). When a user clicks the ellipsis, the Property Page specified is displayed.

Valid only for properties. Default is None.

Property Category

Lists available categories to describe the selected property. You can select a standard category or type in one of your own. When you type in a category, the property browser automatically creates a new level for the property.

Some property browsers such as Visual Basic allow you to categorize control properties. If the control host does not support property categorization, this setting will be ignored.

Valid only for properties. Default is None.

Attributes

Allows you to set some standard behaviors of the selected property, method, or event.

  • Hide this member — Determines whether the property, method, or event will appear to the end user of the control. If checked, it is hidden and cannot be seen in a property browser or the Object Browser. You can still write code to access it but it does not appear in the user interface.

  • User Interface Default — Determines which property is highlighted in the property browser or which event is displayed in the Code window when you double-click the control. There can be only one User Interface default property and one User Interface default event. Not valid for methods.

  • Don't show in Property Browser — Determines if a property, method, or event will be hidden in the property browser. It will continue to appear in the Object Browser and you can continue to write code to access it. This box is cleared when you choose Hide this member.

Data Binding

Determines whether a property can be bound or linked to a field in a database table.

  • Property is data bound — Determines if the property is a data bound property. If this option is selected, the property supports data binding and appears in the DataBindings collection. The box is cleared by default.

  • This property binds to DataField — Specifies whether the field to which the property is bound is specified in the DataField property. With this option, the end user does not have to use the Data Bindings collection and can use DataField. The box is cleared by default.

  • Show in DataBindings collection at design time — Determines if the property will appear in the user interface as bindable at design time. If selected, the property appears in the Bindings dialog box. If cleared, the property does not appear in the user interface as a bindable property but you can continue to write code to access it.

  • Property will call CanPropertyChange before changing — Tells the control container that the control will always call the CanPropertyChange method, and respect the return value, before changing a property value.

    The box is cleared by default.


Project Properties Dialog Box

Specifies the settings for a specific project.


Project Types

Project type is a new property added to each project. Project type determines:

  • The type of component build when you choose the Make Project command from the File menu.

  • Whether the ActiveX DLL restrictions are in effect for the project.

  • Whether a project can contain creatable public classes.

  • The valid options for the Startup Object.

The following table lists the project types and their characteristics and the characteristics of a Project Group.

Project Type | Standard EXE | ActiveX EXE | ActiveX DLL | ActiveX Control | Project Group
Type | EXE | EXE | DLL | DLL | Group
Default Extension | .exe | .exe | .dll | .ocx | .vbg
DLL Restrictions | No | No | Yes | Yes | No
Creatable Public Class | No | Yes | Yes | Yes | No
Start Mode | Stand Alone | ActiveX component | Cannot run unless a subproject in the main project. Automatically starts running when needed. | Cannot run unless a subproject in the main project. Automatically starts running when needed. | Cannot run unless a subproject in the main project. Automatically starts running when needed.
Default Startup Object | Form1 | None | None | None | None
Allowable Objects | MDI Form Form Module Class Module User Control Property Page ActiveX Designer | Form Module Class Module User Control Property Page User Document ActiveX Designer | Form Module Class Module User Control Property Page User Document ActiveX Designer | Form Module Class Module User Control Property Page ActiveX Designer |


Property Pages Dialog Box

Allows you to change a control's properties at design time.

Dialog Box Options

Tabs

Visual Basic creates a tabbed dialog box that acts like a form by writing code to handle updating property values when a user changes values in the control.

You can add Property Pages to your project using the Add Property Pages command on the Project menu.

OK

Validates the Property Pages settings and closes the Property Pages dialog box.

Apply

Validates the Property Page without closing the dialog box.


Recent Tab (New, Open, and Add Project Dialog Boxes)

Displays a list and location of recently opened projects so you can open them or add them to your project.

Dialog Box Options

File

Displays the list of recently opened project.

Folder

Displays the path to the folder in which the file is located.

Open

Opens the selected file and closes the dialog box.


Relation Tab (Command Properties Dialog Box)

The Command Properties dialog box is divided into six tabs. The General, Parameters, and Advanced tabs are used for setting properties of the Command and Parameter objects, while the Relation, Grouping, and Aggregates tabs are used for setting properties that are specific to Command hierarchies.

On the Relation tab, specify the properties for a relation hierarchy.

Note The properties on this tab do not apply to Visual InterDev.

Relate to a Parent Command Object

If selected, the current Command object is the child in a relation hierarchy, and all controls on the tab are enabled. If not selected, the Command object is not the child in a relation hierarchy, and all controls on the tab are disabled.

Parent Command

The Command object that is the parent to the child Command object. This can be any Command object that is associated with the same Connection object.

Relation Definition

This frame contains the control group that defines the Field and Parameter objects that specify the relationship between two Command objects. For example, if one Command object returns data from an Orders table and another returns data from a Customers table, you should use a field that exists in both tables, such as orderID.

Note You must link all required Parameter objects to the parent Command object. If the required parameters are not linked, an error occurs when you attempt to close the Command Properties dialog box.

The Relation Definition list shows the current definitions of Parent Field TO Child Field/Parameters.

Parent Fields

This drop-down list contains the Field objects of the parent Command object. When added, these show on the left side of the relate expression in the Relation Definition list.

Child Fields/Parameters

This drop-down list contains the Parameter or Field objects of the child Command object. The Child Fields/Parameters, when added, are used on the right of the relate expression in the Relation Definition. If the child Command object has input parameters, these parameters are listed first, and if these parameters are required, they must be related to fields in the parent object.

Note An error occurs if you attempt to exit the Command Properties dialog box and the required parameters do not have links set to parent fields.

Add

Click Add to create a new relation definition based on the contents of the Parent Field and Child Field/Parameters lists. The new relation shows in the Relation Definition list (for example, CustomerID TO CustomerID).

Note You can add more than one relation definition within each hierarchical relationship.

Remove

Select a relation from the Relation Definition list, and then click Remove to delete it.

Note There is no undo mechanism. Therefore, if the wrong relation is removed, it must be added again using the Add feature.


Rename Toolbar Dialog Box

Allows you to rename your custom toolbars.

Dialog Box Option

Toolbar name

Type a new name for your toolbar.


Settings Tab (Visual Basic Batch T-SQL Debugger Dialog Box)

Tab Options

DSN (Data Source Name)

Displays a list of DSNs currently installed on your computer to which you can connect. Use the 32-bit ODBC icon in the Control Panel to install new DSNs.

Register DSN

Displays the ODBC SQL Server Setup dialog box. See your ODBC documentation for additional information.

SQL Server

Allows you to type the name of the SQL server where the database resides. This information is required, even if a DSN is already provided.

Database

Allows you to type the name of the database to which you want to connect.

UID (User ID)

Allows you to type the User ID required to connect to this data source. If the data source does not require a user ID, you can leave this box blank.

Password

Allows you to type the password required to connect to the data source. If the data source does not require a password, you can leave this box blank.

Lock Type

Sets a long integer value indicating the type of concurrency handling.

Result Set

Specifies the type of cursor used to manage the result set.

Options

Specifies whether to use SQLExecDirect instead of SQLPrepare and SQLExecute.

Execute

Invokes the debugger and allows you to debug the SQL statements you are interested in.

Close

Closes the Batch T-SQL Debugger dialog box.


New Project Dialog Box (at StartUp)

Allows you to locate and open a new or existing project when you open Visual Basic.

Dialog Box Tabs

New Tab

Displays the project types you can open.

Existing Tab

Displays a dialog box where you can locate and select the project that you want to open.

Recent Tab

Lists the most recently opened projects and their location.

Don't show this dialog in the future

When selected automatically opens a new Standard EXE project without showing the New Project dialog box. To view the New Project dialog box in the future select the Prompt for project option on the Environment tab of the Options dialog box.


Component Tab (Project Properties Dialog Box)

Allows you to determine how your project starts.

Tab Options

Start Mode

Indicates how the application is started. This is used with ActiveX servers (Visual Basic, Professional and Enterprise Editions).

  • Standalone — Starts the application a standalone.

  • ActiveX Component — Starts the application as an ActiveX Server.

Remote Server

  • Remote Server Files (Enterprise Edition) — When checked, Visual Basic creates a file with a .vbr file name extension and the same filename as the .dll file. This .vbr file contains information needed by the Windows Registry to run an ActiveX Server on a remote computer. This option is only available in the Enterprise edition of Visual Basic.

Version Compatibility

Allows you to set the level of version compatibility

  • No Compatibility — Compatibility not enforced.

  • Project Compatibility — If checked, the Location box is active and allows you to search for the file with which this project is to be compatible. If cleared, the Location box is not available.

    For all ActiveX project types, Project Compatibility is checked by default.

  • Binary Compatibility — Useful for maintaining compatibility among projects that have been compiled using your component.

  • File Location Box — Displays the name and location of the file with the project is to be compatible. You can type a name and location or can use the Browse button to display the Compatible ActiveX Server dialog box where you can locate the file.


Stored Procedure Tab (Visual Basic Batch T-SQL Debugger Dialog Box)

Tab Options

Procedure Name

Allows you to select from the available stored procedures.

Query

Displays the SQL string that calls the stored procedure.

Parameters

Allows you to select from the parameters included in the selected stored procedure.

Data Type

Displays the data type of the selected parameter.

Value

Allows you to type the value of the selected parameter.


T-SQL Debugging Options Dialog Box

Lets you customize the T-SQL debugger.

To view this dialog, add the T-SQL Debugger to the development environment via the Add-In Manager command on the Add-Ins menu. Then, with the debugger loaded, choose T-SQL Debugging Options on the Tools menu.

Dialog Box Options

Automatically step into Stored Procedures through RDO and ADO connections

When selected, automatically steps into the stored procedure and displays the T-SQL Debugger each time you step into an RDO or ADO method that executes a stored procedure.

Once you select this option, if you step into a line of code that executes an RDO method that invokes a stored procedure, the debugger automatically starts.

Use Safe Mode (transaction rollback) for Stored Procedure calls

When selected, turns on Safe Mode, which automatically rolls back any design-time queries that you debug.

Limit SQL Output to the following number of lines per resultset

Limits the number of rows that appear in the T-SQL Debugger’s Output window when you debug design-time queries. The default is 500 lines per result set.

Login Timeout value for retrieving stored procedure text

Sets the login timeout value that the debugger uses to connect to the database to get the internal SQL State. The default is 10000.


User Credentials Dialog Box (Webclass Designer)

Prompts you for your network user login information when the webclass creates the virtual directory for your project on a network share. Microsoft Internet Information Server must associate this information with any virtual directory it creates so that it can authenticate future requests to that directory. This prompt appears the first time you run the project.

Dialog Box Options

UserID

Allows you to enter your user ID for verification. Must be a fully qualified user name — that is, if the user account is a member of a domain, the domain must also be specified in the format domain\user.

Password

Allows you to enter your password for verification.


Delete WebItem Dialog Box

Displays a list of all the HTML tag attributes that have been connected to the webitem you have chosen to delete. If you proceed to delete the webitem, the link between each attribute and the webitem will be disconnected.

Dialog Box Options

Template

Lists the template to which each tag attribute is connected.

Tag

Lists the name of each HTML tag attribute that currently references the webitem.

Navigate

Moves you to the currently selected attribute in the designer window.

OK

Deletes the webitem, removing the link between it and all of the listed attributes.


AccessKeyPress Event

Occurs when the user of the control presses one of the control’s access keys, or when the ENTER key is pressed when the developer has set the Default property to True, or when the ESCAPE key is pressed when the developer has set the Cancel property to True. The Default property and the Cancel property are enabled by the author of the control setting the DefaultCancel property to True.

Syntax

Sub object_AccessKeyPress(KeyAscii As Integer)

The AccessKeyPress event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
KeyAscii | An integer that contains the Ascii value of the key (without the ALT) that caused the AccessKeyPress event to fire, in the same manner as the standard KeyPress event.


Activate, Deactivate Events

  • Activate — occurs when an object becomes the active window.

  • Deactivate — occurs when an object is no longer the active window.

Syntax

Private Sub object_Activate( )

Private Sub object_Deactivate( )

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

An object can become active by user action, such as clicking it, or by using the Show or SetFocus methods in code.

The Activate event can occur only when an object is visible. For example, a form loaded with the Load statement isn't visible unless you use the Show method or set the form's Visible property to True.

The Activate and Deactivate events occur only when moving the focus within an application. Moving the focus to or from an object in another application doesn't trigger either event. The Deactivate event doesn't occur when unloading an object.

The Activate event occurs before the GotFocus event; the LostFocus event occurs before the Deactivate event.

These events occur for MDI child forms only when the focus changes from one child form to another. In an MDIForm object with two child forms, for example, the child forms receive these events when the focus moves between them. However, when the focus changes between a child form and a non-MDI child form, the parent MDIForm receives the Activate and Deactivate events.

If an .exe file built by Visual Basic displays a dialog box created by a .dll file also built in Visual Basic, the .exe file's form will get the Deactivate and LostFocus events. This may be unexpected, because you should not get the Deactivate event:

  • If the object is an out-of-process component.

  • If the object isn't written in Visual Basic.

  • In the development environment when calling a DLL built in Visual Basic.


Activate, Deactivate Events Example

This example updates the status bar text to display the caption of the active form. To try this example, create a Form object (Form1) and a new MDIForm object (MDIForm1). On MDIForm1, draw a PictureBox control containing a Label control. On Form1, set the MDIChild property to True. Paste the MDIForm_Load event procedure code into the Declarations section of the MDIForm object. Paste the Form_Activate event procedure code into the Declarations section of the MDI child form, and then press F5.

Private Sub MDIForm_Load ()
   Form1.Caption = "Form #1"      ' Set caption of Form1.
   Dim NewForm As New Form1      ' Create a new child form.
   Load NewForm
   NewForm.Caption = "Form #2"   ' Set caption of new form.
   NewForm.Show                  ' Display the new form.
End Sub

Private Sub Form_Activate ()
      ' Set status bar text.
   MDIForm1.Label1.Caption = "Current form: " & Me.Caption
End Sub


AmbientChanged Event

Occurs when an ambient property’s value changes.

Syntax

Sub object_AmbientChanged(PropertyName As String)

The AmbientChanged event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
PropertyName | A string that identifies the ambient property that has changed.

Remarks

Using PropertyName, the control can access the AmbientProperties object in the Ambient property to check for the new value of the changed ambient property.

If an instance of the control is placed on a Visual Basic form, and the FontTransparent property of the form is changed, the AmbientChanged event will not be raised.


ApplyChanges Event

Occurs when the user presses the OK button or the Apply button on the property page, or when property pages are switched by selecting tabs.

Syntax

Sub object_ApplyChanges()

The ApplyChanges event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

When the ApplyChanges event is raised, the author of the property page needs to handle the setting of all the new property values to the controls; hopefully the author kept track of which properties were changed, otherwise all properties will have to be set. To know what controls are to be changed, use the SelectedControls property.

The ApplyChanges event will be raised only if the Changed property is set to True.


Error Event (Data Report Designer)

Occurs when an error halts an operation.

Syntax

Private Sub object_Error(JobType As AsyncTypeConstants, Cookie As Long, ErrObj As RptError, ShowError As Boolean)

The Error event syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
JobType | Returns the type of operation, as shown in Settings.
Cookie | Returns the ID of the operation. The ID is set when an asynchronous method such as ExportReport or PrintReport is invoked.
ErrObj | Returns the number of the error.
ShowError | Sets a value that specifies if the error dialog displays.

Settings

The JobType settings are:

Constant | Value | Description
rptAsyncPreview | 0 | The report is processing a Preview operation.
rptAsyncPrint | 1 | The report is processing a Print operation.
rptAsyncReport | 2 | The report is processing an ExportReport operation.


AsyncProgress Event

Occurs during an asynchronous operation, as each page of data has been processed by the specific operation (determined by the JobType argument).

Syntax

Private Sub object_AsyncProgress(JobType As AsyncTypeConstants, Cookie As Long, PageCompleted As Long, TotalPages As Long)

The AsyncProgress event syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
JobType | An integer that specifies the type of operation, as shown in Settings.
Cookie | A Long integer that identifies the specific operation.
PageCompleted | A variant that returns the number of completed pages.
TotalPages | A variant that returns the total number of pages to be processed.

Settings

The JobType settings are:

Constant | Value | Description
rptAsyncPreview | 0 | The report is processing a Preview operation.
rptAsyncPrint | 1 | The report is processing a PrintReport operation.
rptAsyncReport | 2 | The report is processing an ExportReport operation.


AsyncReadComplete Event

Occurs when the container has completed an asynchronous read request.

Syntax

Sub object_AsyncReadComplete(AsyncProp As AsyncProperty)

The AsyncReadComplete event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
AsyncProp | An AsyncProperty object.

Remarks

The value in AsyncProp specifies the particular asynchronous data read request that has completed, and matches the value given in a previous AsyncRead method invocation.

Error handling code should be placed in the AsyncReadComplete event procedure, because an error condition may have stopped the download. If this was the case, that error will be raised when the Value property of the AsyncProperty object is accessed.


AsyncReadProgress Event

Occurs when more data is available as a result of an AsyncRead method.

Syntax

Sub object_AsyncReadProgress(AsyncProp As AsyncProperty)

The AsyncReadProgress event syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
AsyncProp | An AsyncProperty object.

Remarks

The AsyncReadProgress event gives you access to the progressive status of an asynchronous download.

If the AsyncType for the AsyncRead method is set to either vbAsyncTypeFileName or vbAsyncTypeByteArray, you can have access to the partially downloaded data during a download. Normally, Visual Basic keeps the file open during the entire download process. Getting the Value for vbAsyncTypeFileName slows the download process (but not significantly over a slow link), because Visual Basic must close the file each time before firing the event, and then re-open the file the next time data is available.

If you open the file, then you must close it before the code inside the AsyncReadProgress event completes (or before calling DoEvents or otherwise allowing a Windows message to be dispatched), otherwise an error will occur, preventing the AsyncReadProgress event from firing. To avoid this, include error-handling code in the AsyncReadComplete event procedure.

Note The firing of the AsyncReadProgress and AsyncReadComplete events is message-based. That is, a Windows notification message is posted and must be dispatched by the applications message pump to fire. Therefore, you should avoid loop structures in the code of these events. Also avoid using DoEvents, since it'll unexpectedly cause the code to be re-entrant.

Both the AsyncReadProgress and AsyncReadComplete events occur when the download completes. (That is, AsyncProp.StatusCode = vbAsyncStatusCodeEndDownloadData.)


BeginRequest Event

Occurs when the user selects an element on an HTML page that sends a request to the WebClass object. Marks the beginning of processing for an HTTP request.

Syntax

Private Sub object_BeginRequest()

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remark

This event is raised before any other events when an HTTP request is received.


Change Event

Indicates the contents of a control have changed. How and when this event occurs varies with the control:

  • ComboBox — changes the text in the text box portion of the control. Occurs only if the Style property is set to 0 (Dropdown Combo) or 1 (Simple Combo) and the user changes the text or you change the Text property setting through code.

  • DirListBox — changes the selected directory. Occurs when the user double-clicks a new directory or when you change the Path property setting through code.

  • DriveListBox — changes the selected drive. Occurs when the user selects a new drive or when you change the Drive property setting through code.

  • HScrollBar and VScrollBar (horizontal and vertical scroll bars) — move the scroll box portion of the scroll bar. Occurs when the user scrolls or when you change the Value property setting through code.

  • Label — changes the contents of the Label. Occurs when a DDE link updates data or when you change the Caption property setting through code.

  • PictureBox — changes the contents of the PictureBox. Occurs when a DDE link updates data or when you change the Picture property setting through code.

  • TextBox — changes the contents of the text box. Occurs when a DDE link updates data, when a user changes the text, or when you change the Text property setting through code.

Syntax

Private Sub object_Change([index As Integer])

The Change event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array

Remarks

The Change event procedure can synchronize or coordinate data display among controls. For example, you can use a scroll bar's Change event procedure to update the scroll bar's Value property setting in a TextBox control. Or you can use a Change event procedure to display data and formulas in a work area and results in another area.

Change event procedures are also useful for updating properties in file-system controls (DirListBox, DriveListBox, and FileListBox). For example, you can update the Path property setting for a DirListBox control to reflect a change in a DriveListBox control's Drive property setting.

Note A Change event procedure can sometimes cause a cascading event. This occurs when the control's Change event alters the control's contents, for example, by setting a property in code that determines the control's value, such as the Text property setting for a TextBox control. To prevent a cascading event:

  • If possible, avoid writing a Change event procedure for a control that alters that control's contents. If you do write such a procedure, be sure to set a flag that prevents further changes while the current change is in progress.

  • Avoid creating two or more controls whose Change event procedures affect each other, for example, two TextBox controls that update each other during their Change events.

  • Avoid using a MsgBox function or statement in this event for HScrollBar and VScrollBar controls.


Changed Event

Occurs when a property of the StdDataFormat object changes.

Syntax

object_Changed()

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

To use the event, declare an object variable in the Declarations section, as type StdDataFormat, using the WithEvents keyword as shown below:

Option Explicit
Private WithEvents fmtMyFormat As StdDataFormat

Private Sub fmtMyFormat_Changed()
   ' Handle change event here.
End Sub


Changed Event Example

The example prints out the number of times the Changed event has occurred. The example assumes that a TextBox control has been bound to a data source, such as the ADO Data Control, at design time.

Option Explicit
Private WithEvents fmtMyFormat As StdDataFormat

Private Sub Form_Load()
   Set fmtMyFormat = New StdDataFormat
   fmtMyFormat.Format = "Long Date"
   Set Text1.DataFormat = fmtMyFormat
End Sub

Private Sub Command1_Click()
   fmtMyFormat.FirstDayOfWeek = fmtMonday
End Sub

Private Sub fmtMyFormat_Changed()
    Static fmtMyFormatChange As Integer
    fmtMyFormatChange = fmtMyFormatChange + 1
    Debug.Print "CHANGED", fmtMyFormatChange
End Sub


Change Event Example

This example displays the numeric setting of a horizontal scroll bar's Value property in a TextBox control. To try this example, create a form with a TextBox control and an HScrollBar control and then paste the code into the Declarations section of a form that contains a horizontal scroll bar (HScrollBar control) and a TextBox control. Press F5 and click the horizontal scroll bar.

Private Sub Form_Load ()
   HScroll1.Min = 0               ' Set Minimum.
   HScroll1.Max = 1000            ' Set Maximum.
   HScroll1.LargeChange = 100   ' Set LargeChange.
   HScroll1.SmallChange = 1      ' Set SmallChange.
End Sub

Private Sub HScroll1_Change ()
   Text1.Text = HScroll1.Value
End Sub


Click Event

Occurs when the user presses and then releases a mouse button over an object. It can also occur when the value of a control is changed.

For a Form object, this event occurs when the user clicks either a blank area or a disabled control. For a control, this event occurs when the user:

  • Clicks a control with the left or right mouse button. With a CheckBox, CommandButton, Listbox, or OptionButton control, the Click event occurs only when the user clicks the left mouse button.

  • Selects an item in a ComboBox or ListBox control, either by pressing the arrow keys or by clicking the mouse button.

  • Presses the SPACEBAR when a CommandButton, OptionButton, or CheckBox control has the focus.

  • Presses ENTER when a form has a CommandButton control with its Default property set to True.

  • Presses ESC when a form has a Cancel button — a CommandButton control with its Cancel property set to True.

  • Presses an access key for a control. For example, if the caption of a CommandButton control is "&Go", pressing ALT+G triggers the event.

You can also trigger the Click event in code by:

  • Setting a CommandButton control's Value property to True.

  • Setting an OptionButton control's Value property to True.

  • Changing a CheckBox control's Value property setting.

Syntax

Private Sub Form_Click( )

Private Sub object_Click([index As Integer])

The Click event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

Typically, you attach a Click event procedure to a CommandButton control, Menu object, or PictureBox control to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to a change in the control.

You can use a control's Value property to test the state of the control from code. Clicking a control generates MouseDown and MouseUp events in addition to the Click event. The order in which these three events occur varies from control to control. For example, for ListBox and CommandButton controls, the events occur in this order: MouseDown, Click, MouseUp. But for FileListBox, Label, or PictureBox controls, the events occur in this order: MouseDown, MouseUp, and Click. When you're attaching event procedures for these related events, be sure that their actions don't conflict. If the order of events is important in your application, test the control to determine the event order.

Note To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

If there is code in the Click event, the DblClick event will never trigger, because the Click event is the first event to trigger between the two. As a result, the mouse click is intercepted by the Click event, so the DblClick event doesn't occur.


Click Event Example

In this example, each time a PictureBox control is clicked it moves diagonally across a form. To try this example, paste the code into the Declarations section of a form that contains a PictureBox control positioned at the lower-left corner of the form, and then press F5 and click the PictureBox.

Private Sub Picture1_Click ()
   Picture1.Move Picture1.Left + 750, Picture1.Top - 550
End Sub


CloseQuery Event

Occurs after you close a query window.

Syntax

object.CloseQuery(value)

Parameters

The CloseQuery event syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A value that specifies the most recent DECommand object that was edited in the query window.


DblClick Event

Occurs when the user presses and releases a mouse button and then presses and releases it again over an object.

For a form, the DblClick event occurs when the user double-clicks a disabled control or a blank area of a form. For a control, it occurs when the user:

  • Double-clicks a control with the left mouse button.

  • Double-clicks an item in a ComboBox control whose Style property is set to 1 (Simple) or in a FileListBox, ListBox, DataCombo, or DataList control.

Syntax

Private Sub Form_DblClick ( )

Private Sub object_DblClick (index As Integer)

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | Identifies the control if it's in a control array.

Remarks

The argument Index uniquely identifies a control if it's in a control array. You can use a DblClick event procedure for an implied action, such as double-clicking an icon to open a window or document. You can also use this type of procedure to carry out multiple steps with a single action, such as double-clicking to select an item in a list box and to close the dialog box.

To produce such shortcut effects in Visual Basic, you can use a DblClick event procedure for a list box or file list box in tandem with a default button — a CommandButton control with its Default property set to True. As part of the DblClick event procedure for the list box, you simply call the default button's Click event.

For those objects that receive Mouse events, the events occur in this order: MouseDown, MouseUp, Click, DblClick, and MouseUp.

If DblClick doesn't occur within the system's double-click time limit, the object recognizes another Click event. The double-click time limit may vary because the user can set the double-click speed in the Control Panel. When you're attaching procedures for these related events, be sure that their actions don't conflict. Controls that don't receive DblClick events may receive two clicks instead of a DblClick.

When debugging events, do not use MsgBox statements to show when the event occurred, as this will disturb the normal functioning of many events. (For example, a MsgBox in the Click event will prevent DblClick from being raised.) Instead, use Debug.Print to show the order in which events occur

Note To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.


DblClick Event Example

This example displays a selected list item in a TextBox control when either a CommandButton control is clicked or a list item is double-clicked. To try this example, paste the code into the Declarations section of a Form object that contains a ListBox control, a TextBox control, and a CommandButton control. Then run the example and click the CommandButton control or double-click an item in the ListBox control.

Private Sub Form_Load ()
   List1.AddItem "John"   ' Add list box entries.
   List1.AddItem "Paul"
   List1.AddItem "George"
   List1.AddItem "Ringo"
End Sub

Private Sub List1_DblClick ()
   Command1.Value = True   ' Trigger Click event.
End Sub

Private Sub Command1_Click ()
   Text1.Text = List1.Text   ' Display selection.
End Sub


DECommandAdded Event

Occurs after a DECommand object is added to a DataEnvironment object.

Syntax

Sub object_DECommandAdded(value)

The DECommandAdded event syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A value that specifies the DECommand object that was added to the DataEnvironment object.


DECommandPropertyChanged Event

Occurs after any property of the DECommand object is changed.

Syntax

Sub object_DECommandPropertyChanged(value, string)

The DECommandPropertyChanged event syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A value that specifies the DECommand object that had its property value changed.
string | A string expression that specifies the name of the property that was changed.

Remarks

If multiple properties are changed at once, this event generates once for each modified property.


DECommandRemoved Event

Occurs after a DECommand object is removed from the DataEnvironment object.

Syntax

Object_DECommandRemoved(value)

The DECommandRemoved event syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A value that specifies the DECommand object that was removed.


DEConnectionAdded Event

Occurs after a DEConnection object is added to the DataEnvironment object.

Syntax

Sub object_DEConnectionAdded(value)

The DEConnectionAdded event syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A value that specifies the DEConnection object that was added to the DataEnvironment object.

Remarks

This event occurs each time a DEConnection object is added to the DataEnvironment object, regardless of whether it was added through the user interface or using the Add method through the Extensibility Object Model.


DEConnectionPropertyChanged Event

Occurs after any property of the DEConnection object is changed.

Syntax

Sub object_DEConnectionPropertyChanged(value, string)

The DEConnectionPropertyChanged event syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A value that specifies the DEConnection object that had its property value changed.
string | A string expression that specifies the name of the property that was changed.

Remarks

If multiple properties are changed at once, this event generates for each modified property.


DEConnectionRemoved Event

Occurs after a DEConnection object is removed from the DataEnvironment object.

Syntax

Sub object.ConnectionRemoved(value)

The ConnectionRemoved event syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A value that specifies the removed DEConnection object.


DEDesignerDelete Event

Occurs when the Data Environment designer window is closed.

Syntax

Sub object_DEDesignerDelete

The DEDesignerDelete event syntax has this parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.


DragDrop Event

Occurs when a drag-and-drop operation is completed as a result of dragging a control over an object and releasing the mouse button or using the Drag method with its action argument set to 2 (Drop).

Syntax

Private Sub Form_DragDrop(source As Control, x As Single, y As Single)

Private Sub MDIForm_DragDrop(source As Control, x As Single, y As Single)

Private Sub object_DragDrop([index As Integer,]source As Control, x As Single, y As Single)

The DragDrop event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.
source | The control being dragged. You can include properties and methods in the event procedure with this argument — for example, Source.Visible = 0.
x, y | A number that specifies the current horizontal (x) and vertical (y) position of the mouse pointer within the target form or control. These coordinates are always expressed in terms of the target's coordinate system as set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties.

Remarks

Use a DragDrop event procedure to control what happens after a drag operation is completed. For example, you can move the source control to a new location or copy a file from one location to another.

When multiple controls can potentially be used in a source argument:

  • Use the TypeOf keyword with the If statement to determine the type of control used with source.

  • Use the control's Tag property to identify a control, and then use a DragDrop event procedure.

Note Use the DragMode property and Drag method to specify the way dragging is initiated. Once dragging has been initiated, you can handle events that precede a DragDrop event with a DragOver event procedure.


DragDrop Event Example

This example demonstrates the visual effect of dropping a PictureBox control onto another PictureBox control. To try this example, paste the code into the Declarations section of a form that contains three PictureBox controls. Set the DragMode property for Picture1 and Picture2 to 1 (Automatic). Use the Picture property to assign bitmaps to Picture1 and Picture2, and then press F5 and drag Picture1 or Picture2 over Picture3.

Private Sub Picture3_DragDrop (Source As Control, X as Single, Y As Single)
   If TypeOf Source Is PictureBox Then
      ' Set Picture3 bitmap to same as source control.
      Picture3.Picture = Source.Picture
   End If
End Sub


DragOver Event

Occurs when a drag-and-drop operation is in progress. You can use this event to monitor the mouse pointer as it enters, leaves, or rests directly over a valid target. The mouse pointer position determines the target object that receives this event.

Syntax

Private Sub Form_DragOver(source As Control, x As Single, y As Single, state As Integer)

Private Sub MDIForm_DragOver(source As Control, x As Single, y As Single, state As Integer)

Private Sub object_DragOver([index As Integer,]source As Control, x As Single, y As Single, state As Integer)

The DragOver event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.
source | The control being dragged. You can refer to properties and methods in the event procedure with this argument — for example, Source.Visible = False.
x, y | A number that specifies the current horizontal (x) and vertical (y) position of the mouse pointer within the target form or control. These coordinates are always expressed in terms of the target's coordinate system as set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties.
state | An integer that corresponds to the transition state of the control being dragged in relation to a target form or control:
0 = Enter (source control is being dragged within the range of a target).
1 = Leave (source control is being dragged out of the range of a target).
2 = Over (source control has moved from one position in the target to another).

Remarks

Use a DragOver event procedure to determine what happens after dragging is initiated and before a control drops onto a target. For example, you can verify a valid target range by highlighting the target (set the BackColor or ForeColor property from code) or by displaying a special drag pointer (set the DragIcon or MousePointer property from code).

Use the state argument to determine actions at key transition points. For example, you might highlight a possible target when state is set to 0 (Enter) and restore the object's previous appearance when state is set to 1 (Leave).

When an object receives a DragOver event while state is set to 0 (Enter):

  • If the source control is dropped on the object, that object receives a DragDrop event.

  • If the source control isn't dropped on the object, that object receives another DragOver event when state is set to 1 (Leave).

Note Use the DragMode property and Drag method to specify the way dragging is initiated. For suggested techniques with the source argument, see Remarks for the DragDrop event topic.


DragOver Event Example

This example demonstrates one way to indicate a valid drop target. The pointer changes from the default arrow to a special icon when a TextBox control is dragged over a PictureBox control. The pointer returns to the default when the source is dragged elsewhere. To try this example, paste the code into the Declarations section of a form that contains a small TextBox and a PictureBox. Set the TextBox control's DragMode property to 1, and then press F5 and drag the TextBox over the PictureBox.

Private Sub Picture1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
   Select Case State
      Case vbEnter
   ' Load icon.
         Source.DragIcon = LoadPicture("ICONS\ARROWS\POINT03.ICO")
      Case vbLeave
         Source.DragIcon = LoadPicture()   ' Unload icon.
   End Select
End Sub

Private Sub Picture1_DragDrop (Source As Control, X As Single, Y As Single)
   Source.DragIcon = LoadPicture()   ' Unload icon.
End Sub


DropDown Event

Occurs when the list portion of a ComboBox control is about to drop down; this event doesn't occur if a ComboBox control's Style property is set to 1 (Simple Combo).

Syntax

Private Sub object_DropDown([index As Integer])

The DropDown event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

Use a DropDown event procedure to make final updates to a ComboBox list before the user makes a selection. This enables you to add or remove items from the list using the AddItem or RemoveItem methods. This flexibility is useful when you want some interplay between controls — for example, if what you want to load into a ComboBox list depends on what the user selects in an OptionButton group.


DropDown Event Example

This example updates a ComboBox control based on the user's selection in an option button group. To try this example, paste the code into the Declarations section of a form that contains a ComboBox control and two OptionButton controls. Set the Name property of both OptionButton controls to OptionGroup, and then press F5 and click the OptionButton controls. The ComboBox control reflects different carriers depending on the OptionButton selected.

Private Sub Form_Load ()
   Combo1.Text = ""   ' Clear combo box.
End Sub

Private Sub Combo1_DropDown ()
   Combo1.Clear            ' Delete existing items.
   If OptionGroup(0).Value = True Then
      Combo1.AddItem "Gray Goose Express", 0
      Combo1.AddItem "Wild Fargo Carriers", 1
   Else
      Combo1.AddItem "Summit Technologies Overnight"
   End If
End Sub


EditProperty Event

Occurs when a property page is opened because of the developer pressing the ellipsis button to display a particular property for editing.

Syntax

Sub object_EditProperty(PropertyName As String)

The EditProperty event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
PropertyName | A string that identifies the property that is to be displayed and edited by the property page.

Remarks

This event happens when a property is assigned a property page via the Attributes dialog box. Assigning a property page through the Attributes dialog box means that the property is displayed in the Properties window with an ellipsis (…) next to it, and the developer can press the ellipsis button and the property page is automatically opened; the EditProperty event is then raised, so that the property page author can put the cursor on the correct field.


EditQuery Event

Occurs when you modify the SQL text of a DECommand object by either clicking Build in the Command Properties dialog box or selecting Design from the shortcut menu or Data Environment designer toolbar.

Syntax

Sub object_EditQuery(value, string1, string2)

Parameters

The EditQuery event syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A value that specifies the DECommand object whose SQL text is being modified.
string1 | A string expression that specifies the existing SQL text of the DECommand object.
string2 | A string expression that specifies the connection string of the associated DEConnection object.

Remarks

This property enables communication between Data View and the Data Environment designer.


EndRequest Event

Occurs when the WebClass object finishes processing an HTTP request and returns a response to the client.

Syntax

Private Sub object_EndRequest()

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remark

Unless a fatal error occurs, the EndRequest is the last event received by a WebClass for a given HTTP request. If a fatal error occurs before EndRequest is fired, the EndRequest event will not be fired. If a fatal error occurs within the EndRequest event, the FatalErrorResponse event will be fired after the EndRequest event.


EnterFocus Event

Occurs when focus enters the object. The object itself could be receiving focus, or a constituent control could be receiving focus.

Syntax

Sub object_EnterFocus()

The EnterFocus event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

This event is useful if object needs to know that the focus is now inside of it.

The EnterFocus event is raised before any GotFocus event; the GotFocus event will only be raised in object or constituent control of object that actually got the focus.


ExitFocus Event

Occurs when focus leaves the object. The object itself could be losing focus, or a constituent control could be losing focus.

Syntax

Sub object_ExitFocus()

The ExitFocus event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

This event is useful if object needs to know that the focus is now leaving it.

The ExitFocus event is raised after any LostFocus event; the LostFocus event will only be raised in object or constituent control of object that actually loses the focus.


FatalErrorResponse Event

Occurs when the processing of a WebClass object is terminated due to an error.

Syntax

Private Sub object_FatalErrorResponse(senddefault As Boolean)

The FatalErrorResponse event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
senddefault | When set to True, senddefault signals that the default Active Server Pages error message should be returned to the browser. If the WebClass object writes its own message, senddefault should be set to False to prevent default processing.

Remarks

If the WebClass is terminated and you choose to write your own error message, such as

senddefault=false

then the code to write the message must be placed inside this event.

Any Visual Basic error or terminal error will cause a FatalErrorResponse event.


FontChanged Event

Occurs when a property of a stdFont object changes at run time.

Syntax

Private Sub object_FontChanged(ByVal PropertyName As String)

The FontChanged event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
PropertyName | A string returning the name of the stdFont object property that has changed. Possible values include Bold, Italic, Name, and Size.

Remarks

The FontChanged event will occur only if the stdFont object is declared using the WithEvents keyword and only for the stdFont object. An object declared as Font rather than as stdFont can’t use the WithEvents keyword and will cause an automation error. The FontChanged event is primarily useful for User controls.


Format Event (StdDataFormat Object)

Occurs after the StdDataFormat object formats the value.

Syntax

Sub object_Format(ByRef datavalue As StdDataValue)

The Format event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
datavalue | StdDataValue object.

Remarks

The Format event allows you to do formatting that the standard settings of the StdDataFormat object cannot accomplish.


GetDataMember Event

Occurs when a data consumer requests a new data source.

Syntax

Private Sub object_GetDataMember(DataMember As String, Data As Object)

The GetDataMember event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
DataMember | A string containing the name of the data member to be bound as a data source.
Data | An object reference to an ADO RecordSet object or a class which implements the OLEDBSimpleProvider interface.

Remarks

The GetDataMember event is available only when an object’s DataSourceBehavior property is set to vbDataSource or vbOLEDBProvider (for classes only). You can add code to the GetDataMember event procedure to initialize a data member or to select from multiple data members within an object.


GetDataMember Event Example

This example uses the GetDataMember event to determine what data will be provided by a data source class.

Option Explicit
Private rsFirst As ADODB.Recordset
Private rsSecond As ADODB.Recordset
Private rsDefault As ADODB.Recordset

Private Sub Class_GetDataMember(DataMember As String, Data As Object)
   Select Case DataMember
      Case "First"
         Set Data = rsFirst
      Case "Second"
         Set Data = rsSecond
      Case “”   ‘ default
         Set Data = rsDefault
      Case Else
         Err.Raise 99999, "DataSource", "Invalid DataMember"
   End Select
End Sub


GetQueryText Event

Occurs when the source of a Command object is changed.

Syntax

Sub object_GetQueryText(value)

Parameters

The GetQueryText event syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A value that specifies the DECommand object whose source has changed.

Remarks

This property enables communication between Data View and the Data Environment designer.


GotFocus Event

Occurs when an object receives the focus, either by user action, such as tabbing to or clicking the object, or by changing the focus in code using the SetFocus method. A form receives the focus only when all visible controls are disabled.

Syntax

Private Sub Form_GotFocus( )

Private Sub object_GotFocus([index As Integer])

The GotFocus event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

Typically, you use a GotFocus event procedure to specify the actions that occur when a control or form first receives the focus. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user by displaying brief instructions or status bar messages. You can also provide visual cues by enabling, disabling, or showing other controls that depend on the control that has the focus.

Note An object can receive the focus only if its Enabled and Visible properties are set to True. To customize the keyboard interface in Visual Basic for moving the focus, set the tab order or specify access keys for controls on a form.


GotFocus Event (UserControl Object and UserDocument Object)

Occurs in the object or constituent control when focus enters it.

Syntax

Sub object_GotFocus()

The GotFocus event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

This GotFocus event is not the same GotFocus extender event that the developer who uses object handles. This GotFocus event is for the author of object, and is internal to object.

This event is useful if object needs to know that the focus is now on it.

Object itself can get focus only when the CanGetFocus property is True and there are no constituent controls that can receive the focus.

The EnterFocus event is raised before the GotFocus event.

Do not raise the GotFocus extender event from this event.


GotFocus Event Example

This example displays a status bar message when a button in an OptionButton group gets the focus. To try this example, paste the code into the Declarations section of a form that contains two OptionButton controls and a Label control. Set the Name property for both OptionButton controls to OptionGroup, and then press F5 and click the OptionButton controls.

Private Sub Form_Load ()
   Label1.AutoSize = True
End Sub

Private Sub OptionGroup_GotFocus (Index As Integer)
   Select Case Index
      Case 0
         Label1.Caption = "Option 1 has the focus."
      Case 1
         Label1.Caption = "Option 2 has the focus."
   End Select
End Sub

Private Sub OptionGroup_LostFocus (Index As Integer)
   Label1.Caption = ""
End Sub


Hide Event (UserControl Object)

Occurs when the object’s Visible property changes to False.

Syntax

Sub object_Hide()

The Hide event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

In order to draw to the screen in Windows, any object must have a window, temporarily or permanently; Visual Basic ActiveX controls have permanent windows. Before a control has been sited on a form, its window is not on the container. The control receives Hide events when the window is removed.

While the control’s window is on the form, the object receives a Hide event when the control’s Visible property changes to False.

The control does not receive Hide events if the form is hidden and then shown again, or if the form is minimized and then restored. The control’s window remains on the form during these operations, and its Visible property doesn’t change.

If the control is being shown in an internet browser, a Hide event occurs when the page is moved to the history list.

Note If the control is used with earlier versions of Visual Basic than 5.0, the control will not receive Hide events at design time. This is because earlier versions of Visual Basic did not put any visible windows on a form at design time.


Hide Event (UserDocument Object)

Occurs when the object’s Visible property changes to False.

Syntax

Sub object_Hide()

The Hide event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

In order to draw to the screen in Windows, any object must have a window, temporarily or permanently. Visual Basic ActiveX documents have permanent windows. The UserDocument object receives Hide events when the window is removed.

While object’s window is on the container, object receives a Hide event when object’s Visible property changes to False.

Object does not receive Hide events if the container is hidden and then shown again, or if the container is minimized and then restored. Object’s window remains on the container during these operations, and its Visible property doesn’t change.

If object is being shown in an internet browser, a Hide event occurs when the page is moved to the history list by navigating off object to another document, or when Internet Explorer 3.0 is terminated while object is being viewed or is still within the cache of active documents. Use the event to destroy any global object references before navigating to another document.

Note If object is used with earlier versions of Visual Basic than 5.0, object will not receive Hide events at design time. This is because earlier versions of Visual Basic did not put any visible windows on a form at design time.


HitTest Event

Occurs when the user moves the mouse over a UserControl object. Only occurs when the Windowless property of the UserControl is set to True and the BackStyle property is set to Transparent.

Syntax

Private Sub object_HitTest(x As Single, y As Single, HitResult As Integer)

The HitTest event syntax has these parts:

Part | Description
object | A UserControl object.
x, y | A number that specifies the current location of the mouse pointer. The x and y values are always expressed in terms of the coordinate system set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of the object.
HitResult | An integer that specifies hit behavior, as described in Settings.

Settings

The settings for HitResult are:

Constant | Setting | Description
vbHitResultOutside | 0 | The mouse pointer is outside of the visible area of the control. Mouse messages are forwarded.
vbHitResultTransparent | 1 | The mouse pointer is over a transparent region of the control. Mouse messages can be forwarded. Must be set at run time.
vbHitResultClose | 2 | The mouse pointer is close to the visible area of the control. The close region must be defined by the developer at design time. Mouse messages can be forwarded. Must be set at run time.
vbHitResultHit | 3 | The mouse pointer is over the visible area of the control. The control receives mouse messages.

Remarks

The HitTest event is used to determine whether a UserControl will receive mouse events such as MouseUp, MouseDown, MouseOver, Click, and DblClick. HitTest occurs before any other mouse messages.

By default, a UserControl will return a HitResult of 0 when the mouse pointer is over a transparent area of the control, or a HitResult of 3 when over the MaskRegion. The MaskRegion is defined by a combination of the MaskPicture and MaskColor properties.

In the HitTest event you can change the hit testing behavior of your control by assigning a different value to the HitResult. For example, if you have a UserControl with a transparent area in its center, it’s possible that another control may be visible underneath that area. By changing the HitResult to 1 or 2 in the HitTest event, you can allow the control underneath to receive the mouse messages. If there is nothing underneath at run time or if the control underneath declines the hit, your control will get a second or third chance to receive the mouse messages.

Hit testing is performed in the following order for multiple overlapping controls:

  • The topmost control in the ZOrder that returns a HitResult of 3 (vbHitResultHit) will receive mouse messages.

  • If no control in the ZOrder returns a hit, the topmost control that returns a HitResult of 2 (vbHitResultClose) will receive mouse messages.

  • If no control returns a hit, the topmost control that returns a HitResult of 1 (vbHitResultTransparent) will receive mouse messages.

  • If no control returns a hit, the mouse messages are forwarded to the underlying container.

The HitTest event only occurs when the Windowless property of the UserControl has been set to True and the BackStyle property has been set to Transparent. If the Windowless property is False or the BackStyle property equals Opaque, any code in the HitTest event procedure will be ignored.

Note The order of hit testing described above applies to UserControl objects in a Visual Basic container. Other containers may not perform hit testing in the same order.


Initialize Event

Occurs when an application creates an instance of a Form, MDIForm, User control, Property Page, Webclass, DHTML Page Designer, or class.

Syntax

Private Sub object_Initialize( )

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You trigger the Initialize event when you:

  • Use the CreateObject function to create an instance of a class. For example:
    Set X = CreateObject("Project1.MyClass")
  • Refer to a property or event of an automatically created instance of a form or class in your code. For example:
    MyForm.Caption = "Example"

Use this event to initialize any data used by the instance of the Form, MDIForm, or class. For a Form or MDIForm, the Initialize event occurs before the Load event.


InitProperties Event

Occurs when a new instance of an object is created.

Syntax

Sub object_InitProperties()

The InitProperties event syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

This event allows the author of the object to initialize a new instance of the object. This event occurs only when a new instance of an object is being created; this is to allow the author of the object to distinguish between creating a new instance of the object and loading an old instance of the object.

By putting in code to initialize new instances in the InitProperties event rather than the Initialize event, the author can avoid cases where loading data through a ReadProperties event into an old instance of the object will undo the initialization of the object.


ItemCheck Event (ListBox Control)

Occurs when a ListBox control Style property is set to 1 (checkboxes) and an item’s checkbox in the ListBox control is selected or cleared.

Syntax

Private Sub object_ItemCheck([index As Integer])

The ItemCheck event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies the item in the listbox which was clicked.

Remarks

Note The ItemCheck event does not occur when a list item is only highlighted; rather, it occurs when the check box of the list item is selected or cleared.

The ItemCheck event can also occur programmatically whenever an element in Selected array of the ListBox is changed (and its Style property is set to 1.)

The ItemCheck event occurs before the Click event.

Attempting to unload a form using Unload Me in a ListBox control's ItemCheck event causes a General Protection Fault (GPF). For example:

Private Sub Form_Load()
     Dim i%
     For i = 0 To 20
       List1.AddItem i
     Next i
   End Sub

Private Sub List1_ItemCheck(Item As Integer)
  Unload Me
End Sub

This example also produces a GPF if the spacebar is pressed, or if you attempt to select an item in the ListBox using a CommandButton.

The recommended procedure for unloading a form is to add the Unload statement to the Click event in a CommandButton or Menu control.


ItemReloaded Event

Occurs after a component is reloaded.

Syntax

Private Sub object_ItemReloaded(vbcomponent As VBComponent)

The ItemReloaded event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
vbcomponent | A VBComponent object representing the component that was reloaded.


KeyDown, KeyUp Events

Occur when the user presses (KeyDown) or releases (KeyUp) a key while an object has the focus. (To interpret ANSI characters, use the KeyPress event.)

Syntax

Private Sub Form_KeyDown(keycode As Integer, shift As Integer)

Private Sub object_KeyDown([index As Integer,]keycode As Integer, shift As Integer)

Private Sub Form_KeyUp(keycode As Integer, shift As Integer)

Private Sub object_KeyUp([index As Integer,]keycode As Integer, shift As Integer)

The KeyDown and KeyUp event syntaxes have these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.
keycode | A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the constants in the Visual Basic (VB) object library in the Object Browser.
shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.

Remarks

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no visible and enabled controls. Although the KeyDown and KeyUp events can apply to most keys, they're most often used for:

  • Extended character keys such as function keys.

  • Navigation keys.

  • Combinations of keys with standard keyboard modifiers.

  • Distinguishing between the numeric keypad and regular number keys.

Use KeyDown and KeyUp event procedures if you need to respond to both the pressing and releasing of a key.

KeyDown and KeyUp aren't invoked for:

  • The ENTER key if the form has a CommandButton control with the Default property set to True.

  • The ESC key if the form has a CommandButton control with the Cancel property set to True.

  • The TAB key.

KeyDown and KeyUp interpret the uppercase and lowercase of each character by means of two arguments: keycode, which indicates the physical key (thus returning A and a as the same key) and shift, which indicates the state of shift+key and therefore returns either A or a.

If you need to test for the shift argument, you can use the shift constants which define the bits within the argument. The constants have the following values:

Constant | Value | Description
vbShiftMask | 1 | SHIFT key bit mask.
VbCtrlMask | 2 | CTRL key bit mask.
VbAltMask | 4 | ALT key bit mask.

The constants act as bit masks that you can use to test for any combination of keys.

You test for a condition by first assigning each result to a temporary integer variable and then comparing shift to a bit mask. Use the And operator with the shift argument to test whether the condition is greater than 0, indicating that the modifier was pressed, as in this example:

ShiftDown = (Shift And vbShiftMask) > 0

In a procedure, you can test for any combination of conditions, as in this example:

If ShiftDown And CtrlDown Then

Note If the KeyPreview property is set to True, a form receives these events before controls on the form receive the events. Use the KeyPreview property to create global keyboard-handling routines.


KeyDown, KeyUp Events Example

This example demonstrates a generic keyboard handler that responds to the F2 key and to all the associated ALT, SHIFT, and CTRL key combinations. The key constants are listed in the Visual Basic (VB) object library in the Object Browser. To try this example, paste the code into the Declarations section of a form that contains a TextBox control, and then press F5 and press F2 with various combinations of the ALT, SHIFT, and CTRL keys.

Private Sub Text1_KeyDown (KeyCode As Integer, Shift As Integer)
   Dim ShiftDown, AltDown, CtrlDown, Txt
   ShiftDown = (Shift And vbShiftMask) > 0
   AltDown = (Shift And vbAltMask) > 0
   CtrlDown = (Shift And vbCtrlMask) > 0
   If KeyCode = vbKeyF2 Then   ' Display key combinations.
   If ShiftDown And CtrlDown And AltDown Then
      Txt = "SHIFT+CTRL+ALT+F2."
   ElseIf ShiftDown And AltDown Then
      Txt = "SHIFT+ALT+F2."
   ElseIf ShiftDown And CtrlDown Then
      Txt = "SHIFT+CTRL+F2."
   ElseIf CtrlDown And AltDown Then
      Txt = "CTRL+ALT+F2."
   ElseIf ShiftDown Then
      Txt = "SHIFT+F2."
   ElseIf CtrlDown Then
   Txt = "CTRL+F2."
   ElseIf AltDown Then
      Txt = "ALT+F2."
   ElseIf SHIFT = 0 Then
      Txt = "F2."
   End If
   Text1.Text = "You pressed " & Txt
   End If
End Sub


KeyPress Event

Occurs when the user presses and releases an ANSI key.

Syntax

Private Sub Form_KeyPress(keyascii As Integer)

Private Sub object_KeyPress([index As Integer,]keyascii As Integer)

The KeyPress event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.
keyascii | An integer that returns a standard numeric ANSI keycode. Keyascii is passed by reference; changing it sends a different character to the object. Changing keyascii to 0 cancels the keystroke so the object receives no character.

Remarks

The object with the focus receives the event. A form can receive the event only if it has no visible and enabled controls or if the KeyPreview property is set to True. A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or one of a few special characters, and the ENTER or BACKSPACE key. A KeyPress event procedure is useful for intercepting keystrokes entered in a TextBox or ComboBox control. It enables you to immediately test keystrokes for validity or to format characters as they're typed. Changing the value of the keyascii argument changes the character displayed.

You can convert the keyascii argument into a character by using the expression:

Chr(KeyAscii)

You can then perform string operations and translate the character back to an ANSI number that the control can interpret by using the expression:

KeyAscii = Asc(char)

Use KeyDown and KeyUp event procedures to handle any keystroke not recognized by KeyPress, such as function keys, editing keys, navigation keys, and any combinations of these with keyboard modifiers. Unlike the KeyDown and KeyUp events, KeyPress doesn't indicate the physical state of the keyboard; instead, it passes a character.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters. KeyDown and KeyUp interpret the uppercase and lowercase of each character by means of two arguments: keycode, which indicates the physical key (thus returning A and a as the same key), and shift, which indicates the state of shift+key and therefore returns either A or a.

If the KeyPreview property is set to True, a form receives the event before controls on the form receive the event. Use the KeyPreview property to create global keyboard-handling routines.

Note The ANSI number for the keyboard combination of CTRL+@ is 0. Because Visual Basic recognizes a keyascii value of 0 as a zero-length string (""), avoid using CTRL+@ in your applications.


KeyPress Event Example

This example converts text entered into a TextBox control to uppercase. To try this example, paste the code into the Declarations section of a form that contains a TextBox, and then press F5 and enter something into the TextBox.

Private Sub Text1_KeyPress (KeyAscii As Integer)
   Char = Chr(KeyAscii)
   KeyAscii = Asc(UCase(Char))
End Sub


LinkClose Event

Occurs when a DDE conversation terminates. Either application in a DDE conversation may terminate a conversation at any time.

Syntax

Private Sub Form_LinkClose( )

Private Sub MDIForm_LinkClose( )

Private Sub object_LinkClose([index As Integer])

The LinkClose event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

Typically, you use a LinkClose event procedure to notify the user that a DDE conversation has been terminated. You can also include troubleshooting information on reestablishing a connection or where to go for assistance. For brief messages, use the MsgBox function.


LinkError Event

Occurs when there is an error during a DDE conversation. This event is recognized only as the result of a DDE-related error that occurs when no Visual Basic code is being executed. The error number is passed as an argument.

Syntax

Private Sub Form_LinkError(linkerr As Integer)

Private Sub MDIForm_LinkError(linkerr As Integer)

Private Sub object_LinkError([index As Integer,]linkerr As Integer)

The LinkError event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
linkerr | Error number of the DDE-related error, as described in Return Values.
index | An integer that uniquely identifies a control if it's in a control array.

Return Values

The following table lists all error numbers returned for the linkerr argument and a brief explanation of each error:

Value | Description
1 | The other application has requested data in the wrong format. This error may occur several times in succession as Visual Basic tries to find a format the other application recognizes.
6 | The destination application attempted to continue a DDE conversation after you set the LinkMode property on your source form to 0 (None).
7 | All the source links are in use (there is a limit of 128 links per source).
8 For destination controls: An automatic link or LinkRequest method failed to update the data in the control.
For source forms: The destination attempted to poke data to a control and the attempt failed.
11 | Not enough memory for DDE.

Remarks

Use a LinkError event procedure to notify the user of the particular error that has occurred. You can also include code to fix the problem or troubleshooting information on reestablishing a connection or on where to go for assistance. For brief messages, use the MsgBox function.


LinkError Event Example

This example is attached to a TextBox control, MyTextBox, that handles selected errors. The procedure displays a message (adapted from the error list in the LinkError event topic) based on the error number passed as the argument LinkErr. You can adapt this code to a source form by substituting Form_LinkError for MyTextBox_LinkError. This example is for illustration only.

Private Sub MyTextBox_LinkError (LinkErr As Integer)
Dim Msg
Select Case LinkErr
   Case 1
      Msg = "Data in wrong format."
   Case 11
      Msg = "Out of memory for DDE."
End Select
MsgBox Msg, vbExclamation, "MyTextBox"
End Sub


LinkExecute Event

Occurs when a command string is sent by a destination application in a DDE conversation. The destination application expects the source application to perform the operation described by the string.

Syntax

Private Sub object_LinkExecute(cmdstr As String, cancel As Integer)

The LinkExecute event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
cmdstr | The command string expression sent by the destination application.
cancel | An integer that tells the destination whether the command string was accepted or refused. Setting cancel to 0 informs the destination that the command string was accepted. Setting cancel to any nonzero value informs the destination that the command string was rejected. (The default is set to -1, indicating cancel.)

Remarks

There is no required syntax for cmdstr. How your application responds to different strings is completely up to you.

If you haven't created a LinkExecute event procedure, Visual Basic rejects command strings from destination applications.


LinkExecute Event Example

This example defines a set of commands for destinations to use in DDE conversations to which your application will respond. This example is for illustration only.

Private Sub Form_LinkExecute (CmdStr As String, Cancel As Integer)
   Cancel = False
   Select Case LCase(CmdStr)
   Case "{big}"
      WindowState = 2   ' Maximize window.
   Case "{little}"
      WindowState = 1   ' Minimize window.
   Case "{hide}"
      Visible = False   ' Hide form.
   Case "{view}"
      Visible = True      ' Display form.
   Case Else
      Cancel = True      ' Execute not allowed.
   End Select
End Sub


LinkNotify Event

Occurs when the source has changed the data defined by the DDE link if the LinkMode property of the destination control is set to 3 (Notify).

Syntax

Private Sub object_LinkNotify([index As Integer])

The LinkNotify event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

Typically, in the LinkNotify event your code notifies the user, gets the new data immediately, or defers getting the data until later. You can use the LinkRequest method to obtain the new data from the source.


LinkNotify Event Example

This example is attached to a PictureBox control, Picture1, that has its LinkTopic and LinkItem properties set to specify a graphic in the source, and its LinkMode property set to 3 (Notify). When the source changes this data, the procedure updates the PictureBox control immediately only if the PictureBox is on the active form; otherwise, it sets a flag variable. This example is for illustration only.

Private Sub Picture1_LinkNotify ()
   If Screen.ActiveForm Is Me Then
   Picture1.LinkRequest      ' Picture is on active form, so update.
   Else
      NewDataFlag = True   ' Assumed to be a module-level variable.
   End If
End Sub


LinkOpen Event

Occurs when a DDE conversation is being initiated.

Syntax

Private Sub Form_LinkOpen(cancel As Integer)

Private Sub MDIForm_LinkOpen(cancel As Integer)

Private Sub object_LinkOpen([index As Integer,]cancel As Integer)

The LinkOpen event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
cancel | An integer that determines whether the DDE conversation is established or not. Leaving cancel set to 0 (the default) establishes the conversation. Setting cancel to any nonzero value refuses the conversation.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

This event occurs for forms when a destination application is initiating a DDE conversation with the form. It occurs for controls when a control is initiating a DDE conversation with a source application.


Load Event

Occurs when a form is loaded. For a startup form, occurs when an application starts as the result of a Load statement or as the result of a reference to an unloaded form's properties or controls.

Syntax

Private Sub Form_Load( )

Private Sub MDIForm_Load( )

Remarks

Typically, you use a Load event procedure to include initialization code for a form — for example, code that specifies default settings for controls, indicates contents to be loaded into ComboBox or ListBox controls, and initializes form-level variables.

The Load event occurs after the Initialize event.

When you reference a property of an unloaded form in code, the form is automatically loaded but isn't automatically made visible unless the MDIChild property is set to True. If an MDIForm object isn't loaded and an MDI child form is loaded, both the MDIForm and the child form are automatically loaded and both become visible. Other forms aren't shown until you either use the Show method or set the Visible property to True.

The following code in an MDIForm Load event automatically loads an MDI child form (assuming Form1 has its MDIChild property set to True):

Dim NewForm As New Form1
NewForm.Caption = "New Form"   ' Loads form by reference.

Because all child forms become visible when loaded, the reference to the Caption property loads the form and makes it visible.

Note When you create procedures for related events, such as Activate, GotFocus, Paint, and Resize, be sure that their actions don't conflict and that they don't cause recursive events.


Load Event Example

This example loads items into a ComboBox control when a form is loaded. To try this example, paste the code into the Declarations section of a form that contains a ComboBox, and then press F5.

Private Sub Form_Load ()
   Combo1.AddItem "Mozart"      ' Add items to list.
   Combo1.AddItem "Beethoven"
   Combo1.AddItem "Rock 'n Roll"
   Combo1.AddItem "Reggae"
   Combo1.ListIndex = 2         ' Set default selection.
End Sub


LostFocus Event

Occurs when an object loses the focus, either by user action, such as tabbing to or clicking another object, or by changing the focus in code using the SetFocus method.

Syntax

Private Sub Form_LostFocus( )

Private Sub object_LostFocus([index As Integer])

The LostFocus event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

A LostFocus event procedure is primarily useful for verification and validation updates. Using LostFocus can cause validation to take place as the user moves the focus from the control. Another use for this type of event procedure is enabling, disabling, hiding, and displaying other objects as in a GotFocus event procedure. You can also reverse or change conditions that you set up in the object's GotFocus event procedure.

If an .exe file built by Visual Basic displays a dialog box created by a .dll file also built in Visual Basic, the .exe file's form will get Deactivate and LostFocus events. This may be unexpected, because you should not get the Deactivate event:

  • If the object is an out-of-process component.

  • If the object isn't written in Visual Basic.

  • In the development environment when calling a DLL built in Visual Basic.


LostFocus Event (UserControl Object and UserDocument Object)

Occurs in the object or constituent control when focus leaves it.

Syntax

Sub object_LostFocus()

The LostFocus event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

This LostFocus event is not the same LostFocus extender event that the developer who uses object handles. This LostFocus event is for the author of object, and is internal to object.

This event is useful if object needs to know that the focus is now on it.

Object itself can get focus only when the CanGetFocus property is True and there are no constituent controls that can receive focus.

The LostFocus event is raised before the ExitFocus event.


LostFocus Event Example

This example changes the color of a TextBox control when it receives or loses the focus (selected with the mouse or TAB key) and displays the appropriate text in the Label control. To try this example, paste the code into the Declarations section of a form that contains two TextBox controls and a Label control, and then press F5 and move the focus between Text1 and Text2.

Private Sub Text1_GotFocus ()
   ' Show focus with red.
   Text1.BackColor = RGB(255, 0, 0)
   Label1.Caption = "Text1 has the focus."
End Sub

Private Sub Text1_LostFocus ()
   ' Show loss of focus with blue.
   Text1.BackColor = RGB(0, 0, 255)
   Label1.Caption = "Text1 doesn't have the focus."
End Sub


MouseDown, MouseUp Events

Occur when the user presses (MouseDown) or releases (MouseUp) a mouse button.

Syntax

Private Sub Form_MouseDown(button As Integer, shift As Integer, x As Single, y As Single)

Private Sub MDIForm_MouseDown(button As Integer, shift As Integer, x As Single, y As Single)

Private Sub object_MouseDown([index As Integer,]button As Integer, shift As Integer, x As Single, y As Single)

Private Sub Form_MouseUp(button As Integer, shift As Integer, x As Single, y As Single)

Private Sub MDIForm_MouseUp(button As Integer, shift As Integer, x As Single, y As Single)

Private Sub object _MouseUp([index As Integer,]button As Integer, shift As Integer, x As Single, y As Single)

The MouseDown and MouseUp event syntaxes have these parts:

Part | Description
object | Returns an object expression that evaluates to an object in the Applies To list.
index | Returns an integer that uniquely identifies a control if it's in a control array.
button | Returns an integer that identifies the button that was pressed (MouseDown) or released (MouseUp) to cause the event. The button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.
shift | Returns an integer that corresponds to the state of the SHIFT, CTRL, and ALT keys when the button specified in the button argument is pressed or released. A bit is set if the key is down. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. The shift argument indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT were pressed, the value of shift would be 6.
x, y | Returns a number that specifies the current location of the mouse pointer. The x and y values are always expressed in terms of the coordinate system set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of the object.

Remarks

Use a MouseDown or MouseUp event procedure to specify actions that will occur when a given mouse button is pressed or released. Unlike the Click and DblClick events, 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.

The following applies to both Click and DblClick events:

  • 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 in the internal area of the object that receives them.

  • If mouse buttons are pressed in succession, the object that captures the mouse after the first press receives all mouse events until all buttons are released.

If you need to test for the button or shift arguments, you can use constants listed in the Visual Basic (VB) object library in the Object Browser to define the bits within the argument:

Constant (Button) | Value | Description
vbLeftButton | 1 | Left button is pressed
vbRightButton | 2 | Right button is pressed
vbMiddleButton | 4 | Middle button is pressed

Constant (Shift) | Value | Description
vbShiftMask | 1 | SHIFT key is pressed.
vbCtrlMask | 2 | CTRL key is pressed.
vbAltMask | 4 | ALT key is pressed.

The constants then act as bit masks you can use to test for any combination of buttons without having to figure out the unique bit field value for each combination.

Note You can use a MouseMove event procedure to respond to an event caused by moving the mouse. The button argument for MouseDown and MouseUp differs from the button argument used for MouseMove. For MouseDown and MouseUp, the button argument indicates exactly one button per event, whereas for MouseMove, it indicates the current state of all buttons.


MouseDown, MouseUp Events Example

This example demonstrates a simple paint application. The MouseDown event procedure works with a related MouseMove event procedure to enable painting when any mouse button is pressed and dragged. The MouseUp event procedure disables painting. To try this example, paste the code into the Declarations section of a form; and then press F5, click the form, and move the mouse while the mouse button is pressed.

Dim PaintNow As Boolean
Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X As
Single, Y As Single)
   PaintNow = True   ' Enable painting.
End Sub

Private Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
   PaintNow = False   ' Disable painting.
End Sub

Private Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
   If PaintNow Then
      PSet (X, Y)      ' Draw a point.
   End If
End Sub

Private Sub Form_Load ()
   DrawWidth = 10      ' Use wider brush.
   ForeColor = RGB(0, 0, 255)   ' Set drawing color.
End Sub


MouseMove Event

Occurs when the user moves the mouse.

Syntax

Private Sub Form_MouseMove(button As Integer, shift As Integer, x As Single, y As Single)

Private Sub MDIForm_MouseMove(button As Integer, shift As Integer, x As Single, y As Single)

Private Sub object_MouseMove([index As Integer,] button As Integer, shift As Integer, x As Single, y As Single)

The MouseMove event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.
button | An integer that corresponds to the state of the mouse buttons in which a bit is set if the button is down. The button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. It indicates the complete state of the mouse buttons; some, all, or none of these three bits can be set, indicating that some, all, or none of the buttons are pressed.
shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys. A bit is set if the key is down. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. The shift argument indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT were pressed, the value of shift would be 6.
x, y | A number that specifies the current location of the mouse pointer. The x and y values are always expressed in terms of the coordinate system set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of the object.

Remarks

The MouseMove event is 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.

If you need to test for the button or shift arguments, you can use constants listed in the Visual Basic (VB) object library in the Object Browser to define the bits within the argument:

Constant (Button) | Value | Description
vbLeftButton | 1 | Left button is pressed.
vbRightButton | 2 | Right button is pressed.
vbMiddleButton | 4 | Middle button is pressed.

Constant (Shift) | Value | Description
vbShiftMask | 1 | SHIFT key is pressed.
vbCtrlMask | 2 | CTRL key is pressed.
vbAltMask | 4 | ALT key is pressed.

The constants then act as bit masks you can use to test for any combination of buttons without having to figure out the unique bit field value for each combination.

You test for a condition by first assigning each result to a temporary integer variable and then comparing the button or shift arguments to a bit mask. Use the And operator with each argument to test if the condition is greater than zero, indicating the key or button is pressed, as in this example:

LeftDown = (Button And vbLeftButton) > 0
CtrlDown = (Shift And vbCtrlMask) > 0

Then, in a procedure, you can test for any combination of conditions, as in this example:

If LeftDown And CtrlDown Then

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

The button argument for MouseMove differs from the button argument for MouseDown and MouseUp. For MouseMove, the button argument indicates the current state of all buttons; a single MouseMove event can indicate that some, all, or no buttons are pressed. For MouseDown and MouseUp, the button argument indicates exactly one button per event.

Any time you move a window inside a MouseMove event, it can cause a cascading event. MouseMove events are generated when the window moves underneath the pointer. A MouseMove event can be generated even if the mouse is perfectly stationary.


MouseMove Event Example

This example demonstrates a simple paint application. The MouseDown event procedure works with a related MouseMove event procedure to enable painting when any mouse button is pressed. The MouseUp event procedure disables painting. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form and move the mouse while the mouse button is pressed.

Dim PaintNow As Boolean   ' Declare variable.
Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
   PaintNow = True   ' Brush on.
End Sub

Private Sub Form_MouseUp (Button As Integer, X As Single, Y As Single)
   PaintNow = False   ' Turn off painting.
End Sub

Private Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
   If PaintNow Then
      PSet (X, Y)      ' Draw a point.
   End If
End Sub

Private Sub Form_Load ()
   DrawWidth = 10      ' Use wider brush.
   ForeColor = RGB(0, 0, 255)   ' Set drawing color.
End Sub


ObjectEvent Event

Occurs when a control that is assigned to a VBControlExtender object variable raises an event.

Syntax

Private Sub object_ObjectEvent(Info As EventInfo)

The ObjectEvent event syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
Info | Returns a reference to an EventInfo object.

Remarks

The ObjectEvent event is a generic event that allows you to handle events of a control and return values through the control's event parameters.

You can use the ObjectEvent event to trap generic events a control raises, assuring that any control you deploy contains certain basic functionality required by the deployed application.


ObjectEvent Event, EventParameter Object Examples

The first example below uses the ObjectEvent event to print all parameter names and values.

Option Explicit
Private WithEvents extObj As VBControlExtender

' Code to set the object variable to a user control not shown.

Private Sub extObj_ObjectEvent(Info As EventInfo)
   Dim p As EventParameter
   Debug.Print Info.Name

   For Each p In Info.EventParameters
      Debug.Print p.Name, p.Value
   Next
End Sub

The second example allows you to check for a generic event raised by the control.

Private Sub extObj_ObjectEvent(Info As EventInfo)
   Dim p As EventParameter
   Select Case Info.Name
   Case "UserName"
      ' Check User name value.
      MsgBox Info.EventParameters("UserName").Value
   ' Other cases now shown
   Case Else ' Unknown Event
      ' Handle unknown events here.
   End Select
End Sub


ObjectMove Event

Occurs immediately after the object within an OLE container control is moved or resized while the object is active.

Syntax

Private Sub object_ObjectMove(left As Single, top As Single, width As Single, height As Single)

The ObjectMove event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
left | The coordinate of the left edge of the OLE container control immediately after it’s moved or resized.
top | The coordinate of the top edge of the OLE container control immediately after it’s moved or resized.
width | The width of the OLE container control immediately after it's moved or resized.
height | The height of the OLE container control immediately after it's moved or resized.

Remarks

When a user moves or resizes an OLE container control, your application can use the ObjectMove event to determine whether to actually change the size and position of the control. If the ObjectMove event procedure doesn't change the OLE container control's position or size, the object within the OLE container control returns to its original position and is informed of its new size. The coordinates passed as arguments to this event include the border of the OLE container control.

The ObjectMove and Resize events are triggered when the OLE container control receives information about the size of the object it contains. However, the Resize event doesn't receive any information about the position of the control. If the OLE container control is moved off the form, the arguments have negative or positive values that represent the position of the object relative to the top and left of the form.


OLECompleteDrag Event

Occurs when a source component is dropped onto a target component, informing the source component that a drag action was either performed or canceled.

Syntax

Private Sub object_OLECompleteDrag([effect As Long])

The OLECompleteDrag event syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Effect | A long integer set by the source object identifying the action that has been performed, thus allowing the source to take appropriate action if the component was moved (such as the source deleting data if it is moved from one component to another). The possible values are listed in Settings.

Settings

The settings for effect are:

Constant | Value | Description
VbDropEffectNone | 0 | Drop target cannot accept the data, or the drop operation was canceled.
VbDropEffectCopy | 1 | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
VbDropEffectMove | 2 | Drop results in data being moved from the drag source to the drop source. The drag source should remove the data from itself after the move.

Remarks

The OLECompleteDrag event is the final event to be called in an OLE drag/drop operation. This event informs the source component of the action that was performed when the object was dropped onto the target component. The target sets this value through the effect parameter of the OLEDragDrop event. Based on this, the source can then determine the appropriate action it needs to take. For example, if the object was moved into the target (vbDropEffectMove), the source needs to delete the object from itself after the move.

If OLEDragMode is set to Automatic, then Visual Basic handles the default behavior. The event still occurs, however, allowing the user to add to or change the behavior.

Most components support manual OLE drag and drop events, and some support automatic OLE drag and drop events.


OLEDragDrop Event

Occurs when a source component is dropped onto a target component when the source component determines that a drop can occur.

Note This event occurs only if OLEDropMode is set to 1 (Manual).

Syntax

Private Sub object_OLEDragDrop(data As DataObject, effect As Long, button As Integer, shift As Integer, x As Single, y As Single)

The OLEDragDrop event syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Data | A DataObject object containing formats that the source will provide and, in addition, possibly the data for those formats. If no data is contained in the DataObject, it is provided when the control calls the GetData method. The SetData and Clear methods cannot be used here.
Effect | A long integer set by the target component identifying the action that has been performed (if any), thus allowing the source to take appropriate action if the component was moved (such as the source deleting the data). The possible values are listed in Settings.
Button | An integer which acts as a bit field corresponding to the state of a mouse button when it is depressed. The left button is bit 0, the right button is bit 1, and the middle button is bit 2. These bits correspond to the values 1, 2, and 4, respectively. It indicates the state of the mouse buttons; some, all, or none of these three bits can be set, indicating that some, all, or none of the buttons are depressed.
Shift | An integer which acts as a bit field corresponding to the state of the shift, ctrl, and alt keys when they are depressed. The shift key is bit 0, the ctrl key is bit 1, and the alt key is bit 2. These bits correspond to the values 1, 2, and 4, respectively. The shift parameter indicates the state of these keys; some, all, or none of the bits can be set, indicating that some, all, or none of the keys are depressed. For example, if both the ctrl and alt keys were depressed, the value of shift would be 6.
x,y | A number which specifies the current location of the mouse pointer. The x and y values are always expressed in terms of the coordinate system set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of the object.

Settings

The settings for effect are:

Constant | Value | Description
VbDropEffectNone | 0 | Drop target cannot accept the data.
VbDropEffectCopy | 1 | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
VbDropEffectMove | 2 | Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move.
VbDropEffectScroll | -2147483648 | A mask to indicate that the drop target window has scrolled or would scroll.

Remarks

The source ActiveX component should always mask values from the effect parameter to ensure compatibility with future implementations of ActiveX components. Presently, only three of the 32 bits in the effect parameter are used. In future versions of Visual Basic, however, these other bits may be used. Therefore, as a precaution against future problems, drag sources and drop targets should mask these values appropriately before performing any comparisons.

For example, a source component should not compare an effect against, say, vbDropEffectCopy, such as in this manner:

If Effect = vbDropEffectCopy...

Instead, the source component should mask for the value or values being sought, such as this:

If Effect And vbDropEffectCopy = vbDropEffectCopy...

-or-

If (Effect And vbDropEffectCopy)...

This allows for the definition of new drop effects in future versions of Visual Basic while preserving backwards compatibility with your existing code.

Most components support manual OLE drag and drop events, and some support automatic OLE drag and drop events.


OLEDragOver Event

Occurs when one component is dragged over another.

Syntax

Private Sub object_OLEDragOver(data As DataObject, effect As Long, button As Integer, shift As Integer, x As Single, y As Single, state As Integer)

The OLEDragOver event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
data | A DataObject object containing formats that the source will provide and, in addition, possibly the data for those formats. If no data is contained in the DataObject, it is provided when the control calls the GetData method. The SetData and Clear methods cannot be used here.
effect | A long integer initially set by the source object identifying all effects it supports. This parameter must be correctly set by the target component during this event. The value of effect is determined by logically Or'ing together all active effects (as listed in Settings). The target component should check these effects and other parameters to determine which actions are appropriate for it, and then set this parameter to one of the allowable effects (as specified by the source) to specify which actions will be performed if the user drops the selection on the component. The possible values are listed in Settings.
button | An integer which acts as a bit field corresponding to the state of a mouse button when it is depressed. The left button is bit 0, the right button is bit 1, and the middle button is bit 2. These bits correspond to the values 1, 2, and 4, respectively. It indicates the state of the mouse buttons; some, all, or none of these three bits can be set, indicating that some, all, or none of the buttons are depressed.
shift | An integer which acts as a bit field corresponding to the state of the shift, ctrl, and alt keys when they are depressed. The shift key is bit 0, the ctrl key is bit 1, and the alt key is bit 2. These bits correspond to the values 1, 2, and 4, respectively. The shift parameter indicates the state of these keys; some, all, or none of the bits can be set, indicating that some, all, or none of the keys are depressed. For example, if both the ctrl and alt keys are depressed, the value of shift would be 6.
x,y | A number that specifies the current horizontal (x) and vertical (y) position of the mouse pointer within the target form or control. The x and y values are always expressed in terms of the coordinate system set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of the object.
state | An integer that corresponds to the transition state of the control being dragged in relation to a target form or control. The possible values are listed in Settings.

Settings

The settings for effect are:

Constant | Value | Description
vbDropEffectNone | 0 | Drop target cannot accept the data.
vbDropEffectCopy | 1 | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
vbDropEffectMove | 2 | Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move.
vbDropEffectScroll | -2147483648 (&H80000000) | Scrolling is occurring or about to occur in the target component. This value is used in conjunction with the other values. Note Use only if you are performing your own scrolling in the target component.

The settings for state are:

Constant | Value | Description
vbEnter | 0 | Source component is being dragged within the range of a target.
vbLeave | 1 | Source component is being dragged out of the range of a target.
vbOver | 2 | Source component has moved from one position in the target to another.

Remarks

Note If the state parameter is vbLeave, indicating that the mouse pointer has left the target, then the x and y parameters will contain zeros.

The source component should always mask values from the effect parameter to ensure compatibility with future implementations of ActiveX components. Presently, only three of the 32 bits in the effect parameter are used. In future versions of Visual Basic, however, these other bits may be used. Therefore, as a precaution against future problems, drag sources and drop targets should mask these values appropriately before performing any comparisons.

For example, a source component should not compare an effect against, say, vbDropEffectCopy, such as in this manner:

If Effect = vbDropEffectCopy...

Instead, the source component should mask for the value or values being sought, such as this:

If Effect And vbDropEffectCopy = vbDropEffectCopy...

-or-

If (Effect And vbDropEffectCopy)...

This allows for the definition of new drop effects in future versions of Visual Basic while preserving backwards compatibility with your existing code.

Most components support manual OLE drag and drop events, and some support automatic OLE drag and drop events.


OLEGiveFeedback Event

Occurs after every OLEDragOver event. OLEGiveFeedback allows the source component to provide visual feedback to the user, such as changing the mouse cursor to indicate what will happen if the user drops the object, or provide visual feedback on the selection (in the source component) to indicate what will happen.

Syntax

Private Sub object_OLEGiveFeedback(effect As Long, defaultcursors As Boolean)

The OLEGiveFeedback event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
effect | A long integer set by the target component in the OLEDragOver event specifying the action to be performed if the user drops the selection on it. This allows the source to take the appropriate action (such as giving visual feedback). The possible values are listed in Settings.
defaultcursors A boolean value which determines whether Visual Basic uses the default mouse cursor proved by the component, or uses a user-defined mouse cursor.
True (default) = use default mouse cursor.
False = do not use default cursor. Mouse cursor must be set with the MousePointer property of the Screen object.

Settings

The settings for effect are:

Constant | Value | Description
vbDropEffectNone | 0 | Drop target cannot accept the data.
vbDropEffectCopy | 1 | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
vbDropEffectMove | 2 | Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move.
vbDropEffectScroll | -2147483648 (&H80000000) | Scrolling is occurring or about to occur in the target component. This value is used in conjunction with the other values. Note Use only if you are performing your own scrolling in the target component.

Remarks

If there is no code in the OLEGiveFeedback event, or if the defaultcursors parameter is set to True, then Visual Basic automatically sets the mouse cursor to the default cursor provided by the component.

The source component should always mask values from the effect parameter to ensure compatibility with future implementations of components. Presently, only three of the 32 bits in the effect parameter are used. In future versions of Visual Basic, however, these other bits may be used. Therefore, as a precaution against future problems, drag sources and drop targets should mask these values appropriately before performing any comparisons.

For example, a source component should not compare an effect against, say, vbDropEffectCopy, such as in this manner:

If Effect = vbDropEffectCopy...

Instead, the source component should mask for the value or values being sought, such as this:

If Effect And vbDropEffectCopy = vbDropEffectCopy...

-or-

If (Effect And vbDropEffectCopy)...

This allows for the definition of new drop effects in future versions of Visual Basic while preserving backwards compatibility with your existing code.

Most components support manual OLE drag and drop events, and some support automatic OLE drag and drop events.


OLESetData Event

Occurs on an source component when a target component performs the GetData method on the source’s DataObject object, but the data for the specified format has not yet been loaded.

Syntax

Private Sub object_OLESetData(data As DataObject, dataformat As Integer)

The OLESetData event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
data | A DataObject object in which to place the requested data. The component calls the SetData method to load the requested format.
dataformat | An integer specifying the format of the data that the target component is requesting. The source component uses this value to determine what to load into the DataObject object.

Remarks

In certain cases, you may wish to defer loading data into the DataObject object of a source component to save time, especially if the source component supports many formats. This event allows the source to respond to only one request for a given format of data. When this event is called, the source should check the format parameter to determine what needs to be loaded and then perform the SetData method on the DataObject object to load the data which is then passed back to the target component.


OLEStartDrag Event

Occurs when a component's OLEDrag method is performed, or when a component initiates an OLE drag/drop operation when the OLEDragMode property is set to Automatic.

This event specifies the data formats and drop effects that the source component supports. It can also be used to insert data into the DataObject object.

Syntax

Private Sub object_OLEStartDrag(data As DataObject, allowedeffects As Long)

The OLEStartDrag event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
data | A DataObject object containing formats that the source will provide and, optionally, the data for those formats. If no data is contained in the DataObject, it is provided when the control calls the GetData method. The programmer should provide the values for this parameter in this event. The SetData and Clear methods cannot be used here.
allowedeffects | A long integer containing the effects that the source component supports. The possible values are listed in Settings. The programmer should provide the values for this parameter in this event.

Settings

The settings for allowedeffects are:

Constant | Value | Description
vbDropEffectNone | 0 | Drop target cannot accept the data.
vbDropEffectCopy | 1 | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
vbDropEffectMove | 2 | Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move.

Remarks

The source component should use the logical Or operator against the supported values and place the result in the allowedeffects parameter. The target component can use this value to determine the appropriate action (and what the appropriate user feedback should be).

The OLEStartDrag event also occurs if the component’s OLEDragMode property is set to Automatic. This allows you to add formats and data to the DataObject object after the component has done so. You can also override the default behavior of the component by clearing the DataObject object (using the Clear method) and then adding your data and formats.

You may wish to defer putting data into the DataObject object until the target component requests it. This allows the source component to save time by not loading multiple data formats. When the target performs the GetData method on the DataObject, the source’s OLESetData event will occur if the requested data is not contained in the DataObject. At this point, the data can be loaded into the DataObject, which will in turn provide the data to the target.

If the user does not load any formats into the DataObject, then the drag/drop operation is canceled.


DataConnection Event

Occurs when a data source connects to an OLE DB Simple Provider.

Syntax

Private Sub object_DataConnection(ConnectionString As String)

The DataConnection event has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
ConnectionString | A string specifying a connection to an OLE DB Simple Provider.

Remarks

The DataConnection event is only available when the DataSourceBehavior property of a class is set to vbOLEDBProvider in an ActiveX DLL project.


Paint Event

Occurs when part or all of an object is exposed after being moved or enlarged, or after a window that was covering the object has been moved.

Syntax

Private Sub Form_Paint( )

Private Sub object_Paint([index As Integer])

The Paint event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

A Paint event procedure is useful if you have output from graphics methods in your code. With a Paint procedure, you can ensure that such output is repainted when necessary.

The Paint event is invoked when the Refresh method is used. If the AutoRedraw property is set to True, repainting or redrawing is automatic, so no Paint events are necessary.

If the ClipControls property is set to False, graphics methods in the Paint event procedure affect only newly exposed areas of the form; otherwise, the graphics methods repaint all areas of the form not covered by controls (except Image, Label, Line, and Shape controls).

Using a Refresh method in a Resize event procedure forces repainting of the entire object every time a user resizes the form.

Note Using a Paint event procedure for certain tasks can cause a cascading event. In general, avoid using a Paint event procedure to do the following:

  • Move or size a form or control.

  • Change any variables that affect size or appearance, such as setting an object's BackColor property.

  • Invoke a Refresh method.

A Resize event procedure may be more appropriate for some of these tasks.


Paint Event Example

This example draws a diamond that intersects the midpoint of each side of a form and adjusts automatically as the form is resized. To try this example, paste the code into the Declarations section of a form, and then press F5 and resize the form.

Private Sub Form_Paint ()
   Dim HalfX, HalfY   ' Declare variables.
   HalfX = ScaleLeft + ScaleWidth / 2   ' Set to one-half of width.
   HalfY = ScaleTop + ScaleHeight / 2   ' Set to one-half of height.
   ' Draw a diamond.
   Line (ScaleLeft, HalfY) - (HalfX, ScaleTop)
   Line -(ScaleWidth + ScaleLeft, HalfY)
   Line -(HalfX, ScaleHeight + ScaleTop)
   Line -(ScaleLeft, HalfY)
End Sub

Private Sub Form_Resize
   Refresh
End Sub


PathChange Event

Occurs when the path is changed by setting the FileName or Path property in code.

Syntax

Private Sub object_PathChange([index As Integer])

The PathChange event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

You can use a PathChange event procedure to respond to path changes in a FileListBox control. When you assign a string containing a new path to the FileName property, the FileListBox control invokes the PathChange event.


PathChange Event Example

This example demonstrates how to update a Label control to reflect the current path for a FileListBox control. Double-clicking a directory name displays a list of that directory's files in the FileListBox; it also displays the directory's complete path in the Label control. To try this example, paste the code into the Declarations section of a form that contains a Label control, a DirListBox control, and a FileListBox control, and then press F5. Double-click a directory to change the path.

Private Sub File1_PathChange ()
   Label1.Caption = "Path: " & Dir1.Path   ' Show path in Label.
End Sub

Private Sub Dir1_Change ()
   File1.Path = Dir1.Path            ' Set file path.
End Sub

Private Sub Form_Load ()
   Label1.Caption = "Path: " & Dir1.Path   ' Show path in Label.
End Sub


PatternChange Event

Occurs when the file listing pattern, such as "*.*", is changed by setting the FileName or Pattern property in code.

Syntax

Private Sub object_PatternChange([index As Integer])

The PatternChange event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

You can use a PatternChange event procedure to respond to pattern changes in a FileListBox control. When you assign a string containing a new pattern to the FileName property, the FileListBox invokes the PathChange event.


PatternChange Event Example

This example updates a FileListBox control with files matching the pattern entered in a TextBox control. If a full path is entered into the TextBox, such as C:\Bin\*.exe, the text is automatically parsed into path and pattern components. To try this example, paste the code into the Declarations section of a form that contains a TextBox control, a Label control, a FileListBox control, and a CommandButton control, and then press F5 and enter a valid file pattern in the TextBox.

Private Sub Form_Load ()
   Command1.Default = True         ' Set Default property.
   Command1.Caption = "OK"         ' Set Caption.
End Sub

Private Sub Command1_Click ()   ' OK button clicked.
   ' Text is parsed into path and pattern components.
   File1.FileName = Text1.Text
   Label1.Caption = "Path: " & File1.Path
End Sub

Private Sub File1_PatternChange ()
   Text1.Text = File1.Pattern   ' Set text to new pattern.
End Sub


ProcessingTimeout Event

Occurs at preset intervals, allowing the user to cancel an asynchronous operation.

Syntax

Private Sub object_ProcessingTimeout(Seconds As Long, Cancel As Boolean, JobType As AsyncTypeConstants, Cookie As Long)

The ProcessingTimeout event syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
Seconds | Returns the number of seconds that have passed since starting the asynchronous operation.
Cancel | Sets a value that determines if the operation will be canceled, as shown in Settings.
JobType | Returns the type of operation, as shown in Settings.
Cookie | Returns the ID of the operation. The ID is set when an asynchronous method such as ExportReport or PrintReport is invoked.

Settings

The JobType settings are:

Constant | Value | Description
rptAsyncPreview | 0 | The report is processing a Preview operation.
rptAsyncPrint | 1 | The report is processing a Print operation.
rptAsyncReport | 2 | The report is processing an ExportReport operation.

The settings for cancel are:

Setting | Description
True | The operation is cancelled.
False | (Default) The operation continues.

Remarks

Use the ProcessingTimeout event to allow the user to cancel an asynchronous operation at specified periods of time.


ProcessingTimeout Event Example

The example uses the ProcessingTimeout event to notify the user when an asynchronous operation has taken longer than expected.

Private Sub DataReport1_ProcessingTimeout(Seconds As Long, _
Cancel As Boolean, JobType As AsyncTypeConstants, Cookie As Long)
   ' Use a function to return a string that describes the job type.
   ' At set intervals, prompt the user to continue or cancel.
   Dim strJob As String
   strJob = GetJobType(JobType)
   Select Case Seconds
   Case 60
      If MsgBox("The " & strJob & " has taken " & Seconds & " seconds." _
      & " Do you want to cancel?", vbRetryCancel) = vbCancel Then _
      Cancel = True
   Case 90
      If MsgBox("The " & strJob & " has taken " & Seconds & " seconds." _
      & " Do you want to cancel?", vbRetryCancel) = vbCancel Then _
      Cancel = True
   Case 120
      ' Cancel the operation.
      Cancel = True
   End Select
End Sub

Private Function GetJobType(jType As AsyncTypeConstants) As String
   'Return the job type as a string.
   Select Case jType
   Case rptAsyncPreview
      GetJobType = "preview operation"
   Case rptAsyncPrint
      GetJobType = "print operation"
   Case rptAsyncExport
      GetJobType = "export report operation"
   Case Else
      'Handle other cases here.
   End Select
End Function


QueryClose Event

Occurs before a form is terminated.

Syntax

Public Sub object_QueryClose(cancel As Integer, closemode As Integer)

The QueryClose event syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
cancel | Set to any value other than zero to stop the designer from closing.
closemode | A value or constant indicating the cause of the QueryClose event, as described in Return Values.

Return Values

The closemode argument returns the following values:

Constant | Value | Description
vbFormControlMenu | 0 | The user has chosen the Close command from the Control menu on the designer or clicked the Close button.
vbFormCode | 1 | The Unload statement is invoked from code.
vbAppWindows | 2 | The current Windows operating environment session is ending.
vbAppTaskManager | 3 | The Windows Task Manager is closing the application.
vbFormMDIForm | 4 | An MDI child form is closing because the MDI form is closing.

Remarks

This event is typically used to make sure there are no unfinished tasks in the designer included in an application before that application closes. For example, if a user hasn't saved new data in any designer, the application can prompt the user to save the data.

When an application closes, you can use the QueryClose event procedure to set the Cancel property to True, stopping the closing process.


QueryUnload Event

Occurs before a form or application closes. When an MDIForm object closes, the QueryUnload event occurs first for the MDI form and then in all MDI child forms. If no form cancels the QueryUnload event, the Unload event occurs first in all other forms and then in an MDI form. When a child form or a Form object closes, the QueryUnload event in that form occurs before the form's Unload event.

Syntax

Private Sub Form_QueryUnload(cancel As Integer, unloadmode As Integer)

Private Sub MDIForm_QueryUnload(cancel As Integer, unloadmode As Integer)

The QueryUnload event syntax has these parts:

Part | Description
cancel | An integer. Setting this argument to any value other than 0 stops the QueryUnload event in all loaded forms and stops the form and application from closing.
unloadmode | A value or constant indicating the cause of the QueryUnload event, as described in Return Values.

Return Values

The unloadmode argument returns the following values:

Constant | Value | Description
vbFormControlMenu | 0 | The user chose the Close command from the Control menu on the form.
vbFormCode | 1 | The Unload statement is invoked from code.
vbAppWindows | 2 | The current Microsoft Windows operating environment session is ending.
vbAppTaskManager | 3 | The Microsoft Windows Task Manager is closing the application.
vbFormMDIForm | 4 | An MDI child form is closing because the MDI form is closing.
vbFormOwner | 5 | A form is closing because its owner is closing.

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

Remarks

This event is typically used to make sure there are no unfinished tasks in the forms included in an application before that application closes. For example, if a user has not yet saved some new data in any form, your application can prompt the user to save the data.

When an application closes, you can use either the QueryUnload or Unload event procedure to set the Cancel property to True, stopping the closing process. However, the QueryUnload event occurs in all forms before any are unloaded, and the Unload event occurs as each form is unloaded.


QueryUnload Event Example

This example uses an MDIForm object containing two MDI child forms. When you choose the Close command from the Control menu to close a form, a different message is displayed than if you choose the Exit command from the File menu. To try this example, create an MDIForm, and then use the Menu Editor to create a File menu containing an Exit command named FileExit. Make sure that this menu item is enabled. On Form1, set the MDIChild property to True. Paste the code into the Declarations sections of the respective forms, and then press F5 to run the program.

' Paste into Declarations section of MDIForm1.
Private Sub MDIForm_Load ()
   Dim NewForm As New Form1   ' New instance of Form1.
   NewForm.Caption = "Form2"   ' Set caption and show.
End Sub

Private Sub FileExit_Click ()
   Unload MDIForm1   ' Exit the application.
End Sub

Private Sub MDIForm_QueryUnload (Cancel As Integer, UnloadMode As Integer)
   Dim Msg   ' Declare variable.
   ' Set the message text.
   Msg = "Do you really want to exit the application?"
   ' If user clicks the No button, stop QueryUnload.
   If MsgBox(Msg, vbQuestion + vbYesNo, Me.Caption) = vbNo Then Cancel = True
End Sub

' Paste into Declarations section of Form1.
Private Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
   Dim Msg   ' Declare variable.
   If UnloadMode > 0 Then
      ' If exiting the application.
      Msg = "Do you really want to exit the application?"
   Else
      ' If just closing the form.
      Msg = "Do you really want to close the form?"
   End If
   ' If user clicks the No button, stop QueryUnload.
   If MsgBox(Msg, vbQuestion + vbYesNo, Me.Caption) = vbNo Then Cancel = True
End Sub


ReadProperties Event

Occurs when loading an old instance of an object that has a saved state.

Syntax

Sub object_ReadProperties(pb As PropertyBag)

The ReadProperties event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
pb | An object of the type PropertyBag class that contains the saved data to load.

Remarks

When this event occurs, the object author can load in the saved state from pb, by calling the ReadProperty method of the PropertyBag object for each value that is to be loaded. This event occurs after the Initialize event.

Always include error trapping when handling the ReadProperties event, to protect the control from invalid property values that may have been entered by users editing the file containing the saved data with text editors. However, you should not raise an error in an event, since doing so may be fatal to the container, so any error trapping in the ReadProperties event procedure should not include raising errors.


ProcessTag Event

When a token-prefixed tag is found in an HTML template during WriteTemplate processing, this event is fired to allow the WebClass to replace the contents of that tag.

Syntax

Private Sub object_ProcessTag(TagName As String, TagContents As String, SendTag As Boolean)

The ProcessTag event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
TagName | The name of the tag being replaced.
TagContents | When the event is fired, contains the current contents of the tag. The WebClass code may change this variable to replace the contents appropriately.
SendTag | When set to True, both the tags and the contents are replaced in the specified replacement area. When set to False, only the value of the TagContents parameter will be sent to the file, to replace the entire replacement area. Default value is False.

Remarks

Event only fires when processing a template that contains replacement tags.


Resize Event

Occurs when an object is first displayed or when the window state of an object changes. (For example, a form is maximized, minimized, or restored.)

Syntax

Private Sub Form_Resize( )

Private Sub object_Resize(height As Single, width As Single)

The Resize event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
height | Number specifying the new height of the control.
width | Number specifying the new width of the control.

Remarks

Use a Resize event procedure to move or resize controls when the parent form is resized. You can also use this event procedure to recalculate variables or properties, such as ScaleHeight and ScaleWidth, that may depend on the size of the form. If you want graphics to maintain sizes proportional to the form when it's resized, invoke the Paint event by using the Refresh method in a Resize event procedure.

Whenever the AutoRedraw property is set to False and the form is resized, Visual Basic also calls the related events, Resize and Paint, in that order. When you attach procedures for these related events, be sure their actions don't conflict.

When an OLE container control's SizeMode property is set to 2 (Autosize), the control is automatically sized according to the display size of the object contained in the control. If the display size of the object changes, the control is automatically resized to fit the object. When this occurs, the Resize event is invoked for the object before the OLE container control is resized. The height and width parts indicate the optimal size for displaying the object (this size is determined by the application that created the object). You can size the control differently by changing the values of the height and width parts in the Resize event.


Resize Event Example

This example automatically resizes a TextBox control to fill the form whenever the form is resized. To try this example, paste the code into the Declarations section of a form that contains a TextBox. Set the TextBox control's MultiLine property to True, its ScrollBars property to 3, and its BorderStyle property to 0, and then press F5 and resize the form.

Private Sub Form_Load ()
   Text1.Text = ""   ' Clear text.
End Sub

Private Sub Form_Resize ()
   Text1.Move 0,0, ScaleWidth, ScaleHeight
End Sub


Respond Event

Occurs when a WebItem object is activated by a user request, if no event is found that directly corresponds to the selected element.

Syntax

Private Sub object_Respond()

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remark

Requests from the browser often correspond to a template event for the WebItem. For example, when the user selects Hyperlink1, the webclass fires a Hyperlink1 event. However, if no direct correlation is found between the selected element and an event for the WebItem, the system fires the Respond event. The Respond event is also fired when you navigate from one WebItem to another using the NextWebItem method.

The Respond event is the default event for a WebItem object. When this event is fired, the code must create the response to be sent to the browser using the Response object.


RowColChange Event

Occurs when the current cell changes to a different cell.

Syntax

Private Sub object_RowColChange ([index As Integer, lastrow As String, lastcol As Integer])

The RowColChange event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it is in a control array.
lastrow | (For DataGrid control) A string expression specifying the previous row position.
lastcol | (For DataGrid control) An integer specifying the previous column position.

Remarks

This event occurs whenever the user clicks a cell other than the current cell or when you programmatically change the current cell within a selection using the Col and Row properties.

The SelChange event also occurs when a user clicks a new cell, but doesn't occur when you programmatically change the selected range without changing the current cell.

For the DataGrid control, the position of the current cell is provided by the Bookmark and ColIndex properties. The previous cell position is specified by lastrow and lastcol. If you edit data and then move the current cell position to a new row, the update events for the original row are completed before another cell becomes the current cell.


Scroll Event

Occurs when the scroll box on a ScrollBar control, or an object which contains a scrollbar, is repositioned or scrolled horizontally or vertically.

Syntax

Private Sub DataGrid_Scroll([cancel As Integer])

Private Sub object_Scroll( )

The Scroll event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
cancel | Determines whether the scroll operation succeeds and the ScrollBar or DataGrid are repainted, as described in Remarks.

Remarks

For a DataGrid control, this event occurs when the user scrolls the grid horizontally or vertically but before the grid is repainted to display the results of the scroll operation.

For a ComboBox control, this event occurs only when the scrollbars in the dropdown portion of the control are manipulated.

Setting cancel to True causes the DataGrid scroll operation to fail, and no repaint operation occurs. If the Refresh method is invoked within this event, the grid is repainted in its new (scrolled) arrangement even if cancel is set to True. However, in this case, the grid is repainted again because the scroll operation fails and it snaps back to its previous position.

You can use this event to perform calculations or to manipulate controls that must be coordinated with ongoing changes in scroll bars. In contrast, use the Change event when you want an update to occur only once, after a ScrollBar control changes.

Note Avoid using a MsgBox statement or function in this event.


Scroll Event Example

This example changes the size of a Shape control to correspond to the value of a horizontal scroll bar (HScrollBar) as you drag the scroll box on the scroll bar. To try this example, paste the code into the Declarations section of a form that contains a Shape control, a Label control, and an HScrollBar control. Set the Index property for the Shape control to 0 to create a control array. Then press F5 and move the scroll bar.

Private Sub Form_Load ()
   ' Move and size the first Shape control.
   Shape1(0).Move HScroll1.Left, HScroll1.Top * 1.5, HScroll1.Width, HScroll1.Height
   Label1.Caption = ""   ' Set the Label caption.
   Load Shape1(1)   ' Create the second Shape.
   ' Move and size the second Shape control.
   Shape1(1).Move Shape1(0).Left, Shape1(0).Top, 1, Shape1(0).Height
   Shape1(1).BackStyle = 1   ' Set BackStyle to Opaque.
   Shape1(1).Visible = True   ' Display the second Shape.
   HScroll1.Min = 1   ' Set values of the scroll bar.
   HScroll1.Max = HScroll1.Width
End Sub

Private Sub HScroll1_Change ()
   Label1.Caption = "Changed"   ' Display message after change.
End Sub

Private Sub HScroll1_Scroll ()
   Shape1(1).BackColor = &HFF0000   ' Set Shape color to Blue.
   Label1.Caption = "Changing"   ' Display message while scrolling.
   Shape1(1).Width = HScroll1.Value ' Size Shape to Scroll Value.
End Sub


SelectionChanged Event

Occurs when the selection of controls on the form has changed.

Syntax

Sub object_SelectionChanged()

The SelectionChanged event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

The firing of this event notifies the property page that the selection of controls has changed, and therefore the display of current property values may need to be updated. The SelectedControls property should be read to find out the new set of selected controls.

The SelectionChanged event is also raised when the property page is first brought up for a control.


Show Event (UserControl Object)

Occurs when the object’s Visible property changes to True.

Syntax

Sub object_Show()

The Show event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

In order to draw to the screen in Windows, any object must have a window, temporarily or permanently. Visual Basic ActiveX controls have permanent windows. Before a control has been sited on a form, its window is not on the container. The control receives Show events when the window is added.

While the control’s window is on the form, the control receives a Show event when the control’s Visible property changes to True.

The control does not receive Show events if the form is hidden and then shown again, or if the form is minimized and then restored. The control’s window remains on the form during these operations, and its Visible property doesn’t change.

If the control is being shown in an internet browser, a Show event occurs if the user returns to the page containing the control.

Note If the control is used with earlier versions of Visual Basic than 5.0, the control will not receive Show events at design time. This is because earlier versions of Visual Basic did not put any visible windows on a form at design time.


Show Event (UserDocument Object)

Occurs when the object’s Visible property changes to True.

Syntax

Sub object_Show()

The Show event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

In order to draw to the screen in Windows, any object must have a window, temporarily or permanently; Visual Basic ActiveX documents have permanent windows. Before object has been sited on a form, its window is not on the container. The UserDocument object receives Show events when the window is added.

While object’s window is on the container, object receives a Show event when object’s Visible property changes to True.

Object does not receive Show events if the container is hidden and then shown again, or if the container is minimized and then restored. Object’s window remains on the container during these operations, and its Visible property doesn’t change.

If object is being shown in an internet browser, a Show event occurs when the user navigates to the page.

Note If object is used with earlier versions of Visual Basic than 5.0, object will not receive Show events at design time. This is because earlier versions of Visual Basic did not put any visible windows on a form at design time.


Start Event

Occurs when a user launches a WebClass object from the browser, if no webitem and event are specified in the request. The Start event follows the BeginRequest event in the application's lifetime.

Syntax

Private Sub object_Start()

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remark

The Start event occurs when the user accesses your application by navigating to the Active Server Page that forms the application’s base URL. You can write code for the Start event in order for the system to successfully run your application in this situation.

Note If the user includes a webitem in the URL they use to launch the webclass, the Start event does not fire. Instead, the run-time fires the BeginRequest event, then launches the specified webitem and its default event or the event the user specified.

Generally, you should use the Start event to navigate to the first WebItem in your WebClass object. The Start event code can use the NextItem property to navigate to the specified WebItem in the Webclass.


Terminate Event

Occurs when all references to an instance of a Form, MDIForm, User control, Property Page, Webclass, DHTML Page Designer, or class are removed from memory by setting all the variables that refer to the object to Nothing or when the last reference to the object falls out of scope.

Syntax

Private Sub object_Terminate( )

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

For all objects except classes, the Terminate event occurs after the Unload event.

The Terminate event isn't triggered if the instances of the form or class were removed from memory because the application terminated abnormally. For example, if your application invokes the End statement before removing all existing instances of the class or form from memory, the Terminate event isn't triggered for that class or form.


Timer Event

Occurs when a preset interval for a Timer control has elapsed. The interval's frequency is stored in the control's Interval property, which specifies the length of time in milliseconds.

Syntax

Private Sub object_Timer([index As Integer])

The Timer event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

Use this event procedure to tell Visual Basic what to do after each Timer control interval has elapsed. When you're working with the Timer event:

  • The Interval property specifies the interval between Timer events in milliseconds.

  • Whenever the Timer control's Enabled property is set to True and the Interval property is greater than 0, the Timer event waits for the period specified in the Interval property.


Timer Event Example

This example demonstrates a digital clock. To try this example, paste the code into the Declarations section of a form that contains a Label control and a Timer control, and then press F5.

Private Sub Form_Load ()
   Timer1.Interval = 1000   ' Set Timer interval.
End Sub

Private Sub Timer1_Timer ()
   Label1.Caption = Time   ' Update time display.
End Sub

This example moves a PictureBox control across a form. To try this example, paste the code into the Declarations section of a form that contains a Timer control and a PictureBox control, and then press F5. For a better visual effect you can assign a bitmap to the PictureBox using the Picture property.

Dim DeltaX, DeltaY As Integer   ' Declare variables.
Private Sub Timer1_Timer ()
   Picture1.Move Picture1.Left + DeltaX, Picture1.Top + DeltaY
   If Picture1.Left < ScaleLeft Then DeltaX = 100
   If Picture1.Left + Picture1.Width > ScaleWidth + ScaleLeft Then
      DeltaX = -100
   End If
   If Picture1.Top < ScaleTop Then DeltaY = 100
   If Picture1.Top + Picture1.Height > ScaleHeight + ScaleTop Then
      DeltaY = -100
   End If
End Sub

Private Sub Form_Load ()
   Timer1.Interval = 1000   ' Set Interval.
   DeltaX = 100   ' Initialize variables.
   DeltaY = 100
End Sub


Unformat Event

Occurs after the StdFormat object unformats the value.

Syntax

Sub object_Unformat(ByRef datavalue As StdDataValue)

The Unformat event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
datavalue | StdDataValue object.

Remarks

This event allows the user to do unformatting that the standard settings of the StdDataFormat object cannot accomplish.


Unload Event

Occurs when a form is about to be removed from the screen. When that form is reloaded, the contents of all its controls are reinitialized. This event is triggered by a user closing the form using the Close command on the Control menu or an Unload statement.

Syntax

Private Sub object_Unload(cancel As Integer)

The Unload event syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Cancel | Integer that determines whether the form is removed from the screen. If cancel is 0, the form is removed. Setting cancel to any nonzero value prevents the form from being removed.

Remarks

Setting cancel to any nonzero value prevents the form from being removed, but doesn't stop other events, such as exiting from the Microsoft Windows operating environment. Use the QueryUnload event to stop exiting from Windows.

Use an Unload event procedure to verify that the form should be unloaded or to specify actions that you want to take place when the form is unloaded. You can also include any form-level validation code you may need for closing the form or saving the data in it to a file.

The QueryUnload event occurs before the Unload event. The Unload event occurs before the Terminate event.

The Unload event can be caused by using the Unload statement, or by the user choosing the Close command on a form's Control menu, exiting the application with the End Task button on the Windows Task List, closing the MDI form for which the current form is a child form, or exiting the Microsoft Windows operating environment while the application is running.


Unload Event Example

This example demonstrates a simple procedure to close a form while prompting the user with various message boxes. In an actual application, you can add calls to general purpose Sub procedures that emulate the processing of the Exit, Save, and Save As commands on the File menu in Visual Basic. To try this example, paste the code into the Declarations section of a form, and then press F5. Once the form is displayed, press ALT+F4 to close the form.

Private Sub Form_Unload (Cancel As Integer)
   Dim Msg, Response   ' Declare variables.
   Msg = "Save Data before closing?"
   Response = MsgBox(Msg, vbQuestion + vbYesNoCancel, "Save Dialog")
   Select Case Response
      Case vbCancel   ' Don't allow close.
         Cancel = -1
         Msg = "Command has been canceled."
      Case vbYes
      ' Enter code to save data here.
         Msg = "Data saved."'
      Case vbNo
         Msg = "Data not saved."
   End Select
   MsgBox Msg, vbOKOnly, "Confirm"   ' Display message.
End Sub


Updated Event

Occurs when an object's data has been modified.

Syntax

Sub object_Updated (code As Integer)

The Updated event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
code | An integer that specifies how the object was updated, as described in Settings.

Settings

The settings for code are:

Constant | Value | Description
vbOLEChanged | 0 | The object's data has changed.
vbOLESaved | 1 | The object's data has been saved by the application that created the object.
vbOLEClosed | 2 | The file containing the linked object's data has been closed by the application that created the object.
vbOLERenamed | 3 | The file containing the linked object's data has been renamed by the application that created the object.

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser. You can use this event to determine if an object's data has been changed since it was last saved. To do this, set a global variable in the Updated event indicating that the object needs to be saved. After you save the object, reset the variable.


UserEvent Event

Occurs in response to the firing of a run-time defined event.

Syntax

Private Sub object_UserEvent(eventname As String)

The UserEvent event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
eventname | Contains a custom event name that was added at run time.

Remark

When receiving an event name that was not defined at design time, the URLFor method returns a URL which when processed by the client fires the UserEvent event on the respective WebItem. The UserEvent event will be passed the name of the run-time defined event. Using the URLFor method you can generate a URL that, if retrieved by the browser in response to a user action, will invoke the UserEvent method. The WebClass should take appropriate action according to the meaning of the event. You write the event procedures for all such events in your WebClass within the UserEvent event. If you have a WebClass that contains several user events, use a conditional statement such as If or Select Case to specify the actions the system should perform for each.


Validate Event (Data Control)

Occurs before a different record becomes the current record; before the Update method (except when data is saved with the UpdateRecord method); and before a Delete, Unload, or Close operation.

Syntax

Private Sub object_Validate ([ index As Integer,] action As Integer, save As Integer)

The Validate event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | Identifies the control if it's in a control array.
action | An integer that indicates the operation causing this event to occur, as described in Settings.
save | A Boolean expression specifying whether bound data has changed, as described in Settings.

Settings

The settings for action are:

Constant | Value | Description
vbDataActionCancel | 0 | Cancel the operation when the Sub exits
vbDataActionMoveFirst | 1 | MoveFirst method
vbDataActionMovePrevious | 2 | MovePrevious method
vbDataActionMoveNext | 3 | MoveNext method
vbDataActionMoveLast | 4 | MoveLast method
vbDataActionAddNew | 5 | AddNew method
vbDataActionUpdate | 6 | Update operation (not UpdateRecord)
vbDataActionDelete | 7 | Delete method
vbDataActionFind | 8 | Find method
vbDataActionBookmark | 9 | The Bookmark property has been set
vbDataActionClose | 10 | The Close method
vbDataActionUnload | 11 | The form is being unloaded

The settings for save are:

Setting | Description
True | Bound data has changed
False | Bound data has not changed

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

The save argument initially indicates whether bound data has changed. This argument can still be False if data in the copy buffer is changed. If save is True when this event exits, the Edit and UpdateRecord methods are invoked. Only data from bound controls or from the copy buffer where the DataChanged property is set to True are saved by the UpdateRecord method.

This event occurs even if no changes have been made to data in bound controls and even if no bound controls exist. You can use this event to change values and update data. You can also choose to save data or stop whatever action is causing the event to occur and substitute a different action.

You can change the action argument to convert one action into another. You can change the various Move methods and the AddNew method, which can be freely exchanged (any Move into AddNew, any Move into any other Move, or AddNew into any Move). When using AddNew, you can use MoveNext and then execute another AddNew to examine the EditMode property to determine if an Edit or AddNew operation is in progress. Attempting to change AddNew or one of the Moves into any of the other actions is either ignored or produces a trappable error. Any action can be stopped by setting action to 0.

In your code for this event, you can check the data in each bound control where DataChanged is True. You can then set DataChanged to False to avoid saving that data in the database.

You can't use any methods (such as MoveNext) on the underlying Recordset object during this event.


Validate Event

Occurs before the focus shifts to a (second) control that has its CausesValidation property set to True.

Syntax

Private Sub object_Validate(KeepFocus As Boolean)

The Validate event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
KeepFocus | Value that determines if the control loses focus. Setting KeepFocus to True specifies that the control retains the focus.

Remarks

The Validate event works in tandem with the CausesValidation property to prevent a control from losing the focus until certain criteria are met.

Important The Validate event only occurs when the control which is about to receive the focus has its CausesValidation property set to True.


Validate Event, CausesValidation Property Example

The example uses three controls to demonstrate the use of the Validate event and CausesValidation property. By default, the CausesValidation property of the two TextBox controls are set to True. Thus when you try to shift the focus from one TextBox to the other, the Validate event occurs. If Text1 doesn't contain a date, or if Text2 doesn't contain a number larger than 10, the shift of focus is prevented. Because the CausesValidation property of the Command1 control is set to False, however, you can always click the Help button.

To try the example, place one CommandButton and two TextBox controls on a form. Paste the code into the Declarations section of the form and run the project. Attempt to shift the focus by pressing the Tab key.

Private Sub Form_Load()
   ' Set the button's CausesValidation property to False. When the user
   ' clicks the button, the Validate event does not occur.
   ' Set the Caption property of the button to "Help".
   With Command1
      .CausesValidation = False
      .Caption = "Help"
   End With

   Show
   With Text1 ' Select text of Text1 and set focus to it.
      .SelLength = Len(Text1.Text)
      .SetFocus
   End With
End Sub

Private Sub Command1_Click()
   ' Give the user help when the button is clicked.
   MsgBox _
   "Text1 must be set to a date." & VbCrLF & _
   "Text2 must be a number less than 10."
End Sub

Private Sub Text1_Validate(KeepFocus As Boolean)
   ' If the value is not a date, keep the focus, unless the user
   ' clicks Help.
   If Not IsDate(Text1.Text) Then
      KeepFocus = True
      MsgBox "Please insert a date in this field.", ,   "Text1"
   End if
End Sub

Private Sub Text2_Validate(KeepFocus As Boolean)
   ' If the value is a number larger than 10, keep the focus.
   If Not IsNumeric(Text2.Text) Or Val(Text2.Text) > 10 Then
      KeepFocus = True
MsgBox _
"Please insert a number less than or equal to 10.", , "Text2"
   End If
End Sub


WriteProperties Event

Occurs when an instance of an object is to be saved. This event signals to the object that the state of the object needs to be saved, so that the state can be restored later. In most cases, the state of the object consists only of property values.

Syntax

Sub object_WriteProperties(pb As PropertyBag)

The WriteProperties event syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
pb | An object of the type PropertyBag class to write the data to.

Remarks

The author of object can have object save the state when the WriteProperties event occurs, by calling the WriteProperty method of the PropertyBag object for each value that is to be saved.

Note The pb property bag may be different from the pb that was passed to the most recent ReadProperties event.

The WriteProperties event may occur multiple times during the life of an instance of object.


GetAutoServerSettings Function

Returns information about the state of an ActiveX component's registration.

Syntax

object.GetAutoServerSettings([progid], [clsid])

The GetAutoServerSettings function syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
progid | Optional. A variant expression specifying the ProgID for the component.
clsid | Optional. A variant expression specifying the CLSID for the component.

Return Values

The GetAutoServerSettings function returns a Variant that contains an array of values about the given ActiveX component. The index values and descriptions are:

Value | Description
1 | True if the ActiveX component is registered remotely.
2 | Remote machine name.
3 | RPC network protocol name.
4 | RPC authentication level.

Remarks

If a value is missing or not available, the value will be an empty string. If there is an error during the method, then the return value will be a Variant of type Empty.


GetAutoServerSettings Function Example

This example retrieves information about a remotely registered object named "Hello":

Sub ViewHello()
   Dim oRegClass As New RegClass
   Dim vRC As Variant
   vRC = oRegClass.GetAutoServerSettings _
  ("HelloProj.HelloClass")
   If Not(IsEmpty(vRC)) Then
      If vRC(1) Then
         MsgBox "Hello is registered remotely on a " _
         & "server named: " & vRC(1)
      Else
         MsgBox "Hello is registered locally."
      End If
   End if
End Sub


LoadPicture Function

Loads a graphic into a form’s Picture property, a PictureBox control, or an Image control.

Syntax

LoadPicture([filename], [size], [colordepth],[x,y])

The LoadPicture function syntax has these parts:

Part | Description
filename | Optional. String expression specifying a filename. Can include folder and drive. If no filename is specified LoadPicture clears the Image or PictureBox control.
size | Optional variant. If filename is a cursor or icon file, specifies the desired image size.
colordepth | Optional variant. If filename is a cursor or icon file, specifies the desired color depth.
x | Optional variant, required if y is used. If filename is a cursor or icon file, specifies the width desired. In a file containing multiple separate images, the best possible match is used if an image of that size is not available. X and y values are only used when colordepth is set to vbLPCustom. For icon files 255 is the maximum possible value.
y | Optional variant, required if x is used. If filename is a cursor or icon file, specifies the height desired. In a file containing multiple separate images, the best possible match is used if an image of that size is not available. For icon files 255 is the maximum possible value.

Settings

The settings for size are:

Constant Value Description

vbLPSmall | 0 | System small icon.
vbLPLarge | 1 | System large icon size, as determined by the video driver.
vbLPSmallShell | 2 | Shell small icon size, as determined by the Caption Buttons size setting on the Appearance tab in the Control Panel Display Properties dialog box.
vbLPLargeShell | 3 | Shell large icon size, as determined by the Icon size setting on the Appearance tab in the Control Panel Display Properties dialog box.
vbLPCustom | 4 | Custom size, values provided by x and y arguments

The settings for colordepth are:

Constant Value Description

vbLPDefault | 0 | Best available match if the specified file is used.
vbLPMonochrome | 1 | 2 colors.
vbLPVGAColor | 2 | 16 colors.
vbLPColor | 3 | 256 colors.

Remarks

Graphics formats recognized by Visual Basic include bitmap (.bmp) files, icon (.ico) files, cursor (.cur) files, run-length encoded (.rle) files, metafile (.wmf) files, enhanced metafiles (.emf), GIF (.gif) files, and JPEG (.jpg) files.

Graphics are cleared from forms, picture boxes, and image controls by assigning LoadPicture with no argument.

To load graphics for display in a PictureBox control, Image control, or as the background of a form, the return value of LoadPicture must be assigned to the Picture property of the object on which the picture is displayed. For example:

Set Picture = LoadPicture("PARTY.BMP")
Set Picture1.Picture = LoadPicture("PARTY.BMP")

To assign an icon to a form, set the return value of the LoadPicture function to the Icon property of the Form object:

Set Form1.Icon = LoadPicture("MYICON.ICO")

Icons can also be assigned to the DragIcon property of all controls except Timer controls and Menu controls. For example:

Set Command1.DragIcon = LoadPicture("MYICON.ICO")

Load a graphics file into the system Clipboard using LoadPicture as follows:

Clipboard.SetData LoadPicture("PARTY.BMP")


LoadPicture Function Example

This example uses the LoadPicture function to load a picture into a PictureBox control and to clear the picture from the control. To try this example, add a PictureBox control to a Form object, paste the code into the Declarations section of the Form, and then run the example and click the Form.

Private Sub Form_Click ()
   Dim Msg as String   ' Declare variables.
   On Error Resume Next   ' Set up error handling.
   Height = 3990
   Width = 4890   ' Set height and width.
   Picture1.Picture = LoadPicture("PAPER.CUR", vbLPCustom, vbLPColor, 32, 32)   ' Load cursor.
   If Err Then
      Msg = "Couldn't find the .cur file."
      MsgBox Msg   ' Display error message.
      Exit Sub   ' Quit if error occurs.
   End If
   Msg = "Choose OK to clear the bitmap from the picturebox."
   MsgBox Msg
   Picture1.Picture = LoadPicture()   'Clear the picturebox.
End Sub


Alignment Constants

Align Property

Constant | Value | Description
vbAlignNone | 0 | Size and location set at design time or in code
vbAlignTop | 1 | Align control to top of form
vbAlignBottom | 2 | Align control to bottom of form
vbAlignLeft | 3 | Align control to left of form
vbAlignRight | 4 | Align control to right of form

Alignment Property

Constant | Value | Description
vbLeftJustify | 0 | Left align
vbRightJustify | 1 | Right align
vbCenter | 2 | Center


BorderStyle Property Constants

BorderStyle Property (Form)

Constant | Value | Description
vbBSNone | 0 | No border
vbFixedSingle | 1 | Fixed single
vbSizable | 2 | Sizable (forms only)
vbFixedDialog | 3 | Fixed dialog (forms only)
vbFixedToolWindow | 4 | Fixed tool window
vbSizableToolWindow | 5 | Sizable tool window

BorderStyle Property (Shape and Line)

Constant | Value | Description
vbTransparent | 0 | Transparent
vbBSSolid | 1 | Solid
vbBSDash | 2 | Dash
vbBSDot | 3 | Dot
vbBSDashDot | 4 | Dash-dot
vbBSDashDotDot | 5 | Dash-dot-dot
vbBSInsideSolid | 6 | Inside solid


BorderStyle Constants (ActiveX Controls)

Constant | Value | Description
ccNone | 0 | (Default) No border or border-related elements.
ccFixedSingle | 1 | (Default for ListView control) Fixed single. There is a single line border around the control.

Note The cc prefix is reserved for the ActiveX controls. The prefixes for the constants may change with the specific control or group of controls. However, the description remains the same unless indicated.


Clipboard Object Constants

Constant | Value | Description
vbCFRTF | -16639 | Rich Text Format (.rtf file)
vbCFLink | -16640 | DDE conversation information
vbCFText | 1 | Text (.txt file)
vbCFBitmap | 2 | Bitmap (.bmp file)
vbCFMetafile | 3 | Metafile (.wmf file)
vbCFDIB | 8 | Device-independent bitmap
vbCFPalette | 9 | Color palette
vbCFEMetaFile | 14 | Enhanced metafile (.emf file)
vbCFFiles | 15 | File list from Windows Explorer


Color Constants

Colors

Constant | Value | Description
vbBlack | &H0 | Black
vbRed | &HFF | Red
vbGreen | &HFF00 | Green
vbYellow | &HFFFF | Yellow
vbBlue | &HFF0000 | Blue
vbMagenta | &HFF00FF | Magenta
vbCyan | &HFFFF00 | Cyan
vbWhite | &HFFFFFF | White

System Colors

Constant | Value | Description
vbScrollBars | &H80000000 | Scroll bar color
vbDesktop | &H80000001 | Desktop color
vbActiveTitleBar | &H80000002 | Color of the title bar for the active window
vbInactiveTitleBar | &H80000003 | Color of the title bar for the inactive window
vbMenuBar | &H80000004 | Menu background color
vbWindowBackground | &H80000005 | Window background color
vbWindowFrame | &H80000006 | Window frame color
vbMenuText | &H80000007 | Color of text on menus
vbWindowText | &H80000008 | Color of text in windows
vbTitleBarText | &H80000009 | Color of text in caption, size box, and scroll arrow
vbActiveBorder | &H8000000A | Border color of active window
vbInactiveBorder | &H8000000B | Border color of inactive window
vbApplicationWorkspace | &H8000000C | Background color of multiple-document interface (MDI) applications
vbHighlight | &H8000000D | Background color of items selected in a control
vbHighlightText | &H8000000E | Text color of items selected in a control
vbButtonFace | &H8000000F | Color of shading on the face of command buttons
vbButtonShadow | &H80000010 | Color of shading on the edge of command buttons
vbGrayText | &H80000011 | Grayed (disabled) text
vbButtonText | &H80000012 | Text color on push buttons
vbInactiveCaptionText | &H80000013 | Color of text in an inactive caption
vb3DHighlight | &H80000014 | Highlight color for 3D display elements
vb3DDKShadow | &H80000015 | Darkest shadow color for 3D display elements
vb3DLight | &H80000016 | Second lightest of the 3D colors after vb3Dhighlight
vb3DFace | &H8000000F | Color of text face
vb3Dshadow | &H80000010 | Color of text shadow
vbInfoText | &H80000017 | Color of text in ToolTips
vbInfoBackground | &H80000018 | Background color of ToolTips


Control Constants

ComboBox Control

Constant | Value | Description
vbComboDropdown | 0 | Dropdown Combo
vbComboSimple | 1 | Simple Combo
vbComboDropdownList | 2 | Dropdown List

CheckBox Control

Constant | Value | Description
vbUnchecked | 0 | Unchecked
vbChecked | 1 | Checked
vbGrayed | 2 | Grayed

ListBox Control

Constant | Value | Description
vbListBoxStandard | 0 | Standard Windows ListBox appearance
vbListBoxCheckBox | 1 | Listbox entries contain selectable CheckBoxes
vbMultiSelectNone | 0 | No multiple selection
vbMultiSelectSimple | 1 | Simple multiple selection
vbMultiSelectExtended | 2 | Extended multiple selection

ScrollBar Control

Constant | Value | Description
vbSBNone | 0 | None
vbHorizontal | 1 | Horizontal
vbVertical | 2 | Vertical
vbBoth | 3 | Both

Shape Control

Constant | Value | Description
vbShapeRectangle | 0 | Rectangle
vbShapeSquare | 1 | Square
vbShapeOval | 2 | Oval
vbShapeCircle | 3 | Circle
vbShapeRoundedRectangle | 4 | Rounded rectangle
vbShapeRoundedSquare | 5 | Rounded square


DDE Constants

linkerr (LinkError Event)

Constant | Value | Description
vbWrongFormat | 1 | Another application requested data in wrong format
vbDDESourceClosed | 6 | Destination application attempted to continue after source closed
vbTooManyLinks | 7 | All source links are in use
vbDataTransferFailed | 8 | Failure to update data in destination

LinkMode Property (Forms and Controls)

Constant | Value | Description
vbLinkNone | 0 | None
vbLinkSource | 1 | Source (forms only)
vbLinkAutomatic | 1 | Automatic (controls only)
vbLinkManual | 2 | Manual (controls only)
vbLinkNotify | 3 | Notify (controls only)

LinkMode Property (Only for backward compatibility with Visual Basic version 1.0; use new constants instead)

Constant | Value | Description
vbHot | 1 | Hot (controls only)
vbServer | 1 | Server (forms only)
vbCold | 2 | Cold (controls only)


Drag-and-Drop Constants

DragOver and OLEDragOver Event

Constant | Value | Description
vbEnter | 0 | Source control dragged into target
vbLeave | 1 | Source control dragged out of target
vbOver | 2 | Source control dragged from one position in target to another

Drag Method (Controls)

Constant | Value | Description
vbCancel | 0 | Cancel drag operation
vbBeginDrag | 1 | Begin dragging control
vbEndDrag | 2 | Drop control

DragMode Property

Constant | Value | Description
vbManual | 0 | Manual
vbAutomatic | 1 | Automatic

OLEDragMode Property

Constant | Value | Description
vbOLEDragManual | 0 | Manual
vbOLEDragAutomatic | 1 | Automatic

OLEDropMode Property

Constant | Value | Description
vbOLEDropNone | 0 | None
vbOLEDropManual | 1 | Manual
vbOLEDropAutomatic | 2 | Automatic

OLE Drop Effect

Constant | Value | Description
vbOLEDropEffectNone | 0 | No OLE drag/drop operation has taken place
vbOLEDropEffectCopy | 1 | A mask indicating that a copy operation has taken, or would take, place
vbOLEDropEffectMove | 2 | A mask indicating that a move operation has taken, or would take, place
vbOLEDropEffectScroll | &H80000000 | A mask indicating that the drop target window has scrolled, or will scroll


Drawing Constants

DrawMode Property

Constant | Value | Description
vbBlackness | 1 | Black
vbNotMergePen | 2 | Not Merge pen
vbMaskNotPen | 3 | Mask Not pen
vbNotCopyPen | 4 | Not Copy pen
vbMaskPenNot | 5 | Mask pen Not
vbInvert | 6 | Invert
vbXorPen | 7 | Xor pen
vbNotMaskPen | 8 | Not Mask pen
vbMaskPen | 9 | Mask pen
vbNotXorPen | 10 | Not Xor pen
vbNop | 11 | No operation; output remains unchanged
vbMergeNotPen | 12 | Merge Not pen
vbCopyPen | 13 | Copy pen
vbMergePenNot | 14 | Merge pen Not
vbMergePen | 15 | Merge pen
vbWhiteness | 16 | White

DrawStyle Property

Constant | Value | Description
vbSolid | 0 | Solid
vbDash | 1 | Dash
vbDot | 2 | Dot
vbDashDot | 3 | Dash-dot
vbDashDotDot | 4 | Dash-dot-dot
vbInvisible | 5 | Invisible
vbInsideSolid | 6 | Inside solid


Form Constants

Show Parameters

Constant | Value | Description
vbModal | 1 | Modal form
vbModeless | 0 | Modeless form

Arrange Method for MDI Forms

Constant | Value | Description
vbCascade | 0 | Cascade all nonminimized MDI child forms
vbTileHorizontal | 1 | Horizontally tile all nonminimized MDI child forms
vbTileVertical | 2 | Vertically tile all nonminimized MDI child forms
vbArrangeIcons | 3 | Arrange icons for minimized MDI child forms

WindowState Property

Constant | Value | Description
vbNormal | 0 | Normal
vbMinimized | 1 | Minimized
vbMaximized | 2 | Maximized


Graphics Constants

FillStyle Property

Constant | Value | Description
vbFSSolid | 0 | Solid
vbFSTransparent | 1 | Transparent
vbHorizontalLine | 2 | Horizontal line
vbVerticalLine | 3 | Vertical line
vbUpwardDiagonal | 4 | Upward diagonal
vbDownwardDiagonal | 5 | Downward diagonal
vbCross | 6 | Cross
vbDiagonalCross | 7 | Diagonal cross

ScaleMode Property

Constant | Value | Description
vbUser | 0 | User
vbTwips | 1 | Twips
vbPoints | 2 | Points
vbPixels | 3 | Pixels
vbCharacters | 4 | Characters
vbInches | 5 | Inches
vbMillimeters | 6 | Millimeters
vbCentimeters | 7 | Centimeters
vbHiMetric | 8 | HiMetric
vbContainerPosition | 9 | Units used by the control's container to determine the control's position
vbContainerSize | 10 | Units used by the control's container to determine the control's size

PaletteMode Property

Constant | Value | Description
vbPaletteModeHalfTone | 0 | Use system halftone palette
vbPaletteModeUseZOrder | 1 | Use palette from topmost control that has a palette
vbPaletteModeCustom | 2 | Use palette specified in Palette property
vbPaletteModeContainer | 3 | Use the container's palette for containers that support ambient Palette property
vbPaletteModeNone | 4 | Do not use any palette
vbPaletteModeObject | 5 | Use the ActiveX designer's palette


Help Constants

Constant | Value | Description
cdlHelpContext | &H1 | Displays Help for a particular topic
cdlHelpQuit | &H2 | Notifies the Help application that the specified Help file is no longer in use
cdlHelpIndex | &H3 | Displays the index of the specified Help file
cdlHelpContents | &H3 | Displays the contents topic in the current Help file
cdlHelpHelpOnHelp | &H4 | Displays Help for using the Help application itself
cdlHelpSetIndex | &H5 | Sets the current index for multi-index Help
cdlHelpSetContents | &H5 | Designates a specific topic as the contents topic
cdlHelpContextPopup | &H8 | Displays a topic identified by a context number
cdlHelpForceFile | &H9 | Creates a Help file that displays text in only one font
cdlHelpKey | &H101 | Displays Help for a particular keyword
cdlHelpCommandHelp | &H102 | Displays Help for a particular command
cdlHelpPartialKey | &H105 | Calls the search engine in Windows Help


Key Code Constants

Key Codes

Constant | Value | Description
vbKeyLButton | 1 | Left mouse button
vbKeyRButton | 2 | Right mouse button
vbKeyCancel | 3 | CANCEL key
vbKeyMButton | 4 | Middle mouse button
vbKeyBack | 8 | BACKSPACE key
vbKeyTab | 9 | TAB key
vbKeyClear | 12 | CLEAR key
vbKeyReturn | 13 | ENTER key
vbKeyShift | 16 | SHIFT key
vbKeyControl | 17 | CTRL key
vbKeyMenu | 18 | MENU key
vbKeyPause | 19 | PAUSE key
vbKeyCapital | 20 | CAPS LOCK key
vbKeyEscape | 27 | ESC key
vbKeySpace | 32 | SPACEBAR key
vbKeyPageUp | 33 | PAGE UP key
vbKeyPageDown | 34 | PAGE DOWN key
vbKeyEnd | 35 | END key
vbKeyHome | 36 | HOME key
vbKeyLeft | 37 | LEFT ARROW key
vbKeyUp | 38 | UP ARROW key
vbKeyRight | 39 | RIGHT ARROW key
vbKeyDown | 40 | DOWN ARROW key
vbKeySelect | 41 | SELECT key
vbKeyPrint | 42 | PRINT SCREEN key
vbKeyExecute | 43 | EXECUTE key
vbKeySnapshot | 44 | SNAPSHOT key
vbKeyInsert | 45 | INS key
vbKeyDelete | 46 | DEL key
vbKeyHelp | 47 | HELP key
vbKeyNumlock | 144 | NUM LOCK key

KeyA Through KeyZ Are the Same as Their ASCII Equivalents: 'A' Through 'Z'

Constant | Value | Description
vbKeyA | 65 | A key
vbKeyB | 66 | B key
vbKeyC | 67 | C key
vbKeyD | 68 | D key
vbKeyE | 69 | E key
vbKeyF | 70 | F key
vbKeyG | 71 | G key
vbKeyH | 72 | H key
vbKeyI | 73 | I key
vbKeyJ | 74 | J key
vbKeyK | 75 | K key
vbKeyL | 76 | L key
vbKeyM | 77 | M key
vbKeyN | 78 | N key
vbKeyO | 79 | O key
vbKeyP | 80 | P key
vbKeyQ | 81 | Q key
vbKeyR | 82 | R key
vbKeyS | 83 | S key
vbKeyT | 84 | T key
vbKeyU | 85 | U key
vbKeyV | 86 | V key
vbKeyW | 87 | W key
vbKeyX | 88 | X key
vbKeyY | 89 | Y key
vbKeyZ | 90 | Z key

Key0 Through Key9 Are the Same as Their ASCII Equivalents: '0' Through '9

Constant | Value | Description
vbKey0 | 48 | 0 key
vbKey1 | 49 | 1 key
vbKey2 | 50 | 2 key
vbKey3 | 51 | 3 key
vbKey4 | 52 | 4 key
vbKey5 | 53 | 5 key
vbKey6 | 54 | 6 key
vbKey7 | 55 | 7 key
vbKey8 | 56 | 8 key
vbKey9 | 57 | 9 key

Keys on the Numeric Keypad

Constant | Value | Description
vbKeyNumpad0 | 96 | 0 key
vbKeyNumpad1 | 97 | 1 key
vbKeyNumpad2 | 98 | 2 key
vbKeyNumpad3 | 99 | 3 key
vbKeyNumpad4 | 100 | 4 key
vbKeyNumpad5 | 101 | 5 key
vbKeyNumpad6 | 102 | 6 key
vbKeyNumpad7 | 103 | 7 key
vbKeyNumpad8 | 104 | 8 key
vbKeyNumpad9 | 105 | 9 key
vbKeyMultiply | 106 | MULTIPLICATION SIGN (*) key
vbKeyAdd | 107 | PLUS SIGN (+) key
vbKeySeparator | 108 | ENTER (keypad) key
vbKeySubtract | 109 | MINUS SIGN (-) key
vbKeyDecimal | 110 | DECIMAL POINT(.) key
vbKeyDivide | 111 | DIVISION SIGN (/) key

Function Keys

Constant | Value | Description
vbKeyF1 | 112 | F1 key
vbKeyF2 | 113 | F2 key
vbKeyF3 | 114 | F3 key
vbKeyF4 | 115 | F4 key
vbKeyF5 | 116 | F5 key
vbKeyF6 | 117 | F6 key
vbKeyF7 | 118 | F7 key
vbKeyF8 | 119 | F8 key
vbKeyF9 | 120 | F9 key
vbKeyF10 | 121 | F10 key
vbKeyF11 | 122 | F11 key
vbKeyF12 | 123 | F12 key
vbKeyF13 | 124 | F13 key
vbKeyF14 | 125 | F14 key
vbKeyF15 | 126 | F15 key
vbKeyF16 | 127 | F16 key


Menu Control Constants

PopupMenu Method Alignment

Constant | Value | Description
vbPopupMenuLeftAlign | 0 | Pop-up menu left-aligned
vbPopupMenuCenterAlign | 4 | Pop-up menu centered
vbPopupMenuRightAlign | 8 | Pop-up menu right-aligned

PopupMenu Mouse Button Recognition

Constant | Value | Description
vbPopupMenuLeftButton | 0 | Pop-up menu recognizes left mouse button only
vbPopupMenuRightButton | 2 | Pop-up menu recognizes right and left mouse buttons


Miscellaneous Constants

AsyncRead Method

Constant | Value | Description
vbAsyncTypePicture | 0 | Data is provided in a Picture object
vbAsyncTypeFile | 1 | Data is provided in a file provide by Visual Basic
vbAsyncTypeByteArray | 2 | Data is provided in a byte array that contains the retrieved data

Application Start Mode

Constant | Value | Description
vbSModeStandalone | 0 | Stand-alone application
vbSModeAutomation | 1 | OLE automation server

Buttons (Applies to CommandButton, CheckBox, and OptionButton controls)

Constant | Value | Description
vbButtonStandard | 0 | Buttons have standard Windows appearance
vbButtonGraphical | 1 | Buttons have graphical appearance (that is, they contain pictures, text, and/or a non-standard BackColor)

LoadResPicture Method

Constant | Value | Description
vbResBitmap | 0 | Bitmap resource
vbResIcon | 1 | Icon resource
vbResCursor | 2 | Cursor resource

LogEvent Method

Constant | Value | Description
vbLogEventTypeError | 1 | Log an Error event
vbLogEventTypeWarning | 2 | Log a Warning event
vbLogEventTypeInformation | 4 | Log an Information event

Mouse Button Parameter Masks

Constant | Value | Description
vbLeftButton | 1 | Left mouse button
vbRightButton | 2 | Right mouse button
vbMiddleButton | 4 | Middle mouse button

QueryUnload Method

Constant | Value | Description
vbAppWindows | 2 | Current Windows session ending
vbFormMDIForm | 4 | MDI child form is closing because the MDI form is closing
vbFormCode | 1 | Unload method invoked from code
vbFormControlMenu | 0 | User has chosen Close command from the Control-menu box on a form
vbAppTaskManager | 3 | Windows Task Manager is closing the application

Shift Parameter Masks

Constant | Value | Description
vbShiftMask | 1 | SHIFT key bit mask
vbCtrlMask | 2 | CTRL key bit mask
vbAltMask | 4 | ALT key bit mask

ZOrder Method

Constant | Value | Description
vbBringToFront | 0 | Bring to front
vbSendToBack | 1 | Send to back


Mouse Pointer Constants

Constant | Value | Description
vbDefault | 0 | Default
vbArrow | 1 | Arrow
vbCrosshair | 2 | Cross
vbIbeam | 3 | I beam
vbIconPointer | 4 | Icon
vbSizePointer | 5 | Size
vbSizeNESW | 6 | Size NE, SW
vbSizeNS | 7 | Size N, S
vbSizeNWSE | 8 | Size NW, SE
vbSizeWE | 9 | Size W, E
vbUpArrow | 10 | Up arrow
vbHourglass | 11 | Hourglass
vbNoDrop | 12 | No drop
vbArrowHourglass | 13 | Arrow and hourglass; (available only in 32-bit Visual Basic 5.0)
vbArrowQuestion | 14 | Arrow and question mark; (available only in 32-bit Visual Basic 5.0)
vbSizeAll | 15 | Size all; (available only in 32-bit Visual Basic 5.0)
vbCustom | 99 | Custom icon specified by the MouseIcon property


MousePointer Constants

Constant | Value | Description
ccDefault | 0 | (Default) Shape determined by the object.
ccArrow | 1 | Arrow.
ccCross | 2 | Cross (cross-hair pointer).
ccIbeam | 3 | I Beam.
ccIcon | 4 | Icon (small square within a square).
ccSize | 5 | Size (four-pointed arrow pointing north, south, east, and west).
ccSizeNESW | 6 | Size NE SW (double arrow pointing northeast and southwest).
ccSizeNS | 7 | Size N S (double arrow pointing north and south).
ccSizeNWSE | 8 | Size NW, SE.
ccSizeEW | 9 | Size E W (double arrow pointing east and west).
ccUpArrow | 10 | Up Arrow.
ccHourglass | 11 | Hourglass (wait).
ccNoDrop | 12 | No Drop.
ccArrowHourglass | 13 | Arrow and hourglass.
cc ArrowQuestion | 14 | Arrow and question mark.
ccSizeAll | 15 | Size all.
ccCustom | 99 | Custom icon specified by the MouseIcon property.

Note The cc prefix is reserved for ActiveX controls. Prefixes for the constants may change with the specific control or group of controls. However, the description remains the same unless indicated.


OLE Container Control Constants

OLEType Property

Constant | Value | Description
vbOLELinked | 0 | OLE container control contains a linked object
vbOLEEmbedded | 1 | OLE container control contains an embedded object
vbOLENone | 3 | OLE container control doesn't contain an object

OLETypeAllowed Property

Constant | Value | Description
vbOLEEither | 2 | OLE container control can contain either a linked or an embedded object

UpdateOptions Property

Constant | Value | Description
vbOLEAutomatic | 0 | Object is updated each time the linked data changes
vbOLEFrozen | 1 | Object is updated whenever the user saves the linked document from within the application in which it was created
vbOLEManual | 2 | Object is updated only when the Action property is set to 6 (Update)

AutoActivate Property

Constant | Value | Description
vbOLEActivateManual | 0 | OLE object isn't automatically activated
vbOLEActivateGetFocus | 1 | Object is activated when the OLE container control gets the focus
vbOLEActivateDoubleclick | 2 | Object is activated when the OLE container control is double-clicked
vbOLEActivateAuto | 3 | Object is activated based on the object's default method of activation

SizeMode Property

Constant | Value | Description
vbOLESizeClip | 0 | Object's image is clipped by the OLE container control's borders
vbOLESizeStretch | 1 | Object's image is sized to fill the OLE container control
vbOLESizeAutoSize | 2 | OLE container control is automatically resized to display the entire object
vbOLESizeZoom | 3 | Object's image is stretched but in proportion

DisplayType Property

Constant | Value | Description
vbOLEDisplayContent | 0 | Object's data is displayed in the OLE container control
vbOLEDisplayIcon | 1 | Object's icon is displayed in the OLE container control

Updated Event Constants

Constant | Value | Description
vbOLEChanged | 0 | Object's data has changed
vbOLESaved | 1 | Object's data has been saved by the application that created the object
vbOLEClosed | 2 | Application file containing the linked object's data has been closed
vbOLERenamed | 3 | Application file containing the linked object's data has been renamed

Special Verb Values

Constant | Value | Description
vbOLEPrimary | 0 | Default action for the object
vbOLEShow | -1 | Activates the object for editing
vbOLEOpen | -2 | Opens the object in a separate application window
vbOLEHide | -3 | For embedded objects, hides the application that created the object
vbOLEUIActivate | -4 | All UI's associated with the object are visible and ready for use
vbOLEInPlaceActivate | -5 | Object is ready for the user to click inside it and start working with it
vbOLEDiscardUndoState | -6 | For discarding all record of changes that the object's application can undo

Verb Flag Bit Masks

Constant | Value | Description
vbOLEFlagGrayed | &H1 | Grayed menu item
vbOLEFlagDisabled | &H2 | Disabled menu item
vbOLEFlagChecked | &H8 | Checked menu item
vbOLEFlagSeparator | &H800 | Separator bar in menu item list
vbOLEMiscFlagMemStorage | &H1 | Causes control to use memory to store the object while it's loaded
vbOLEMiscFlagDisableInPlace | &H2 | Forces OLE container control to activate objects in a separate window


Picture Object Constants

Constant | Value | Description
vbPicTypeNone | 0 | Icon type of Picture object
vbPicTypeBitmap | 1 | Bitmap type of Picture object
vbPicTypeMetafile | 2 | Metafile type of Picture object
vbPicTypeIcon | 3 | Icon type of Picture object
vbPicTypeEMetaFile | 4 | Enhanced metafile type of Picture object


Printer Object Constants

Printer Color Mode

Constant | Value | Description
vbPRCMMonochrome | 1 | Monochrome output
vbPRCMColor | 2 | Color output

Duplex Printing

Constant | Value | Description
vbPRDPSimplex | 1 | Single-sided printing
vbPRDPHorizontal | 2 | Double-sided horizontal printing
vbPRDPVertical | 3 | Double-sided vertical printing

Printer Orientation

Constant | Value | Description
vbPRORPortrait | 1 | Documents print with the top at the narrow side of the paper
vbPRORLandscape | 2 | Documents print with the top at the wide side of the paper

Print Quality

Constant | Value | Description
vbPRPQDraft | -1 | Draft print quality
vbPRPQLow | -2 | Low print quality
vbPRPQMedium | -3 | Medium print quality
vbPRPQHigh | -4 | High print quality

PaperBin Property

Constant | Value | Description
vbPRBNUpper | 1 | Use paper from the upper bin
vbPRBNLower | 2 | Use paper from the lower bin
vbPRBNMiddle | 3 | Use paper from the middle bin
vbPRBNManual | 4 | Wait for manual insertion of each sheet of paper
vbPRBNEnvelope | 5 | Use envelopes from the envelope feeder
vbPRBNEnvManual | 6 | Use envelopes from the envelope feeder, but wait for manual insertion
vbPRBNAuto | 7 | (Default) Use paper from the current default bin
vbPRBNTractor | 8 | Use paper fed from the tractor feeder
vbPRBNSmallFmt | 9 | Use paper from the small paper feeder
vbPRBNLargeFmt | 10 | Use paper from the large paper bin
vbPRBNLargeCapacity | 11 | Use paper from the large capacity feeder
vbPRBNCassette | 14 | Use paper from the attached cassette cartridge

PaperSize Property

Constant | Value | Description
vbPRPSLetter | 1 | Letter, 8 1/2 x 11 in
vbPRPSLetterSmall | 2 | +A611Letter Small, 8 1/2 x 11 in
vbPRPSTabloid | 3 | Tabloid, 11 x 17 in
vbPRPSLedger | 4 | Ledger, 17 x 11 in
vbPRPSLegal | 5 | Legal, 8 1/2 x 14 in
vbPRPSStatement | 6 | Statement, 5 1/2 x 8 1/2 in
vbPRPSExecutive | 7 | Executive, 7 1/2 x 10 1/2 in
vbPRPSA3 | 8 | A3, 297 x 420 mm
vbPRPSA4 | 9 | A4, 210 x 297 mm
vbPRPSA4Small | 10 | A4 Small, 210 x 297 mm
vbPRPSA5 | 11 | A5, 148 x 210 mm
vbPRPSB4 | 12 | B4, 250 x 354 mm
vbPRPSB5 | 13 | B5, 182 x 257 mm
vbPRPSFolio | 14 | Folio, 8 1/2 x 13 in
vbPRPSQuarto | 15 | Quarto, 215 x 275 mm
vbPRPS1&H14 | 16 | 10 x 14 in
vbPRPS11x17 | 17 | 11 x 17 in
vbPRPSNote | 18 | Note, 8 1/2 x 11 in
vbPRPSEnv9 | 19 | Envelope #9, 3 7/8 x 8 7/8 in
vbPRPSEnv10 | 20 | Envelope #10, 4 1/8 x 9 1/2 in
vbPRPSEnv11 | 21 | Envelope #11, 4 1/2 x 10 3/8 in
vbPRPSEnv12 | 22 | Envelope #12, 4 1/2 x 11 in
vbPRPSEnv14 | 23 | Envelope #14, 5 x 11 1/2 in
vbPRPSCSheet | 24 | C size sheet
vbPRPSDSheet | 25 | D size sheet
vbPRPSESheet | 26 | E size sheet
vbPRPSEnvDL | 27 | Envelope DL, 110 x 220 mm
vbPRPSEnvC3 | 29 | Envelope C3, 324 x 458 mm
vbPRPSEnvC4 | 30 | Envelope C4, 229 x 324 mm
vbPRPSEnvC5 | 28 | Envelope C5, 162 x 229 mm
vbPRPSEnvC6 | 31 | Envelope C6, 114 x 162 mm
vbPRPSEnvC65 | 32 | Envelope C65, 114 x 229 mm
vbPRPSEnvB4 | 33 | Envelope B4, 250 x 353 mm
vbPRPSEnvB5 | 34 | Envelope B5, 176 x 250 mm
vbPRPSEnvB6 | 35 | Envelope B6, 176 x 125 mm
vbPRPSEnvItaly | 36 | Envelope, 110 x 230 mm
vbPRPSEnvMonarch | 37 | Envelope Monarch, 3 7/8 x 7 1/2 in
vbPRPSEnvPersonal | 38 | Envelope, 3 5/8 x 6 1/2 in
vbPRPSFanfoldUS | 39 | U.S. Standard Fanfold, 14 7/8 x 11 in
vbPRPSFanfoldStdGerman | 40 | German Standard Fanfold, 8 1/2 x 12 in
vbPRPSFanfoldLglGerman | 41 | German Legal Fanfold, 8 1/2 x 13 in
vbPRPSUser | 256 | User-defined


RasterOp Constants

Constant | Value | Description
vbDstInvert | &H00550009 | Inverts the destination bitmap
vbMergeCopy | &H00C000CA | Combines the pattern and the source bitmap
vbMergePaint | &H00BB0226 | Combines the inverted source bitmap with the destination bitmap by using Or
vbNotSrcCopy | &H00330008 | Copies the inverted source bitmap to the destination
vbNotSrcErase | &H001100A6 | Inverts the result of combining the destination and source bitmaps by using Or
vbPatCopy | &H00F00021L | Copies the pattern to the destination bitmap
vbPatInvert | &H005A0049L | Combines the destination bitmap with the pattern by using Xor
vbPatPaint | &H00FB0A09L | Combines the inverted source bitmap with the pattern by using Or. Combines the result of this operation with the destination bitmap by using Or
vbSrcAnd | &H008800C6 | Combines pixels of the destination and source bitmaps by using And
vbSrcCopy | &H00CC0020 | Copies the source bitmap to the destination bitmap
vbSrcErase | &H00440328 | Inverts the destination bitmap and combines the result with the source bitmap by using And
vbSrcInvert | &H00660046 | Combines pixels of the destination and source bitmaps by using Xor
vbSrcPaint | &H00EE0086 | Combines pixels of the destination and source bitmaps by using Or


Variant Type Constants

Constant | Value | Description
vbVEmpty | 0 | Empty (uninitialized)
vbVNull | 1 | Null (no valid data)
vbVInteger | 2 | Integer data type
vbVLong | 3 | Long integer data type
vbVSingle | 4 | Single-precision floating-point data type
vbVDouble | 5 | Double-precision floating-point data type
vbVCurrency | 6 | Currency (scaled integer) data type
vbVDate | 7 | Date data type
vbVString | 8 | String data type


Visual Basic Constants

The following constants are specified or recognized by Visual Basic. As a result, they can be used anywhere in your code in place of the actual values.

  • Add-In Constants

  • Alignment Constants

  • Asynchronous Constants

  • BorderStyle Property Constants

  • Button Constants

  • Clipboard Object Constants

  • Color Constants

  • CommonDialog Control Constants

  • ComboBox Constants

  • CommonDialog Error Constants

  • Control Constants

  • Data Control Constants

  • DefaultCursorType Constants

  • DataGrid Control Constants

  • DataList and DataCombo Controls Constants

  • DDE Constants

  • Drag-and-Drop Constants

  • Drawing Constants

  • Form Constants

  • FillStyle Constants

  • Graphics Constants

  • Help Constants

  • Key Code Constants

  • ListBox Constants

  • Menu Accelerator Constants

  • Menu Control Constants

  • Miscellaneous Constants

  • Mouse Pointer Constants

  • OLE Container Control Constants

  • Picture Object Constants

  • Printer Object Constants

  • RasterOp Constants

  • ScaleMode Constants

  • Variant Type Constants

Use the Object Browser to view the intrinsic constants you can use with methods and properties. From the View menu, choose Object Browser, select the Visual Basic object library, and then choose the Constants object. You can scroll through the constants that appear under Methods/Properties.


Visual Basic Menus

File Menu

Edit Menu

View Menu

Project Menu

Format Menu

Debug Menu

Run Menu

Query Menu

Diagram Menu

Tools Menu

Add-Ins Menu

Window Menu

Help Menu


ActiveX Control Constants

The following constants are recognized by the ActiveX controls. As a result, they can be used anywhere in your code in place of the actual values.

  • BorderStyle Constants

  • MousePointer Constants

  • OLEDragDrop Constants

Use the Object Browser to view the intrinsic constants you can use with methods and properties. From the View menu, choose Object Browser, select the appropriate control library, and then the Constants object. You can scroll through the constants that appear in the Members pane.

Note Prefixes for the constants change with the specific control or group of controls. However, the description remains the same unless indicated.


Form Window Keys

Use these key combinations in the Form window:

Press | To
F7 | Open the Code window for the selected object.
CTRL+C | Copy the selected controls to the Clipboard.
CTRL+X | Cut the selected controls to the Clipboard.
DEL | Delete the selected controls without placing them on the Clipboard.
CTRL+V | Paste the Clipboard contents on the form.
CTRL+Z | Undo a deletion of controls.
TAB | Cycle forward through controls in tab order.
SHIFT+TAB | Cycle backward through controls in tab order.
CTRL+CLICK | Add or remove a control from the selection.
CLICK+DRAG | Select multiple controls.
CTRL+CLICK+DRAG | Add or remove controls from the current selection.
SHIFT+CLICK | Select multiple controls.
CTRL+E | Display the Menu Editor (design time only).
F4 | Display the Properties window (design time only).
CTRL+J | Bring to front (affects overlapping controls at design time only).
CTRL+K | Send to back (affects overlapping controls at design time only).
CTRL+DOWN ARROW | Move the control down one grid unit (if the grid is turned on) or one pixel (if the grid is turned off).
CTRL+UP ARROW | Move the control up one grid unit (if the grid is turned on) or one pixel (if the grid is turned off).
CTRL+RIGHT ARROW | Move the control one grid unit (if the grid is turned one)or one pixel (if the grid is turned off) to the right.
CTRL+LEFT ARROW | Move the control one grid unit (if the grid is turned on) or one pixel (if the grid is turned off) to the left.

To deselect all controls, click the form. To select controls in a container, first deselect the container and then CTRL+CLICK+DRAG around the desired controls.


Global Keys

Use these key combinations in all Visual Basic windows:

Press | To
F5 | Run aan applications Sub/UserForm or macro.
F8 | Execute code one line at a time.
SHIFT+F8 | Execute statements one line at a time without stepping into procedure calls.
CTRL+BREAK | Stop running a Visual Basic application.
CTRL+G | Displays the Immediate window.
SHIFT+F5 | Restart an application from the beginning after an interruption.
CTRL+TAB | Switch between windows.
ALT+F5 | Runs the error handler code or returns the error to the calling procedure. Does not affect the setting for error trapping on the General tab of the Options dialog box.
ALT+F8 | Steps into the error handler or returns the error to the calling procedure. Does not affect the setting for error trapping on the General tab of the Options dialog box.

Use these key combinations in all Windows-based applications:

Press | To
F1 | Open Help.
ALT+F6 | Toggle between the last two active windows.
ALT+F4 | (Visual Basic) Close the active window; if all windows are closed, close Visual Basic.
CTRL+C or F3 | Copy the selection to the Clipboard.
CTRL+X | Cut the selection to the Clipboard.
CTRL+V | Paste the Clipboard selection.
CTRL+Z | Undo the last edit.
SHIFT+F10 | View shortcut menu.


Menu Editor Keys

Use these key combinations in the Menu Editor:

Press | To
TAB | Cycle forward through the boxes and buttons.
SHIFT+TAB | Cycle backward through the boxes and buttons.
ENTER | Cycle forward through menu items.
ALT+R | Move an item to a lower level in a hierarchical menu.
ALT+L | Move an item to a higher level in a hierarchical menu.
ALT+U | Move an item one line up.
ALT+B | Move an item one line down.

Use these key combinations when the Shortcut list box has the focus in the Menu Editor:

Press | To
F4 | Open or close the list.
ALT+DOWN ARROW | Open or close the list.
ALT+UP ARROW | Open or close the list.
END | Move to the last item in the list.
HOME | Move to the first item in the list.


Toolbox Keys

Use these key combinations in the Toolbox:

Press | To
ENTER | Place the selected control on the active form.
DOWN ARROW | Select the next tool down in the same column as the selected tool.
UP ARROW | Select the next tool up in the same column as the selected tool.
LEFT ARROW | Select the tool to the left of the selected tool.
RIGHT ARROW | Select the tool to the right of the selected tool.
TAB | Move through the Toolbox from left to right, one tool at a time.
SHIFT+TAB | Move up through the Toolbox from right to left, one tool at a time.
END | Select the last tool in the Toolbox.
HOME | Select the pointer tool.
ALT+F4 | Close the Toolbox.


Clear Structure Command (Microsoft Data Report Shortcut Menu)

Clears the structure of the Data Report designer. This action deletes all group header and footer sections as well as any controls on the designer. This action can be done by immediately pressing CTRL+Z, or selecting Undo Structure Change from the shortcut menu.


Preferences Command (VisData Utility Menu)

Displays a menu with commands that let you enter a login timeout value, load the last database you had open the next time you run VisData, and set a default query timeout for the current database.

Open Last Database on Startup

If selected, automatically loads the last database that was open in the last session when you run VisData.

Include System Tables

If selected, includes the system-created table in the Database window.

Query Timeout Value

Displays a dialog box that prompts you to set the default query timeout value for the current database that will be used for ODBC connections.

The timeout value is stored in Visdata.ini for future use.

Login Timeout Value Command

Displays a dialog box that prompts you to enter the login timeout value that will be used for ODBC connections. The timeout value is stored in the Registry for future use.


Project Menu

Add Form

Add MDI Form

Add Module

Add Class Module

Add User Control

Add Property Page

Add User Document

Add AddIn Class

Add DHTML Page

Add Data Environment

Add Data Report

Add WebClass

Add Microsoft UserConnection

More ActiveX Designers

Add File

Remove <Item>

References

Components

<Project Name> Properties


Retrieve Structure Command (Microsoft Data Report Shortcut Menu)

Synchronizes the structure of the Data Report designer with the structure of the Data Environment designer by creating group header and group footer sections on the Data Report designer. Except for the lowest Command object in the Data Environment designer, each Command object corresponds to a pair of group header/footer sections. The final Command object corresponds to the detail section of the Data Report designer.

Note There is an exception for grouping fields and grand total aggregate fields created by the Data Environment. For each set of grouping fields or grand total aggregate fields created, a group header/footer pair is created.

To use this command, set the DataSource property of the Data Report designer to the Data Environment designer. Then set the DataMember property to the topmost Command object of the Data Environment designer.

Invoking this command will clear the present structure and all controls of the Data Report designer. However, this can be undone by pressing CTRL+Z, or selecting Undo Structure Change from the shortcut menu.

Note The Data Environment allows you to create hierarchies of Command objects wherein a Command object has more than one child object — child Command objects parallel to each other. The Data Report designer, however, is not as flexible, and can't display more than one child object at a time. In such cases, when executing a Retrieve Structure command, the Data Report will display only the first of the child commands, and none below it. Thus you should avoid creating Command hierarchies with parallel children commands.


Utility Menu (VisData)

Query Builder

Data Form Designer

Global Replace

Attachments

Groups/Users

SYSTEM.MD?

Preferences


Visual Basic Design Time File Extensions

Visual Basic has a number of file extensions that are specific to design time. The currently used file extensions are:

Extension | Used For
.bas | Basic module
.cls | Class module
.ctl | User Control file
.ctx | User Control Binary file
.dca | Active Designer Cache
.dep | Setup Wizard dependency file
.dob | User Document form file
.dox | User Document binary form file
.dsr | Active Designer file
.dsx | Active Designer binary file
.frm | Form file
.frx | Binary Form file
.log | Log file for load errors
.oca | Control Typelib Cache
.pag | Property Page file
.pgx | Binary Property Page file
.res | Resource file
.swt | Visual Basic Set Up Wizard Template file
.tlb | Remote Automation Typelib files
.vbg | Visual Basic group project
.vbl | User Control Licensing file
.vbp | Visual Basic project
.vbr | Remote Automation Registration files
.vbw | Visual Basic Project workspace
.vbz | Wizard launch file
.wct | Webclass template file


Convert a database

The database file you selected isn't a replicable file. To make a replica of your database, you must first convert it to a Design Master. Converting your database increases the size of your file because new, hidden system fields and tables are added to your database.

Before you convert your database, remove the database password. Setting user permissions to access the database doesn't interfere with synchronization.


Designate the Design Master

If you want to change the design of your database while working on the Briefcase copy of the file, make the Briefcase copy the Design Master. It is important to remember, however, that no one will be able to make changes to the design of the replica remaining on the desktop.


Make a backup copy

The backup copy is to be used only in emergency cases. Any copy made from the backup copy of the database, or any replica made from a converted backup copy, will not be able to synchronize with the existing members of the replica set.


Visual Basic Run Time File Extensions

Extension | Used For
.dll | In-process ActiveX component
.exe | EXE file, Out-of-process ActiveX component
.ocx | ActiveX control


Templates

Templates are items that are saved in a specific directory structure in the \vb directory. They provide a way for you to re-use components and code, and to add them to projects.

When you choose the New Project command on the File menu, any projects found in the \template\projects directory appear in the New Project dialog box.

You can set the path for your template directory, or turn templates off, using the Environment tab of the Options dialog box.


Tools Directory

The Tools directory contains various tools, accessories, and sample applications that are useful to you, but are not installed on your hard disk during setup and are not supported by Visual Basic. You can find the Tools directory under Common\Tools\VB.


VisData As a Sample

VisData was written as a test and sample of the data access features in Visual Basic. In the Professional and Enterprise editions, source code can be found in the Samples\VisData directory or wherever you installed Visual Basic. This sample is a good source of code and forms for your applications. Some of the forms were designed to be placed in other applications with very little modification.

This topic contains information that helps you use the VisData sample code to save you time in your application development. Modifying the code requires some experimentation and persistence on your part to make it work.

The best way to add a form to your application is to:

  1. Copy the .frm and .frx files to the same location as your application.

  2. Add the form you want to your application.

  3. Set the MDIChild property to False if your application is not MDI.

  4. Open the Code window and search the code for the word, "Standalone", for special instructions about using the form in your application.

  5. Make the changes and additions noted in the special instructions.

  6. Press F8 to compile your application.

  7. Fix any errors that occur on compilation. You may be required to add global variables, other forms or some of your own functionality. Usually you can simply comment out the code that is causing the error and then decide if you need it or not.

There are a number of useful routines in the modVisData code module that you might want to include in your application to make using the forms easier. Some of routines are called from a form and will either need to be added, commented out, or rewritten by you in order to make the form operate correctly.

If you do not add the VisData.bas file to your application, there are a few global variables you will need that are used to share data among the forms. They are listed in the "global variables" section of VisData.bas.

You can add the following forms to your application:

  • frmAttachments A form that displays a list of attached tables allowing the user to add new attachments and re-attach existing attachments. It requires a frmNewAttach to work correctly.

  • frmDataControl is a form that dynamically loads a recordset and displays the records.

  • frmDataGrid A form that displays a recordset in a bound grid with additional features such as quick sorting by clicking the column header.

  • frmDynaSnap A form that loads a dynaset or snapshot type recordset and provides many features such as searching for a form, zooming in on a memo field or large text fields, and the use of a scrollbar to move around the recordset. To use the functionality of frmDynaSnap, you must also have a frmFindForm and a frmZoom.

  • frmGroupsUsers A dialog box that allows you to administer the permissions of the groups and users of the database. It requires a frmNewPassword and frmNewUserGroup.

  • frmQuery A form that is a fairly full-featured query builder. It requires a frmJoin. The frmQuery may not be easy to create from VisData but using it may save you time and effort.

  • frmSQL A form that allows a user to enter SQL statements and execute them or save them as queries in the database.

  • frmTableObj A form that displays a table type recordset with features specific to a table recordset such as searching and setting the current index. It requires a frmSeek.


Active Server Pages is not installed

Active Server Pages must be installed for this process to work correctly.


Visual Basic cannot load 'item' because it is not in the system registry. Remove it from the list of available Add-Ins?

Visual Basic couldn't load the add-in that you tried to select from the Available Add-Ins list in the Add-In Manager dialog box, because it was not registered properly or is no longer registered in the system registry.


'Item' could not be loaded. Remove it from the list of available Add-Ins?

Visual Basic couldn't load the add-in that you tried to select from the Available Add-Ins list in the Add-In Manager dialog box. Choose Yes to remove it from the list or choose No to leave it on the list. In either case, you won’t be able to load it.


A procedure of that name already exists

You tried to add a procedure but that procedure name already exists. This error has the following cause and solution:

  • In the Add Procedure dialog box, you tried to add a procedure that already exists in the project.

    Change the name of your procedure to avoid this problem.


An internal exception has occurred (2001)

An internal exception has occurred (9000)

An unknown and unexpected internal error occurred in the WebClass or WebClass run-time. You may need to re-install Visual Basic.


An unspecified error has occurred

An error has occurred that cannot be identified by Visual Basic.


The application description can't be more than 2000 characters long

You can't have an application description longer than 2000 characters. Delete some characters from the description. This error may occur if the .VBP file was modified in an editor other than Visual Basic.


Application was launched but it didn't register a class factory. Looking for object with CLSID: |1.

Application was launched but it didn't register a class factory. Looking for object with CLSID: <number>.

The application was opened but a class factory was not registered. This is a system error. If this problem persists, re-install Visual Basic or the affected application, and try again.


Application not found. Looking for object with CLSID: |1.

Application not found. Looking for object with CLSID: <number>.

Visual Basic could not find the application you are trying to use. This is a system error. If this problem persists, re-install Visual Basic or the affected application, and try again.


Failure in AsyncRead (Error 688)

A general error occurred during the AsyncRead method but no detailed information was returned.


PropertyName parameter conflicts with the PropertyName of an AsyncRead in progress (Error 689)

You tried to execute the AsyncRead method with the same PropertyName of an AsyncRead that is currently in progress. This error has the following cause:

  • For example, if you do the following in the UserControl event:

    AsyncRead "file:c:\winnt\winnt.bmp", vbAsyncTypePicture, "MyPicture"

    AsyncRead "file:c:\winnt\winnt.bmp", vbAsyncTypePicture, "MyPicture"

    You would get the error on the second AsyncRead method.


A time out occurred when attempting to access < >'s metadata

This error occurs when you manipulate Internet Information Server or Peer Web Server from the WebClass designer.

When you run a WebClass from the Visual Basic IDE, the WebClass designer associates a virtual root with the WebClass’s project directory. This message specifies that an error occurred when setting up that project directory.


A time out occurred when starting < >

This error occurs when you manipulate Internet Information Server or Peer Web Server from the WebClass designer.

IIS or PWS is in an unstable state. You should restart your system.


A time out occurred when stopping < >

This error occurs when you manipulate Internet Information Server or Peer Web Server from the WebClass designer.

IIS or PWS is in an unstable state. You should restart your system.


An error occurred while background loading module 'item'. Background load will now abort and the code for some modules may not be loaded. Saving these modules to their current file name will result in code loss. Please load a new project.

An error occurred while background loading your project. This error has the following causes and solutions:

  • While the source file was loading, it may have been changed or corrupted by an editor other than Visual Basic.

    Do not modify source code from a separate editor while it is being loaded into Visual Basic.

  • During the load of your project or projects, the drive containing the source files became unavailable.

    If your source files are on a network, verify that the network is still connected.

If this error persists, turn off the Background Project Load option from the Advanced tab of the Options dialog box.


The given bookmark was invalid (Error 527)

You tried to set a bookmark to an invalid string. This error has the following causes and solutions:

  • You set the Bookmark property to a string that wasn't saved after reading a record’s Bookmark property.

    Save the string before setting the Bookmark property to it.

  • You set the Bookmark property to a string that was saved after reading a record’s Bookmark property, but that record has since been deleted.

    Test that the record with the saved Bookmark property still exists before trying to move to it.


Line 'item1': Class 'item2' of control 'item3' was not a loaded control class.

The ASCII file contains a control class that Visual Basic doesn't recognize. Add the custom control with this class to your project.


Invalid command line argument 'item'

There is an invalid argument in the command line used to invoke Visual Basic. Search Help for a list of command line arguments.


You specified a command line argument that requires a project, but no project was specified

This error occurs if you specify a command-line argument that requires a project, but don't specify the project name (as in vb5 /make).


Error loading 'item'. A control could not be loaded due to load error. Continue?

This error message appears after another error has occurred. Once you've taken the appropriate action for that error, you will see this error message. To load the control anyway, choose Yes; to cancel the loading, choose No.


No compatible data source was found for this control.

Complex bound controls in previous versions of Visual Basic were bound to data sources with a mixture of DAO, RDO, and ODBC data sources. New complex bound Visual Basic controls, however, use ADO and OLEDB data sources, which are not internally compatible with the older data sources.

As a result, new complex bound controls (such as the Microsoft DataRepeater control or the Microsoft Hierarchical FlexGrid control) can be bound only to new data sources (ADO and OLEDB), and old complex bound controls can be bound only to older data sources. You can also use a Data Environment as a new OLEDB data source. If you attempt to bind a new complex bound control to an old data source or vice-versa, you get this error.

For a list of OLEDB-compatible components, click Components in the Project menu and look for "(OLEDB)" at the end of the name of the component.


Help Context ID must be a nonnegative number

You can't specify a negative number for the Help Context ID.


Procedure ID must be a negative number or zero

You are only allowed to enter Standard Procedure IDs in the Procedures Attributes dialog that are zero or a negative number.

Valid ranges are:

  • -999 to -500 for controls.

  • -2499 to -2000 for Visual Basic version 5.

  • -3899 to -2500 reserved for future expansion.

  • -3999 to -3900 for Dynamic HTML.

  • -5550 to -5500 for Dynamic HTML.

  • -5499 to -5000 for ActiveX accessibility.

  • Also allowed is a special range of 0x80010000 to 0x8001FFFF for control containers such as Visual Basic version 4.

The above values are ID numbers that are invoked through an internal Visual Basic interface called IDispatch. It is your choice as to what range of numbers to use in your application, although you should use a set of numbers that are contiguous and from the appropriate group. That is, if your application is an ActiveX control, you might choose a value (or values) from the range -5499 to –5000.


Error loading 'item'. An error was encountered loading a property. Continue?

You may have tried to load a form with controls whose names conflict with forms already in the project. For example, loading Form2 that contains a Form1 control triggers this error.


The declaration in the Compatible ActiveX Component was: 'item1' It has been changed to: 'item2'

Displays the difference between a declaration in the component you are attempting to compile, and the version-compatible component that is selected on the Components Tab of the Project Properties dialog box.

Click OK to return to the Incompatible Component dialog. You can then:

  • Click Accept to accept this version incompatible change.

  • Click Accept All to accept this and all subsequent version incompatible changes.

  • Click Edit to change the declaration back to what it was.

Note Accepting even one incompatible change will render this version of your component incompatible with all clients compiled using prior versions. It is strongly recommended that you change the file name and Project Name settings to avoid potentially serious program errors in those clients.


Line 'item1': Cannot create embedded object in 'item2'

An embedded object could not be created during the load of a Form, User Control, User Document, or Property Page from a text file. For example, if you had previously inserted a Microsoft Word Document onto the form, then removed Microsoft Word from your system you would get this error. This message is written to the error log file.


Line 'item1': Property 'item2' in 'item3' could not be loaded.

The ASCII file contains an unknown property. The property will be skipped when loading the form.


Visual Basic can't upgrade the custom controls to those provided in the 'item' library. Remove this library from the list of available upgrades?

Visual Basic was unable to convert one or more VBX controls to ActiveX controls. Choose Yes to remove the library reference from the list so that Visual Basic won't try to upgrade the specified VBX custom controls again, or choose No to leave the library in the list.


Cannot read HTML template (3004)

Cannot read HTML template (9007)

A system error occurred while trying to read the HTML template. Check that the file appears correctly in your directory listing and that it can be read from the disk.


Unable to access source document (Error 31039)

You attempted to create an embedded object, but the file specified by the SourceDoc property isn't a valid file.


Unable to activate object (Error 31027)

The object's source document can't be loaded, or the application that created the object isn't available.

This error occurs when you try to activate a linked object (set Action = 7) and the file specified in the SourceDoc property has been deleted, or no longer exists.

This error also occurs when you activate an object (set Action = 7), and the action specified by the Verb property isn't valid. Some applications that provide objects may support different verbs, depending on the state of the application. All the verbs supported by an application are listed in the ObjectVerbs property list. However, some verbs may not be valid for the application's current state.


Unexpected error; quitting

An unexpected error occurred, and Visual Basic was unable to continue. This may be a hardware problem or an effect of other software in your system.


Unable to close object (Error 31006)

The object can't be closed (Action = 10) in its current state.


Can't copy (Error 31009)

You tried to copy an object to the Clipboard (set Action = 4), but the object is corrupted or is no longer valid.


Class object cannot be determined. Looking for object CLSID: |1.

Class object cannot be determined. Looking for object CLSID: <number>.

Visual Basic could not find the class object you indicated. This is a system error. If this problem persists, re-install Visual Basic or the affected application, and try again.


Can't display system information

Visual Basic can't display system information when you choose System Info from the About Microsoft Visual Basic dialog box. Your system may not have enough memory or a required file may be corrupted or missing.


Unable to create embedded object (Error 31032)

The application that is creating the object can't create the object as specified in the SourceDoc property.

For example, this error occurs if you try to embed a spreadsheet object and SourceDoc specifies a spreadsheet that is too large to be loaded by the spreadsheet application.


Can't quit at this time

You can't quit Windows while Visual Basic is in run or break mode. You also can't quit Windows while a dialog box or message box is displayed.


Unable to fetch link source name (Error 31033)

The OLE container control can't determine the name of the source document for the object you want to create.

For example, when you attempt to paste a linked object from the Clipboard (set Action = 5), the OLE container control must determine the name of the source document based on the information provided by the Clipboard. If the OLE container control can't determine the name of the document to link to, this error occurs.


Can't find file 'item'

The specified file was not found. This error has the following cause and solution:

  • You tried to load a project but the specified file doesn't exist.

    You may have moved or deleted a file belonging to this project. Verify that the file is available on your drive.


Unable to create link (Error 31024)

The application that is creating the object can't create the linked object as specified in the SourceDoc and SourceItem properties.

For example, this error occurs if you try to link a spreadsheet object and SourceDoc specifies a spreadsheet that is too large to be loaded by the spreadsheet application.


Can't find or load the required file urlmon.dll (Error 690)

This error occurs if you try to call the AsyncRead method and don't have the urlmon.dll file. The Package and Deployment Wizard distributes the urlmon.dll file when you distribute your application.

Verify that this file is available in the Windows SYSTEM or SYSTEM32 directory.


User Documents are not allowed in Standard EXE and User Control project types

UserDocuments are not allowed in Standard EXE or ActiveX Control project types.


'Item' is in binary format and cannot be loaded into VB5

'Item' is in binary format and cannot be loaded into VB

Binary format files created with versions of Visual Basic prior to version 5.0 cannot be loaded without being converted. Only Visual Basic versions 2.0 and 3.0 support binary format file conversion. If you have access to a copy of Visual Basic 2.0 or 3.0, you can load the file and save it as text, then load the file into the newer version of Visual Basic.


Could not lock the database (Error 536)

The database file could not be locked. This error has the following causes and solutions:

  • You tried to lock a table while opening it, but the table can't be locked because it is currently in use.

    Wait a moment, and then try the operation again.

  • You tried to lock a record that is currently locked by another user.

    Wait for the other user to finish working with the record, and then try the operation again.


Can't open Clipboard (Error 31003)

You tried to copy (Action = 4) or paste (Action = 5) an object, but the Clipboard is not currently available. Find the application that has the Clipboard open, and close it.


Can't paste (Error 31007)

The Clipboard doesn't contain a valid OLE object.

This error also occurs when you copy an OLE object to the Clipboard and then try to paste the object back to the same OLE container control.

The PasteOK property returns True when an object can be pasted from the Clipboard.

Note that when you copy an OLE object to the Clipboard (set Action = 4) and then delete the object (set Action = 10), the object on the Clipboard is also deleted.


You can't put a Default or Cancel button on a User Control unless its DefaultCancel property is set (Error 399)

You can't set a control's Default or Cancel property to True on a User Control unless the User Control's DefaultCancel property is True. This error has the following causes and solutions:

  • You tried to set the Default or Cancel property of a control contained by a User Control to True, but the DefaultCancel property of the User Control was set to False.

    Set the DefaultCancel property of the User Control to True. This allows the User Control to participate in form wide Cancel/Default behavior.


Can't exit Windows while an OLE object is active for editing

You tried to exit Windows while an OLE object was active for editing. Deactivate the OLE object before quitting Windows.


Project 'item' can not be referenced because it is loaded into the same IDE as the referencing project

You attempted to reference an ActiveX EXE project in the same instance of Visual Basic as the referencing project, which is not allowed.


Can't run without setting a Startup Project first

You must set a startup project before running. This error has the following causes and solutions:

  • You had a startup project and two or more other projects in the project group that could be a startup project, but you removed the one that was a startup project.

    Make one of the projects a startup project by right clicking the project in the Project Explorer and selecting the Set as Start Up menu item.

  • This error also occurs in any other case where there is more than one project that could be a startup project after removing the current startup project.

    Make one of the projects a startup project by right clicking the project in the Project Explorer and selecting the Set as Start Up menu item.


Unable to set the version compatible component: 'item'

The version-compatible component could not be set. This error has the following cause and solution:

  • During the load of your project, the version-compatible component could not be set and the Version Compatibility option in the Components tab of the Project Properties dialog has been reset to No Compatibility.

    In order for Visual Basic to make sure you have a version-compatible project, you must select a version-compatible component in the Components tab of the Project Properties dialog.


You cannot set DisplayType while the control contains an object (Error 31040)

You tried to change the DisplayType property while the control contains an object.

Remove the object, then set the DisplayType property.


Can't set the project name at this time

The project name cannot be set.


An instance of 'item' cannot be created because it's designer window is open

You cannot create an instance of a form when its designer window is open.

Occurs if code running at design time tries to create an instance of a form (such as Form1.Show), and its designer is open.


Not enough room to allocate control array 'item' (Error 342)

There isn't enough memory to create all the elements of a control array. This error has the following causes and solutions:

  • An element in a control array with discontiguous index values for its elements, such as 0, 2, 4, was assigned too large an index value at design time.

    Change the Index property’s setting to a smaller value so that Visual Basic doesn't run out of memory.

  • You used the Load statement to add an element with too large an index value to a control array.

    Change the index value in your code to a smaller value.


Invalid control array index (Error 341)

You used an invalid index value to refer to an element in a control array. This error has the following cause and solution:

  • The index value you referred to in your code is a negative number.

    Change the index value to refer to one of the existing elements of the control array.


Control array element 'item' doesn't exist (Error 340)

You used an invalid index value to refer to an element in a control array. This error has the following cause and solution:

  • No control with the index value you referred to is part of the existing control array.

    Change the Index property setting for one of the existing elements to the value you referred to. Or use the Load statement to add a control to the array with an index equal to the value and then refer to the index value again.


Must specify index for object array (Error 344)

A control that isn't part of a control array is referred to as if it were. This error has the following causes and solutions:

  • You referred to an index value for a control that isn't a part of a control array.

    Remove the reference to the index value.

  • You tried to add a control at run time with the Load statement but no control array with that Name property exists.

    Create the control you are referring to as a control array at design time.


Object not an array (Error 343)

A control that isn't part of a control array is referred to as if it were. This error has the following cause and solution:

  • You tried to refer to an index value for a control that isn't part of an array (for example, Command1(3).Caption and Command1.Text).

    Delete the reference to the index value, or redefine the control as an element in a control array.


Reached limit: cannot create any more controls for this form (Error 345)

Reached limit: cannot create any more controls on this form (Error 345)

No more than 255 individual controls are allowed for each form. This error has the following cause and solution:

  • At design time you tried to add a control to a form that resulted in a total of 256 individual controls for the form (with the form itself counting as one control).

    Delete one or more controls from the form or redefine one or more of your controls as part of a control array.


Can't remove control or reference; in use

The ActiveX control or reference that you tried to remove is being used by one of the forms in the project. First delete the control or referenced object from the form and then deselect it from the list.


The class name of the newly upgraded 'item1' objects is 'item2'. Since this is different from their previous name of 'item3', you must change any declarations of this object that you have in code.

The class name of the specified object you upgraded has changed. You must change any declarations of the specified object in your code to refer to the new class name.


Low on memory! Can't bring up the dialog! (Error 32752)

This error occurs when sufficient memory isn't available. Check for sufficient system memory as well as available system resources.


Cancel was selected (Error 32755)

This error occurs when the CancelError property is set to True and the user clicks the Cancel button in the dialog box. Use this error to execute different code when the Cancel button was selected. For example, in a File Open dialog box, you might respond to this error by exiting the current procedure instead of attempting to open a file.


The PrintDlg function failed when it attempted to create an information context (Error 28661)

The amount of available system resources may be too low.


A default printer does not exist (Error 28663)

Check the system for installed printers using the Printers collection. If there are printers installed, set the Printer object to one of the printers in the Printers collection to define a default printer.


The data in the DEVMODE and DEVNAMES data structures describes two different printers (Error 28662)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


The FileName buffer is too small to store the selected file name(s) (Error 20476)

This error occurs when the MaxFileSize property setting is too small to allocate enough space in memory for the selected file name(s). Increase the setting of the MaxFileSize property.


The common dialog function failed to find a specified string (Error 32761)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


The printer device driver failed to initialization a DEVMODE data structure (Error 28666)

The printer device driver failed to initialize a DEVMODE data structure (Error 28666)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


Help call fail. Check Help properties (Error 32751)

Check to make sure the HelpContextID and HelpFile properties are set to proper values for the Help file used by the application.


The common dialog function failed during initialization (Error 32765)

This error often occurs when sufficient memory isn't available.


Invalid filename (Error 20477)

The specified filename may not exist or may contain illegal characters.


The PrintDlg function failed to load the specified printer's device driver (Error 28667)

This error could be caused by a defective printer driver or a corruption in system memory.

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


The common dialog function failed to load a specified resource (Error 32760)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


The common dialog function failed to load a specified string (Error 32762)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


The common dialog function failed to lock a specified resource (Error 32759)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


The common dialog function was unable to allocate memory for internal data structures (Error 32758)

This error is caused by insufficient memory.


The common dialog function was unable to lock the memory associated with a handle (Error 32757)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


No fonts exist (Error 24574)

Before displaying the Choose Font dialog box, you must set one of the following flags:

  • ScreenFonts

  • PrinterFonts

  • Both


The ENABLETEMPLATE flag was set in the Flags member of a common dialog data structure but the application failed to provide a corresponding instance handle (Error 32763)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


No printer device drivers were found (Error 28664)

The system may not have printer drivers installed or the drivers may be missing.


The ENABLETEMPLATE flag was set in the Flags member of a common dialog data structure but the application failed to provide a corresponding template (32764)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


The common dialog function failed to parse the strings in the [devices] section of the file WIN.INI (Error 28669)

This error occurs when the information in Win.ini can't be read by the CommonDialog control. For example, the Win.ini entry may contain the string "LDT1" instead of "LPT1" to identify a port.


The PrintDlg function failed during initialization (Error 28665)

This error is usually caused by insufficient memory.


The [devices] section of the file WIN.INI did not contain an entry for the requested printer (Error 28660)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


The PD_RETURNDEFAULT flag was set in the Flags member of the PRINTDLG data structure but either the hDevMode or hDevNames field were nonzero (Error 28668)

The PD_RETURNDEFAULT flag was set in the Flags member of the PRINTDLG data structure but either the hDevMode or hDevNames field was nonzero (Error 28668)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


An attempt to subclass a ListBox failed due to insufficient memory (Error 20478)

The CommonDialog control uses specialized functions in the operating system to present the dialog boxes it displays. When this error occurs, the problem exists at the operating system level and shouldn't appear as the result of Visual Basic code that uses the control.


Some project properties and/or items have to be changed in this type of project. Check Help for details. Are you sure you want to change the project type?

You are trying to change the Project Type in the Project Properties dialog to a type that requires different settings for some properties or items. These properties or items need to be changed in order to make the project consistent with its new type. Also, the public property of some items in the project, such as User Controls and Class Modules, may be modified as well, since some Project Types do not allow public items.


Name 'item' conflicts with existing module, project, or object library

This error has the following causes:

  • You loaded a Form, User Control , User Document, or Property Page that contains objects with conflicting names.

    This can occur if the file was edited outside of Visual Basic.

  • You renamed a form to the same name as the project, another form, or a module.

  • You renamed the project to the same name as a form or module.


Line 'item1': Class name too long; truncated to 'item2'.

The ASCII file contains a class name longer than 40 characters. The class will be loaded with the name truncated to 40 characters.


Class not found

Visual Basic could not find the class that you specified. This is a system error. If this problem persists, re-install Visual Basic or the affected application, and try again.


Class is not registered. Looking for object with CLSID: |1.

Class is not registered. Looking for object with CLSID: <number>.

The class was not registered. This is a system error. If this problem persists, re-install Visual Basic and try again.


Invalid class string. Looking for object with ProgID.

The class string you are trying to use is invalid. This is a system error. If this problem persists, re-install Visual Basic or the affected application, and try again.


Client Site not available (Error 398)

The User Control or User Document cannot retrieve information from its container. This error has the following cause and solution:

  • The User Control or User Document tried to get information from the container's Ambient properties or its Extender object before the container attached to it. This can happen if you try to access these objects before your InitProperties or ReadProperties events get fired, such as in the Initialize event, or for some containers in the Terminate event.

    To solve this problem, wait for an InitProperties or ReadProperties event before accessing these objects.


Can't empty Clipboard (Error 520)

The Clipboard was opened but could not be emptied. This error has the following cause and solution:

  • Another application is using the Clipboard and will not release it to your application.

    Set an error trap for this situation in your code and provide a message box with Retry and Cancel buttons to allow the user to try again after a short pause.


Can't open Clipboard (Error 521)

The Clipboard has already been opened by another application. This error has the following cause and solution:

  • Another application is using the Clipboard and will not release it to your application.

    Set an error trap for this situation in your code and provide a message box with Retry and Cancel buttons to allow the user to try again after a short pause.


Invalid Clipboard format (Error 460)

The specified Clipboard format is incompatible with the method being executed. This error has the following causes and solutions:

  • You tried to use the clipboard's GetText or SetText method with a Clipboard format other than vbCFText or vbCFLink.

    Remove the invalid format and specify one of the two valid formats.

  • You tried to use the clipboard's GetData or SetData method with a Clipboard format other than vbCFBitmap, vbCFDIB, or vbCFMetafile.

    Remove the invalid format and specify one of the three valid graphics formats.

  • You tried to use the DataObject’s GetData or SetData method with a clipboard format in the range reserved by Windows for registered formats (&HC000-&HFFFF), but that clipboard format has not been registered with Windows.

    Use a clipboard format recognized by Visual Basic, or a clipboard format which has been registered with Windows through the Windows RegisterClipboardFormat API function.


Specified format doesn't match format of data (Error 461)

The specified Clipboard format is incompatible with the method being executed. This error has the following causes and solutions:

  • You tried to use the clipboard's GetText or SetText method with a Clipboard format other than vbCFText or vbCFLink.

    Before using these methods, use the GetFormat method to test if the current contents of the Clipboard matches the specified format.

  • You tried to use the clipboard's GetData or SetData method with a Clipboard format other than vbCFBitmap, vbCFDIB, or vbCFMetafile.

    Before using these methods, use the GetFormat method to test if the current contents of the Clipboard matches the specified graphics format.

  • You tried to use the DataObject’s GetData or SetData method with a clipboard format inappropriate to the data, for instance, using vbCFDIB with a metafile.

    Before using these methods, use the GetFormat method to test if the current contents of the DataObject matches the specified data format.


Closing angle bracket '>' not found (3007)

Closing angle bracket '>' not found (9011)

Every open angle bracket must be matched with a closing angle bracket.


Could not access the desired Column (Error 537)

The control could not access the desired column. This error has the following cause and solution:

  • The bound control has attempted to access data from a column that is not in the result set.

    This error occurs when a control incorrectly accesses data from a Data control. Contact the control vendor for more information.


The compatible server file 'item' is in use by another project

Multiple projects loaded in Visual Basic can't use the same compatible server at the same time. For example, if Project1's compatible server is set to Test.DLL and you try to add Project2, which also has its compatible server set to Test.DLL, you will get this error. This is not allowed.


Compile Error in File 'item1' : 'item2'

There was an error compiling the specified source file during a command line build. Check the file and correct the error.


Compile Error in File 'item1', Line 'item2' : 'item3'

There was an error compiling the source file at the specified line number during a command line build. Check the file and correct the error.


Conflicting attributes were found in 'item'. The defaults will be used

Some of the attribute statements in a Form, User Control, Property Page, User Document, or Class Module conflict with the required settings for their type. For example, forms must always have the VB_PredeclaredId attribute equal to True.

This error can occur if the file was modified by an editor other than Visual Basic.


Conflicting names were found in 'item1'. The name 'item2' will be used

The name of a form occurs twice in the source file for a Form, User Control, Property Page, or User Document. The names are different ,so the specified name will be used. This error can occur if the file was modified by an editor other than Visual Basic.


Control 'item' not found (Error 423)

Access to an invalid VBControl (or ControlTemplate) object. The control this object refers to may no longer exist or may be in an invalid state.


Item' is a control name

A control already has this name. A form can't have the same name as a control in the same project.


'item1' is referenced by 'item2' project and cannot be updated.

You are trying to modify the specified control but it is shared between two or more projects. This error has the following cause and solution:

  • You have two or more projects in the same project group that use the same control and are trying to modify the control.

    You cannot update a control that is referenced by two or more projects.


Corresponding close tag not found (3006)

Corresponding close tag not found (9010)

Every open tag must be matched with a close tag.


Could not create reference: 'item'

There was an error establishing a reference while loading the file, so the reference was not added.


Line 'item1': Property 'item2' in 'item3' could not be set.

Visual Basic can't set the property of the specified control as indicated by the form description in the ASCII file.


'item' could not be loaded

In addition to other causes, such as if the file is corrupt, or you don’t have read permission to the file, this error occurs when you attempt to add a file containing an existing Form, MDIForm, UserControl, PropertyPage, or UserDocument to a project in which you have selected the Unattended Execution option (accessed from the General tab of the Project Properties dialog box).

A project marked for unattended execution cannot support any form of user interaction, so the module types it can contain are severely restricted.

For more information, see "Scalability and Multithreading," in "Building Code Components" in Creating ActiveX Components.


Line 'item1': Cannot load control 'item2'; name already in use.

The control named in the ASCII text file couldn't be loaded because its name is already in use elsewhere in the application.


Line 'item1': Control name too long; truncated to 'item2'.

The ASCII file contains a control name longer than 40 characters. The control will be loaded with the name truncated to 40 characters.


Line 'item1': Cannot load control 'item2'; license not found

An ActiveX control could not be created during the load of a Form, User Control, User Document, or Property Page from a text file, due to the license file not being found. You must have a license to use this control. Check with the control's vendor for more information. This message is written to the error log file.


Could not find Data Access Library. Cannot Create reference.

Visual Basic tried to create a reference to the Microsoft DAO Object Library through the Data control, but failed. Verify that all system registry keys are valid and, if they are not, run Visual Basic setup again.


'item' (Error 524)

The specified error has occurred in the Automation object currently running.


Data Access Error (Error 525)

A Data Access Object error has occurred that was not specifically trapped.


You need to fill in the DatabaseName and/or Connect properties of the Data Control to complete this operation

Before you can see a list of possible settings for the RecordSource property of the Data control, you must first set at least the DatabaseName property (for Access database .MDB files), and possibly the Connect property (for all non-Access database files).


You need to fill in the RecordSource property of the Data control to get a list of field names.

Before you can see a list of possible settings for the DataField property of a bound control, you must first set the RecordSource property of the Data control.


Requested data was not supplied to the DataObject during the OLESetData event (Error 676)

The requested data was not supplied to the DataObject during the OLESetData event. This error has the following causes:

  • The programmer specified a data format but did not specify the data itself during the OLEStartDrag event and didn't handle the OLESetData event.

  • The programmer specified a data format but did not specify the data itself during the OLEStartDrag event and didn't provide the actual data during the OLESetData event (or else provided the data for the wrong format).


DataObject formats list may not be cleared or expanded outside of the OLEStartDrag event (Error 672)

The DataObject formats list may not be cleared or expanded outside of the OLEStartDrag event. This error has the following cause and solution:

  • You tried to clear or expand the DataObject formats list with the SetData method in an event other than the OLEStartDrag event. This is not supported. For example, you may have placed the code Data.SetData [value], format, where format was not already supported by that data object, in some event other than the OLEStartDrag event.

    When expanding or clearing the DataObject formats list, make sure that you do it in the OLEStartDrag event.


Data value named 'item' not found (Error 327)

The specified data value could not be found. This error has the following cause and solution:

  • In the ReadProperties event of a UserDocument or UserControl, you passed in the name of a property to PropBag.ReadProperty that doesn't exist and you didn't specify a default value.

    To avoid this error, verify that the specified property exists or use the optional default parameter for the PropBag.ReadProperty.


The data binding DLL, 'item', could not be loaded. (Error 523)

Unable to load specified data binding DLL. Make sure the DLL is installed on your system.


User pressed Escape key during DDE operation (Error 287)

You pressed the ESC key while waiting for a DDE operation to be completed. This error has the following cause and solution:

  • The other application in the DDE conversation is taking too long to respond.

    Try setting the LinkTimeout property to a lower value.


Invalid DDE Link format (Error 294)

The other application in a DDE conversation passed data in an invalid format. This error has the following cause and solution:

  • The application passed data in the vbCFLink Clipboard format but it isn't valid link data.

    Fix the data in the other application so that it conforms to the vbCFLink Clipboard format.


Destination is busy (Error 288)

The other application in the DDE conversation can't perform a DDE operation. This error has the following cause and solution:

  • The other application is busy responding to other Windows events.

    Try calling the DoEvents function and attempt the DDE operation again.


System DLL 'dll' could not be loaded (Error 298)

A .DLL file provided by the operating system; for example, Ddeml.dll, Version.dll, or Winspool.drv couldn't be found. This error has the following causes and solutions:

  • The file isn't on the proper path.

    Ensure the DLL is on the Windows System path.

  • The DLL is corrupted or was deleted.

    Reload the DLL.

  • There isn't enough memory or swap space.

    Try to free up some memory by closing other applications.


Can't set LinkMode; invalid LinkTopic (Error 297)

You tried and failed to set the LinkMode property of a control. This error has the following cause and solution:

  • You did not specify a LinkTopic property for the control.

    First specify a valid LinkTopic property.


Message queue filled; DDE message lost (Error 295)

Visual Basic can't keep up with the number of DDE operations attempted. This error has the following causes and solutions:

  • Too many DDE conversations are running.

    Try terminating one or more DDE conversations.

  • Too much code in event procedures is executing because of incoming DDE data.

    Reduce the amount of code being called as a result of DDE changes, or try calling the DoEvents function.


Foreign application won't perform DDE method or operation (Error 285)

An application refused to perform the DDE method or operation you attempted. This error has the following causes and solutions:

  • You supplied data or commands that the other application did not recognize.

    Check the application's documentation to see what data or commands it recognizes.

  • The LinkItem property isn't set to an item that the other application recognizes as valid for the topic of the conversation.

    Check the application's documentation to see what items it recognizes.


No foreign application responded to a DDE initiate (Error 282)

Visual Basic could not find an application and topic corresponding to the application name and topic in the LinkTopic property. This error has the following causes and solutions:

  • The application specified in LinkTopic isn't running.

    Ensure the specified application is running.

  • The application is running, but doesn't recognize the topic of the link.

    Ensure the specified application actually has a topic with the name specified in LinkTopic.


PasteLink already performed on this control (Error 296)

You have already performed a Paste Link on this control. This error has the following cause and solution:

  • You are trying to paste a new link while a prior link is still in effect.

    To paste a new link, first set the LinkMode property of this control to 0 (None), and then use the Paste Link command.


DDE Method invoked with no channel open (Error 293)

A DDE method (LinkExecute, LinkPoke, LinkRequest, or LinkSend) was performed on a control that isn't involved in a valid DDE conversation. This error has the following causes and solutions:

  • Changing the LinkTopic property terminates an existing DDE conversation, but doesn't automatically establish a new conversation.

    After changing the LinkTopic property for a control, you must set the LinkMode property of the form to 1 (Automatic) or 2 (Manual) before executing a DDE method on this control.

  • You executed a DDE method on a control with LinkMode set to 0 (None).

    Set LinkMode to 1 (Automatic) or 2 (Manual) and try again.


Timeout while waiting for DDE response (Error 286)

The other application in a DDE conversation did not respond within the time specified by the LinkTimeout property. This error has the following causes and solutions:

  • The other application isn't responding because it is waiting for a response from the user.

    Switch to that application, and close the dialog box or take an action corresponding to the message it displays.

  • The LinkTimeout property is set to a value that is too low.

    Try increasing the value.

  • The other application is too busy to respond to DDE messages.

    Try calling the DoEvents function before performing this DDE operation.


Data in wrong format (Error 290)

An application in a DDE conversation supplied data in an unexpected format. It may not be performing DDE correctly. This error has the following causes and solutions:

  • The application is supplying data in a format that Visual Basic doesn't recognize.

    Try initiating the conversation with a different topic.

  • The application is supplying text data to a PictureBox or picture data to a TextBox.

    Try initiating the conversation with a different control.


Changing the Connection object information may make one or more of your Command objects invalid. Are you sure you wish to continue?

Changing the source of a Connection object, for example to a different server or data source, may cause associated Command objects to become invalid. This could occur because the database object or SQL command upon which the Command object is based does not exist in the new source.


To retrieve field information for this Command, the Command must be executed. This may add to or modify data in the database. Are you sure you wish to continue?

While attempting to execute a Command object which is based on a stored procedure, the Field and Parameter objects required cannot be retrieved. Note that if the stored procedure performs an insert or delete, executing the Command object will add or delete data from the database. If the stored procedure performs a SELECT, you may execute the Command object without any side effects.


This object will be permanently deleted. Are you sure you wish to continue?

Confirms that you want to permanently delete the selected Connection or Command object from your Data Environment.


At least one field must be used for grouping.

Group Command Object is selected on the Grouping tab of the Command Properties dialog box, but no Field objects are listed in the Fields Used for Grouping list box. When grouping a Command object, at least one Field object must be in the Fields Used for Grouping box.


Invalid aggregate name. Check for illegal characters or object same name.

An invalid name, such as a name with spaces, or a pre-existing Field object's name was entered in the Name box on the Aggregates tab of the Command Properties dialog box. A valid aggregate name can include alphanumeric characters, starting with an alpha character.


Invalid Cache size value.

An invalid value was entered in the Cache Size box on the Advanced tab of the Command Properties dialog box.


Invalid Command Timeout value.

An invalid value was entered in the Command Timeout box on the Advanced tab of the Command Properties dialog box.


Invalid name for grouping command. Check for illegal characters or object with same name.

An invalid name, such as a name with spaces, or a pre-existing Command or Connection object's name is entered in the Grouping Command Name box on the Grouping tab of the Command Properties dialog box. A valid aggregate name can include alphanumeric characters, starting with an alpha character.


Invalid object name. Check for illegal characters or object with same name.

An invalid name, such as a name with spaces, or a pre-existing Command or Connection object's name is entered in the Name box on the General tab of a Connection or Command object's Properties dialog box. A valid aggregate name can include alphanumeric characters, starting with an alpha character.


Invalid name for grand total aggregate. Check for illegal characters or object with same name.

An invalid name, such as a name with spaces, or a pre-existing grand total aggregate or grand total command's name is entered in the Name box within the Grand Total Command frame on the Aggregates tab of the Command Properties dialog box. A valid aggregate name can include alphanumeric characters, starting with an alpha character.


Denali BrowserType object is not installed correctly (3002)

Active Server Pages BrowserType object is not installed correctly (9005)

Active Server Pages BrowserType object is not installed correctly.

For information on how to install it, see "The Object model for IIS Applications" in "Building Internet Applications" in the Component Tools Guide.


This Command object contains child Command objects. Do you wish to delete these child Command objects as well as the parent Command object?

A parent Command object is being deleted. Click Yes to delete the selected Command object and all associated child Command objects. Click No to delete only the selected Command object. Click Cancel to abort the delete.


Connection is either not specified or could not be established.

The Command object does not have an associated Connection object or the specified connection could not be opened. The connection properties may be incorrect or the server may not be available. You must associate the current Command object with a Connection object, using the Connection box on the General tab of the Command Properties dialog box, before the Database Name list can be populated.


This Connection object has one or more associated Command objects. Do you wish to delete these Command objects as well as the Connection object?

The Connection object being deleted has one or more associated Command objects. Click Yes to delete the selected Connection object and all associated Command objects. Click No to delete only the selected Connection object, in which case its associated Command objects become invalid. Click Cancel to abort the delete.


Operation Canceled.

When a Connection object was being executed, a provider-specific window was displayed from which you canceled the operation.


Refresh will lose all user-defined information in fields or parameters associated with this Command object. Are you sure you wish to continue?

Refreshing a Command object rebuilds all field and parameter information. Any user-defined property settings are lost during the refresh. For Fields, the Control and Caption properties are reset to their defaults. For Parameters, the Name, Direction, DataType, Precision, Scale, Size, and HostDataType properties are reset to their defaults. Once the user-defined property settings are discarded, they cannot be retrieved.


At least one relation definition must be defined.

Relate to a Parent Command Object is selected and no Relation Definition is defined in the list box on the Relation tab of the Command Properties dialog box, or no parent Command object is selected.

When creating a hierarchy of Command objects, you must select a parent Command object and create at least one Relation Definition.


MDI/SDI option change will take effect the next time the Development Environment is started

The SDI Development Environment option on the Advanced tab in the Options dialog box doesn't take effect until you restart Visual Basic.


Dialog already in use (Error 31029)

Only one OLE dialog box (either Insert Object or Paste Special) can be displayed at a time.


Control must be same type as rest of array

You attempted to give a control the same Name property setting as an existing control array of a different type. All controls in a control array must be the same type.


One or more files in the project have changed. Do you wish to save the changes now?

One of the property settings or a code statement has changed for one or more of the files in the project and the changes have not yet been saved. This is your last chance to save the changes before loading another project.


Display more load errors?

There were errors loading your .VBP project file. Select Yes to display more load errors. Choose No to close.


No creatable public class module detected. Press F1 for more information

ActiveX EXE, ActiveX DLL, and ActiveX Control project types require that you have a least one public creatable class module.


DLL for class not found. Looking for object with CLSID: |1.

DLL for class not found. Looking for object with CLSID: <number>.

Visual Basic could not find the DLL for the class that you specified. This is a system error. If this problem persists, re-install Visual Basic or the affected application, and try again.


Unattended Project Cannot be visible at runtime

A project marked for Unattended Execution cannot have any visible user interface elements. This message has the following cause and solution:

  • The Unattended flag was manually set in the .VBP file and the project was compiled or executed in the design environment.

    To solve this problem, remove all forms from the project or change the Startup Object in the Project Properties dialog box to (none) or Sub Main.


Array already has control at index 'item'

Possible causes:

  • You tried to change the index value to a number that is already used by this control array. To determine which indices have already been assigned, select the Index property in the Properties window for each control array element.

  • You tried to change the Name property of a control in an array to the name of a control array already using this index value.


This Procedure ID is already assigned to member 'item'. Assigning it to this member will void the previous setting.

You tried to set the Procedure ID of an item to the same value as another item. This message occurs in the Procedure Attributes dialog box.

Procedure IDs must be unique within a module. Click OK to apply the Procedure ID to the current item or Cancel to void the change.


'item' will not be loaded. Name is already in use

Form names must be unique for each project. This error has the following cause and solution:

  • You tried to load a form with the same name as a form that is already in the project.

    To avoid this error, change the Name property of the duplicate form to another name.


Duplicate procedure name

You have defined (or are attempting to define) more than one version of a procedure with the same name. Rename one of the procedures. Ensure that duplicate Declare statements for the same procedure have the same Alias clause.


Disk full: 'item'

This error has the following cause and solution:

  • There isn't enough room on the disk to create required files.

    Move any unused files to another disk or delete unnecessary files.


Device unavailable: 'item'

This error has the following cause and solution:

  • The specified device is not online or doesn't exist.

    Check power to the device and any cables connecting your computer to the device. If you are trying to access a printer over a network, make sure there is a logical connection between your computer and the printer, for example, a connection associating LPT1 with the network printer ID.


File already exists: 'item'

This error has the following cause and solution:

  • You used the Save As command to save a currently loaded project, but the project name already exists.

    Use a different project name if you don't want to replace the other project.


File not found: 'item'

The file was not found where specified. This error has the following cause and solution:

  • In the development environment, this error occurs if you attempt to open a project or load a text file that doesn't exist.

    Check the spelling of the project name or file name and the path specification.


Device I/O error: 'item'

External devices are sometimes subject to unanticipated errors. This error has the following cause and solution:

  • An input or output error occurred while your program was the specified device.

    Make sure the device is operating properly, and then retry the operation.


Error accessing registry

A system error occurred while attempting to access your system's internal registry file.


Error automating < >

This error occurs when you manipulate Internet Information Server or Peer Web Server from the WebClass designer.

An error occurred when trying to assign a virtual root to your project directory. Restart your system and run the project again.


Error in the DLL. Looking for object with CLSID: |1.

Error in the DLL. Looking for object with CLSID: <number>.

You have received a system error. If this problem persists, re-install Visual Basic or the affected application, and try again.


Error loading from file (Error 31037)

An error occurred while attempting to read the specified file (set Action = 12). Possible causes:

  • The FileNumber property is invalid.

  • The file wasn't opened in Binary mode.

  • The file wasn't saved properly (set Action = 11).

  • The file is corrupted.

  • The file position isn't located at the beginning of a valid OLE object.


Error loading WebClass state

An error occurred while attempting to load the WebClass state.

If this occurs at run-time, then your .Dll is probably corrupted and you should recopy or rebuild/recopy. If it occurs at design time, then your project files are probably corrupted. If you can’t manually rebuild your project, contact Microsoft Technical Support, as in certain cases some of the project may be salvaged. (See the Technical Support command on the Help menu.)


Errors during load. Refer to 'item' for details

Something unexpected appeared in the ASCII form file. Visual Basic created a log file to provide more detail about the errors. You should examine the log file to determine the severity of the problem. Sometimes you can safely ignore the errors (for example, Version number missing or invalid...). Other times, however, the errors could cause the form not to run as expected (for example, Class MyClass in control  MyControl was not a loaded control class).


Error saving to file (Error 31036)

Visual Basic can't write the object to the specified file (set Action = 11, or 18). Possible causes:

  • The FileNumber property is invalid.

  • The specified file wasn't opened in Binary mode.

  • There isn't enough disk space.


Errors occurred during load

There were problems loading a form at design time.

This error can occur when there is an invalid property value in an .FRM file, however, Visual Basic will continue loading the form.


An EXE or DLL name can not be specified for /Make if building a project group.

You tried to override the default file name of the DLL or EXE being built during a command-line build of a project group file. Project groups may have multiple output files so this is not allowed.

Use the /Outdir command line argument to specify the output directory for a project group.


Project too large too make into an EXE

Project too large to make into an .EXE

This project exceeded the absolute size for an .EXE file that the operating system can handle. You must reduce the size of the project or break it up into pieces.


Version numbers must be in the range 0 to 9999

You tried to assign a negative number, a non-numeric character, or a number greater than 9999, as the Major, Minor, or Revision component of the Version number for a project in the Make tab of the Project Properties dialog box. Use a number between 0 and 9999 inclusive.


Expected at least one argument (Error 673)

The method expected at least one argument. This error has the following cause and solution:

  • The user tried to call the DataObject.SetData method without any parameters.

    Although both parameters are optional, you must call the DataObject.SetData method with at least one parameter.


The file 'item' is already open

This error has the following causes and solution:

  • You tried to load two project files with the same name in the same project group.

  • You tried to save two projects with the same name in the same project group.

Project files cannot have duplicate names in the same project group. You must change the name of one of the project files.


Can't use character device names in file names: 'item' (Error 320)

From within Visual Basic, you can't give a file the same name as a character device driver. This error has the following cause and solution:

  • You tried to use a filename such as AUX, CON, COM1, COM2, LPT1, LPT2, LPT3, LPT4, or NUL.

    Give the file another name.


Invalid file format (Error 321)

A Visual Basic form file is damaged. This error has the following causes and solutions:

  • The form has a damaged ActiveX control.

    Try replacing the ActiveX control on the form.

  • The number of properties in the current version of the ActiveX control don't match the number expected.

    Try replacing the ActiveX control with an earlier or later version.


'Item' is a Read-Only file

You asked to save to a file that is read-only. Read-only files are shown in the Project Explorer as [image]. You can't save to read-only files. Use Save As instead.


File is read-only

The file is read-only and cannot be changed. This error has the following cause and solution:

  • You are trying to edit a form whose file attribute is set to read-only. You cannot modify form files that are read-only.

    You must change the file attribute to read-write in order to modify the form.


<file name> is not in the project directory

This error occurs if you enter a template filename that is not in the project directory. HTML template files must be in the project directory.


<file name> is a Read-Only file

You attempted to save a template file that is marked read-only. You will be prompted to enter new file name.


Line 'item1': The file 'item2' could not be loaded.

Syntax errors are preventing Visual Basic from parsing and loading a file, or form name conflicts prevent loading of an ASCII form. The form won't be loaded and the form name won't be displayed in the Project Explorer.

Make sure that the file causing this error is a valid ASCII form in the correct format and that no conflicts exist among the different forms in the project. The correct ASCII form format is:

   VERSION 6.00
   Begin VB.Form <formname>

      Form Properties
      Begin VB.<controltype> <controlname>
         prop = value
         prop = value
         [...]

         Control Properties
         Begin VB.<control type> <control name>
            prop = value
            [...]
            Begin ...
               [...]
            End
         End
      End
   End
   ATTRIBUTE = "<form name>"
   [...]


The file 'item' was recognized as a Visual Basic file, but the header was corrupt and the file can't be loaded

There was an error in the header of the specified file and it cannot be loaded. This error has the following cause and solution:

  • Visual Basic could not load the specified file because the header was corrupt. The header contains lines of code specific to Visual Basic and one or more of the header lines were missing or corrupt.

    Install a backup copy of the specified file or modify the file using a text editor to match the header of an existing file.

Warning Modifying a Visual Basic file in an editor other than Visual Basic may corrupt the file. This is only recommended for advanced users.


Line 'item1': The Form or MDIForm name 'item2' is already in use; cannot load this form.

The ASCII file contains a form with a name that is already being used elsewhere in the application. The form isn't loaded.


Form not found (Error 424)

The form was not found. This error has the following cause and solution:

  • You tried to add a form to the Forms collection using the Add method, but there is no form class of that name. For example, Forms.Add "Form2", where Form2 doesn't exist.

    Make sure that the class name is available to your project.


Can't print form image to this type of printer (Error 486)

The form cannot print to this type of printer. This error has the following cause:

  • Your printer doesn't support RASTER capabilities or failed a StartPage during the printing of a form.


The file, 'item', is marked as a version not supported by the current version of Visual Basic, and won't be loaded

You tried to load a form from Visual Basic version 1.0 or a form from a version greater than this version of Visual Basic. This is not supported.


Can't create AutoRedraw image (Error 480)

Visual Basic can't create a persistent bitmap for automatic redraw of the form or picture. This error has the following cause and solution:

  • There isn't enough available memory for the AutoRedraw property to be set to True.

    Set the AutoRedraw property to False and perform your own redraw in the Paint event procedure or make the PictureBox control or Form object smaller and try the operation again with AutoRedraw set to True.


Printer driver does not support specified property (Error 483)

The printer driver for the printer in use doesn't support this property of the Printer object. This error has the following cause and solution:

  • The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may or may not produce an error.

    For more information, see the manufacturer's documentation for the specific driver.


Problem getting printer information from the system. Make sure the printer is set up correctly. (Error 484)

There is some problem that prevents getting printer information from the system. This error has the following causes and solutions:

  • You don't have a printer installed from the Windows Control Panel.

    Open the Control Panel, double-click the Printers icon, and choose Add Printer to install a printer.

  • Your printer isn't online.

    Physically switch the printer online.

  • Your printer is jammed or out of paper.

    Physically correct the problem.


Invalid picture (Error 481)

An invalid graphics format was assigned to the Picture property. This error has the following cause and solution:

  • You tried to assign a graphics format other than a bitmap, icon, or Windows metafile to the Picture property of a form or control.

    Ensure that the file you are trying to load into the Picture property is a valid graphics file supported by Visual Basic.


Invalid picture type (Error 485)

The resource file picture format you tried to load doesn't match the specified property of the object. This error has the following causes and solutions:

  • You tried to use the LoadResPicture method to load a bitmap resource as the Icon property of a Form.

    Change the property of Form to the Picture property or change the format argument of LoadResPicture to vbResIcon.

  • You tried to use the LoadResPicture method to load a cursor resource as some property of an object or control other than the MousePointer property.

    Change the property reference to MousePointer.


Printer error (Error 482)

There is some problem that prevents printing. This error has the following causes and solutions:

  • You don't have a printer installed from the Windows Control Panel.

    Open the Control Panel, double-click the Printers icon, and choose Add Printer to install a printer.

  • Your printer isn't online.

    Physically switch the printer online.

  • Your printer is jammed or out of paper.

    Physically correct the problem.

  • You tried to print a form to a printer that can accept only text.

    Switch to an installed printer that can print graphics.


The project group file 'item' is in an unknown format, and can't be loaded

This can occur if the version number or header in the .VBG file is not correct. To correct this, for example, in Visual Basic 98, the version number should be VBGROUP 6.X, where is X can be 0-9.


The project group file 'item' is corrupt, and can't be loaded

A line in the .VBG file is not in the format: <property>=<value>, the <value> string is too big (>260 chars), or <property> is not equal to Project or StartupProject. This can occur if the .VBG file was edited outside of Visual Basic.


The project group file 'item' contains a duplicate value, and can't be loaded

The project group file (.VBG file) contains a duplicate entry for the StartupProject attribute. This can occur if the .VBG file was edited outside of Visual Basic. Remove the duplicate entry and reload the project.


The project group file 'item' is missing a required value, and can't be loaded

A required value was missing in the .VBG file. This error can occur if the .VBG file was modified outside of Visual Basic.


The wizard file 'item' is missing a required value, and can't be loaded

A required value was missing in the .VBZ file. The Wizard key must be specified. This error can occur if the .VBZ file was modified outside of Visual Basic.


The project group file 'item' is read-only

You tried to save, add, or remove a project from a project group which was marked as read-only. A project group is read-only if the .VBG to which it belongs has its read-only file attribute set.


Can't find Windows Help .EXE file

The Windows Help application isn't available. If Winhelp.Exe is on your machine, make sure it is on your path. If it isn't on your machine, run Microsoft Windows 95 or Microsoft Windows NT setup to install it.


Interface not registered. Looking for object with CLSID: |1.

Interface not registered. Looking for object with CLSID: <number>.

The interface is not registered. This is a system error. If this problem persists, re-install Visual Basic or the affected application, and try again.


Not a legal object name: 'item'

Form and control names must start with a letter and can be a maximum of 40 characters — including letters, numbers, and underscores (_).

Note that the Name property of a form or control is different from the Label properties — Caption, Text, and Value — which label or display the contents of a control at run time. These properties can be restricted keywords, can begin with a number, and can contain nonalphanumeric characters.


Illegal parameter. Can't write arrays (Error 328)

An illegal parameter was passed to the method. This error has the following cause and solution:

  • In the WriteProperties event of your User Control, you tried to do a PropBag.WriteProperty X, where X is an array. This isn't supported.

    You must write out each element of the array individually.


Invalid Action (Error 31021)

The Action property has been set to an invalid value.

The values 2, 3, 8, 13, and 16 are reserved for future use and are not valid with this version of the OLE container control.


Line 'item1': Cannot load control 'item2'; containing control not a valid container.

You attempted to load a control into a control which isn't a valid container.


Invalid Base Address

You entered an invalid base address. This error has the following cause and solution:

  • On the Compile Tab in the Project Properties dialog, you specified an invalid Base Address.

    A valid base address must be a multiple of 64K, greater than 64K, and less than &H7FFF0000.

This error occurs in ActiveX DLL or ActiveX Control projects.


Line 'item1': The CLSID 'item2' for 'item3' is invalid

An object could not be loaded during the load of a Form, User Control, User Document, or Property Page from a text file. The CLSID specified in the file is not valid. Applies only to objects that are properties, such as the Font object. This message is written to the error log file.


Visual Basic was not able to start up due to an invalid system configuration

Your installation of Visual Basic has not been correctly configured. This error has the following causes:

  • Visual Basic may have been incorrectly installed or the installation not fully completed.

  • System files or files required by Visual Basic may have been moved or deleted.

  • The registry may be corrupt.

In most cases, when this error occurs, you will need to reinstall your version of Visual Basic to properly configure it.


Line 'item1': The control name 'item2' is invalid.

The ASCII file contains a control name that isn't a valid string in Visual Basic. The control isn't loaded.


'item1' is an invalid key. The file 'item2' can't be loaded

Visual Basic did not recognize the specified key in the .VBP file. This error has the following cause and solution:

  • The .VBP file contains a key that Visual Basic doesn't recognize. The file may be corrupt.

    Install a backup copy of the specified file or modify the file using a text editor to correct the error.

Warning Modifying a Visual Basic file in an editor other than Visual Basic may corrupt the file. This is only recommended for advanced users.


Line 'item1': Property 'item2' in 'item3' had an invalid file reference.

The ASCII file contains a reference to a file that Visual Basic couldn't find in the specified directory.


Line 'item1': The Form or MDIForm name 'item2' is not valid; cannot load this form.

The ASCII file contains a form name that isn't a valid string in Visual Basic. The form isn't loaded.


Line 'item1': Property 'item2' in control 'item3' had an invalid property index.

The ASCII file contains a property name with a property index greater than 255.


Invalid object use (Error 425)

This error has the following causes and solution:

  • You called the SetData or Clear methods of DataObject during an OLE drag-and-drop target event (OLEDragOver or OLEDragDrop).

  • You called the GetData method of DataObject during an OLE drag-and-drop source event (OLEStartDrag, OLECompleteDrag, OLEGiveFeedback, OLESetData).

  • You tried to reference a DataObject object outside of the event in which it was passed in.

  • You tried to use the PropertyBag object outside of the ReadProperties and WriteProperties events of a User Control.

In general, this error is caused by an illegal reference to an object. To solve the problem, remove the reference to that object or try referencing it in a different part of your program.


The specified object can't be used as an owner form for Show() (Error 371)

You specified an invalid object for the OwnerForm parameter of the Show method. This error has the following cause and solution:

  • You specified the OwnerForm parameter for the Show method but didn't specify a valid owner.

    You must specify a valid Form, MDI Form, or ActiveX Designer for the OwnerForm parameter of the Show method.


Invalid path to HTML template (3003)

Invalid path to HTML template (9006)

The path supplied to the HTML template is either incorrect or missing from the system.


Invalid procedure name

A procedure name can't be a restricted keyword, must start with a letter, must be unique within the same scope, and can be a maximum of 255 characters — including letters, numbers, and underscores (_). Function procedure names can include a type declaration character, but Sub procedure names cannot.


The project file 'item1' contains invalid 'item2' key value

Visual Basic did not recognize the specified key value in the .VBP file. This error has the following cause and solution:

  • The .VBP file contains a value for the key that is invalid. The file may be corrupt.

    Install a backup copy of the specified file or modify the file using a text editor to correct the error.

Warning Modifying a Visual Basic file in an editor other than Visual Basic may corrupt the file. This is only recommended for advanced users.


Invalid property value


Line 'item1': The property name 'item2' in 'item3' is invalid.

The ASCII file contains a property name that isn't a valid property for that control.


Line 'item1': Property 'item2' in 'item3' had an invalid value.

The ASCII file contains a property with a value that isn't correct for this control. The property is set with its default value.


The project file 'item1' contains invalid 'item2' key value. Valid range is 0 to 'item3'

The key value specified in the .VBP file was out of range. This error has the following cause and solution:

  • The .VBP file contains a key value that is not in the specified range. The file may be corrupt.

    Install a backup copy of the specified file or modify the file using a text editor to correct the error.

Warning Modifying a Visual Basic file in an editor other than Visual Basic may corrupt the file. This is only recommended for advanced users.


Line 'item1': Could not create reference: 'item2'

The specified reference could not be created.


Invalid source for link (Error 31031)

You attempted to create a linked object (set Action = 1) and the file specified by the SourceDoc property couldn't be found.


Invalid number of threads. The number of threads should be integer between 1 and 32767

You entered an invalid number of threads for the Thread Pool in the General Tab of the Project Properties dialog box. The number of threads must be an integer between 1 and 32767.


Invalid Verb index (Error 31034)

You tried to activate an object (set Action = 7), and the Verb property was set to an invalid value.

Use the ObjectVerbs and ObjectVerbsCount properties to determine the list of verbs an object supports.


Invalid or unknown Class (Error 31023)

The specified Class property isn't valid and the SourceDoc property isn't specified.

To display a list of the available class names on your system, at design time click the OLE container control with the right mouse button and choose the Insert Object command.

Use extra care when setting the Class property at run time as some class names may be case-sensitive.


Invalid format (Error 31017)

You attempted to set or get data with the Data or DataText property using an invalid data format or a format the object doesn't support.

To determine the set of valid formats for an OLE object, use the ObjectAcceptFormats, ObjectAcceptFormatsCount, ObjectGetFormats, and ObjectGetFormatsCount properties.


Invalid property value (Error 31008)

You attempted to assign an invalid value to a property.

This error also occurs when you are performing an action that requires several properties to be set, and one of the properties is set to an invalid value.


The current value of '|1' instancing property is not valid in this type of project. The property value has been changed

The current value of '<name>' instancing property is not valid in this type of project. The property value has been changed

The Instancing property chosen for this particular type of object is not valid, so it was changed to a legal value.


'item' can not be public in this type of project. The item has been changed to private

The item cannot be public in this type of project and will be changed to private.

Visual Basic changes some items to private in order to avoid inconsistencies in the project. For example, if Visual Basic detects that the project has a public class module but the Project Type is set to a type that doesn't support public class modules, the public class module will be changed to private.

This error can occur if any of the files in the project have been modified in an editor other than Visual Basic. For example, Visual Basic detects that Standard Project Executable owns public class modules while this type of project allows only private class modules.


Project file '|1' does not exist

Project file '<name>' does not exist

A file referred to in a saved project was not able to be loaded in the project.


Object already loaded (Error 360)

The control in the control array has already been loaded. This error has the following cause and solution:

  • You tried to add a control to a control array at run time with the Load statement but the index value you referred to already exists.

    Change the index reference to a new value or check if your code is executing the same Load statement, with the same index value reference, more than once.


The file 'item' is out of date. This program requires a newer version (Error 368)

An ActiveX control was found to be out of date. This error has the following cause and solution:

  • The number of properties in the current version of the ActiveX control doesn't match the number expected.

    Replace the ActiveX control with a newer version.


Unable to unload within this context (Error 365)

In some situations you are not allowed to unload a form or a control on a form. This error has the following causes and solutions:

  • There is an Unload statement in the Paint event for the form or for a control on the form that has the Paint event.

    Remove the Unload statement from the Paint event.

  • There is an Unload statement in the Change, Click, or DropDown events of a ComboBox.

    Remove the Unload statement from the event.

  • There is an Unload statement in the Scroll event of an HScrollBar or VScrollBar control.

    Remove the Unload statement from the event.

  • There is an Unload statement in the Resize event of a Data, Form, MDIForm, or PictureBox control.

    Remove the Unload statement from the event.

  • There is an Unload statement in the Resize event of an MDIForm that is trying to unload an MDI child form.

    Remove the Unload statement from the event.

  • There is an Unload statement in the RePosition or Validate event of a Data control.

    Remove the Unload statement from the event.

  • There is an Unload statement in the ObjectMove event of an OLE Container control.

    Remove the Unload statement from the event.


The ActiveX Designer's Type Information does not match what was saved. Unable to Load (Error 370)

An ActiveX Designer could not recreate the information that it saved, and won't be loaded. This error has the following cause and solution:

  • The most common reasons for this to occur are – a forms package designer might not be able to load a control, a control might be missing a license, or a database designer might not be able to find ODBC.

    Re-install the ActiveX Designer to correctly register the designer, or contact the designer's vendor for more information.


Can't load (or register) ActiveX control: 'item' (Error 367)

The specified ActiveX control cannot be loaded or registered. This error has the following cause and solution:

  • You tried to load a form but one of the ActiveX controls on the form is not registered correctly, and its file cannot be located so it can't be auto-registered.

    This error occurs in compiled projects. Make sure that you distribute all necessary files when distributing your program to another user.


No MDI form available to load (Error 366)

There is no MDIForm in your project to load. This error has the following cause and solution:

  • You tried to load a form whose MDIChild property is set to True, but at run time there was no MDIForm in your project to load.

    Add a MDIForm to your project or change the MDIChild property setting to False.


ActiveX control 'item' not found (Error 363)

The form being loaded contains an ActiveX control that isn't part of the current project. This error has the following causes and solutions:

  • You may have manually edited the project’s .VBP file to add a form containing an ActiveX control that isn't already part of the project.

    After the project loads, select Components from the Project menu and add the ActiveX control to the project.

  • You may have manually edited the project’s .VBP file to add a form containing an ActiveX control that is an older version than the ActiveX control that is already part of the project.

    After the project loads, delete the older version from the form and put the newer version of the control on the form.


Operation not valid in an ActiveX DLL (Error 369)

Some operations are not valid in an ActiveX DLL or ActiveX Control project. This error has the following causes:

  • You set the LinkMode property of a form or control.

  • You set or accessed the App.TaskVisible property.

  • You set or accessed the App.OleRequestPendingTimeout property.

  • You set or accessed the App.OleServerBusyRaiseError property.

  • You set or accessed the App.OleServerBusyTimeout property.

  • You set or accessed the App.OleServerBusyMsgTitle property.

  • You set or accessed the App.OleServerBusyMsgText property.

  • You set or accessed the App.OleRequestPendingMsgTitle property.

  • You set or accessed the App.OleRequestPendingMsgText property.

For additional information, select the item in question and press F1.


Can't load or unload this object (Error 361)

A Load or Unload statement has referenced an invalid object or control. This error has the following causes and solutions:

  • You tried to load or unload an object that isn't a control or form, such as Screen, Printer, or Clipboard.

    Delete the erroneous statement from your code.

  • You tried to load or unload an existing control that isn't part of a control array. For example, assuming that a TextBox with the Name property Text1 exists, Load Text1 will cause this error.

    Delete the erroneous statement from your code or change the reference to a control in a control array.

  • You tried to unload a Menu control in the Click event of its parent menu.

    Unload the Menu control with some other procedure.

  • You tried to unload the last visible menu item of a Menu control.

    Check the setting of the Visible property for the other menu items in the control array before trying to unload a menu item or delete the erroneous statement from your code.


Can't unload controls created at design time (Error 362)

Only a control array element loaded at run time can be unloaded. This error has the following cause and solution:

  • You used the Unload statement to refer to a control array element that you created at design time.

    Change the index value of the control you want to unload to a control array element that was loaded at run time. Or you can hide any control by setting its Visible property to False.


Object was unloaded (Error 364)

A form was unloaded from its own Form_Load procedure. This error has the following cause and solution:

  • A form with an Unload statement in its Form_Load procedure was implicitly loaded. For example, the following will implicitly load Form2 if it isn't already loaded: Form2.BackColor = Form1.BackColor.

    Remove the Unload statement from the Form_Load procedure.


Current public/instancing property values are not valid in this type of project ('|1'). The property values have been changed.

Current public/instancing property values are not valid in this type of project (<name>). The property values have been changed.

The values currently set in the Public and/or Instancing properties aren't valid for this type of project, so the property values were changed to values that will work.

This error occurs when you add a file to an existing project, but that project type doesn't support the setting of the Instancing and/or Public properties of the module the file contains.

For example, you get this error if you add a class module from an ActiveX Exe project whose Instancing property is set to MultiUse to a Standard Exe project. This is because Standard Exe projects support only the value Private for the Instancing property.

Similarly, this error occurs if you add a UserControl whose Public property is True to a Standard Exe project, because controls in Standard Exe projects can be private only.

You don't need to take any action as a result of this error, because Visual Basic automatically resets the Instancing or Public property to a value supported by the project type.


Could not lock the database (Error 541)

The database file could not be locked. This error has the following causes and solutions:

  • You tried to lock a table while opening it, but the table can't be locked because it is currently in use.

    Wait a moment, and then try the operation again.

  • You tried to lock a record that is currently locked by another user.

    Wait for the other user to finish working with the record, and then try the operation again.


< > cannot be renamed back to < >

When a WebClass is run from the Visual Basic IDE, an .Asp is generated for that WebClass. If an .Asp of the same name already exists, it is backed up before the WebClass is run and restored after the WebClass runs. An error has occurred restoring the original .Asp. The original .Asp may have been deleted or a system error occurred.


Main can't be module, type, project, or form name.

You have the startup form set to Sub Main, and you have a module, form, project, or type named "Main" which prevents the Sub with the same name from being called.

Rename the module, form, project, or type.


You already have a control named 'item'. Do you want to create a control array?

You've tried to set the Name property of a control or paste a new control onto the form, and you already have a control with the indicated name.

If you would like to create a control array, choose Yes. The newly created control array element will have an Index value one higher than the control previously created with this name. If you don't want to create a control array, choose No. If you're pasting a control, Visual Basic will generate the name for the new control.


The project 'item1' can not be built because it references project 'item2' that does not have a compatible server set.

You cannot build the project because a project did not set a compatible server. For example, if you build Project1, and Project1 references Project2, but Project2 doesn't have a compatible server set, you will get this error. You must set a compatible server on the Components tab of the Project Properties dialog box.


The project 'item1' can not be built because it references project 'item2' that has not been built.

You tried to build a project that references another project that hasn’t been built. For example, if you build Project1, and Project1 references Project2, but Project2 does not have a version compatible component set, you will get this error. This only occurs when the Project2's Version Compatibility setting is set to Project Compatibility. You can solve this problem by building Project2, which automatically sets the version compatible component.


Unexpected error occurred in code generator or linker

The code generator or linker caused an unexpected error. Click Yes to display the errors in Notepad.

This error is most commonly caused by low disk space or other disk-related issues.


Line 'item1': Maximum nesting level for controls exceeded with 'item2'.

The ASCII file contains controls nested more than seven levels deep.


Shortcut key already assigned

You tried to assign a shortcut key that has already been assigned to another menu item. Assign a different shortcut key.


Menu control array elements must be contiguous and within the same submenu

You have tried to add an item to a Menu control array in which the other items in the array are adjacent to the current item. The indices of the items in a Menu control array don't have to be contiguous (for example, 2, 3, 4), but they must be in ascending order according to their location on the menu. The items in a Menu control array, however, must be located next to each other within the same menu or pop-up menu.


Controls without the align property cannot be placed directly on the MDI form

You tried to double-click a control to place it on an MDI form, but the control doesn't support the standard Align property or is not an invisible at run-time control. The PictureBox and Timer controls are the only intrinsic controls that can be placed on an MDI form.


Control 'item' does not have the align property, so it cannot be placed directly on the MDI form

The specified control doesn't have an Align property so it can't be put on an MDI form. This error has the following causes and solution:

  • You placed a UserControl on an MDI form, then changed the Alignable property of the UserControl to False.

  • You tried to add a control that doesn't have an Align property to the form.

    Only controls that have an Align property can be placed on an MDI form.


Menu control array element must have an index

An item has been added to a Menu control array without assigning an index value to the item. Unlike other control arrays in Visual Basic, Menu control arrays require you to assign indices as the item is created, because Visual Basic doesn't supply a default Index property setting for Menu control array items.


Menu control array indexes must be in ascending order

An index value assigned to an item in a Menu control array is out of order with the other items. The indices of a Menu control array don't have to be contiguous (for example, they could be 1, 3, and 5), but they must be in ascending order according to their location on the menu. Get the next available index number before assigning a number to the index.


MDI Forms are not allowed in an ActiveX DLL or ActiveX Control project

You cannot add an MDI Form to an ActiveX DLL or ActiveX Control project.


Menu control must have a name

A menu item has been created without assigning a name to it. Unlike other controls in Visual Basic, a Menu control requires you to assign names as the control is created, because Visual Basic doesn't supply a default name for menu items.


Can't have more than one Window List menu

You clicked the Window List check box for more than one menu item and then chose OK to close the dialog box. For a particular form, only one menu can have the Window List check box checked. To do this, use the Menu Editor.


Can't assign shortcut key to a top level menu

You are trying to assign a key combination to a parent or top-level menu item that isn't a command. Only commands can have shortcut keys assigned to them.


Can't put check mark here.

This is a menu design error indicating that you tried to select Checked on a menu item that does not support check marks. The following situations can cause this error:

  • You tried to select Checked in the Menu Editor for a top-level menu item.

  • You selected Checked for some menu item which has a submenu such as a cascading sub-menu.

  • You chose some menu such as a MDI Window list menu that cannot be checked.


Separator may not be checked or disabled, or have a shortcut key

While working with the Menu Editor tool, you tried to set a separator menu item's Checked property to True or its Enabled property to False or you tried to assign it a shortcut key. A separator menu item can't have any of these property settings, but you can set its Visible property to False.


Separator may not be the Window List menu

The window menu has to be a menu item that can support being a pop-up menu (one that can have subitems). A separator can't have subitems.


Menu item skipped a level

Menu levels must be contiguous. Menus can be cascaded to five levels. An item at level 2 can open a pop-up menu at level 3, and an item at level 3 can open a pop-up menu at level 4.

In the Menu Editor dialog, make sure menu items are indented only one level beyond the previous level.


Only Top Level Menus can have non-zero NegotiatePosition.

You tried to set the NegotiatePosition property for a menu item other than a top-level menu.


At least one submenu item must be visible

The Visible property can't be set to False for the last remaining visible submenu item. You can't have a parent menu with no visible submenu items.


Top-level or invalid menu specified as PopupMenu default (Error 490)

You specified a default item in the PopupMenu method but that item was not a valid menu item.

The default item must be one of the items already listed in the menu.


Line 'item1': All controls must precede menus; cannot load control 'item2'.

A control appeared in an incorrect location in the ASCII form file. All controls must be loaded before menus.


Method not applicable in this context (Error 444)

You cannot use this method in the current event procedure.


Line 'item1': Missing or invalid control class in file 'item2'.

The ASCII file contains an unknown control class in the form description, or the class name isn't a valid string in Visual Basic.


Line 'item1': Missing or invalid control name in file 'item2'.

The ASCII file contains an unknown control name in the form description, or the control name isn't a valid string in Visual Basic.


Line 'item1.: Syntax error: property 'item2' in 'item3' was missing an '='.

Line 'item1': Syntax error: property 'item2' in 'item3' was missing an '='.

The ASCII file contains a property name and value without an equal sign between them. The property isn't loaded.


Can't show non-modal form when modal form is displayed (Error 401)

When a modal form is displayed, you can’t display another non-modal form. This error has the following cause and solution:

  • You tried to use the Show method or set the Visible property to True on a non-modal form when another form is already displayed as modal.

    Use either the Unload statement or the Hide method on the modal form before attempting to use the Show method on a non-modal form.


Unable to show modal form within this context (Error 405)

You tried to show a modal form that would cause the current form to be unloaded. This is not allowed.


MDI child forms cannot be shown modally (Error 404)

You may not set the modal option on an MDI child form. This error has the following cause and solution:

  • You tried to use the Show method, with the style argument set to 1 - vbModal, on an MDI child form.

    Remove the style argument reference from your code.


MDI forms cannot be shown modally (Error 403)

You may not set the modal option on an MDIForm. This error has the following cause and solution:

  • You tried to use the Show method, with the style argument set to 1 - vbModal, on an MDI parent form.

    Remove the style argument reference from your code.

  • You tried to compile an ActiveX DLL project that contains an MDIForm.

    MDFforms cannot be put in DLLs. Remove the MDIForm from the project and then re-compile, or change the Project Type from the Project Properties dialog box to Standard EXE and re-compile.


Must close or hide topmost modal form first (Error 402)

The modal form you are trying to close or hide isn't on top of the z-order. This error has the following cause and solution:

  • Another modal form is higher in the z-order than the modal form you tried to close or hide.

    First use either the Unload statement or the Hide method on any modal form higher in the z-order. A modal form is a form displayed by the Show method, with the style argument set to 1 - vbModal.


Form already displayed; can't show modally (Error 400)

You can’t use the Show method to display a form as modal that is already visible. This error has the following cause and solution:

  • You tried to use Show, with the style argument set to 1 - vbModal, on an already visible form.

    Use either the Unload statement or the Hide method on the form before trying to show it as a modal form.


Line 'item1': Property 'item2' in 'item3' must be a quoted string.

The ASCII file contains a property that should appear inside quotation marks, but the quotation marks are missing. This line in the form description is ignored.


Must specify which item(s) to print

You have not specified what to print. Check at least one of the Form or Code check boxes in the Print dialog box after choosing Print from the File menu.


All 'item1' objects in this project will be upgraded to 'item2' objects

You're trying to load a project that contains an OLE Embedding (Excel, Word, etc.) and the server application on your machine is a more recent version than the one used to save the project. Your project should continue to load correctly.


Name already in use

This name is already in use. You must choose another name.


NextItem cannot be set from within this event (3013)

NextItem cannot be set from within this event (9016)

NextItem cannot be set from within this event.


The Visual Basic Development Environment can't provide multiple instances of a single use class. Consult the documentation for restrictions on debugging single-use objects

You are only allowed one instance of a single-use object when debugging in the development environment.

You are trying to create more than one object marked as single-use from the development environment. Each instance of a single-use object creates a new instance of the component. This is not allowed in the development environment.

To allow the creation of more than one instance of the object, set the Instancing property of the object to 5 - MultiUse, or compile the component and use the object from a compiled executable.


Line 'item1': Cannot set checked property in menu 'item2'. Parent menu cannot be checked.

A top-level Menu control appeared in the ASCII form file with its Checked property set to True. Top-level menus can't be checked. The Menu control will be loaded, but its Checked property won't be set.


Class is not set (Error 31018)

When setting Action = 0 (CreateEmbed method) if you don't specify a source document (SourceDoc property), the Class property must be set to the name of a class available on your system.

To display a list of the available class names at design time, click the OLE container control with the right mouse button and choose the Insert Object command.


Incorrect Clipboard format (Error 31035)

The OleTypeAllowed property doesn't match the type of object on the Clipboard.


A file must be specified in order to create a compatible ActiveX component.

You must specify a file when you create a version compatible ActiveX component. On the Components tab of the Project Properties window, type in the name of an ActiveX component in the text box, or click the ellipse button to browse for one.


The file 'item' does not contain information needed to create a compatible ActiveX component

The file name you entered for the Compatible ActiveX Component (in the Component tab of the Project Properties dialog box) isn't a Visual Basic-created .exe with Public class modules.


You can't put a Default or Cancel button on a Property Page (Error 379)

A Default or Cancel button cannot be put on a Property Page. This error has the following causes and solutions:

  • You tried to set the Default or Cancel property of a control contained by a Property Page to True. This is not allowed.

    Property Pages already have Default/Cancel buttons on them and you're not allowed to override them.


Unable to write Designer cache file 'item'. Will just use regular files on Load

Your ActiveX Designer was not able to write information to a cache file, so the designer will load using uncached information.

An ActiveX Designer writes a cache file to improve performance the next time you start Visual Basic. When this error occurs, the designer was unable to write to the cache file due either to insufficient disk space or invalid permissions to the drive (such as write privilege). Make sure you have enough disk space available and that you have network access (if applicable) and write permission to the drive. If the problem persists, contact the ActiveX Designer's vendor.


'Item' could not be loaded

Syntax errors are preventing Visual Basic from parsing and loading a file, or form name conflicts prevent loading of an ASCII form. The form won't be loaded and the form name won't be displayed in the Project Explorer.

Make sure that the file causing this error is a valid ASCII form in the correct format and that no conflicts exist among the different forms in the project. The correct ASCII form format is:

   VERSION 6.00
   Begin VB.Form <formname>

      Form Properties
      Begin VB.<controltype> <controlname>
         prop = value
         prop = value
         [...]

         Control Properties
         Begin VB.<control type> <control name>
            prop = value
            [...]
            Begin ...
               [...]
            End
         End
      End
   End
   ATTRIBUTE = "<form name>"
   [...]


'Item' could not be registered

The specified file couldn't be registered in the system registry. The error is related to type libraries used by components of the Visual Basic development environment and indicates that the specified file's entry in the system registry is corrupted or that the DLL itself is missing or corrupted.


Can't have child controls capable of receiving focus on a UserControl whose CanGetFocus property is False

You are not allowed to have controls that can receive focus on a UserControl whose CanGetFocus property is set to False.


Line 'item1': Did not find an index property and control 'item2' already exists.

The control can't be loaded because there is no index, and it has the same name as a previously loaded control.


Not enough memory to load file

Visual Basic couldn't obtain enough memory to load the file. Close other applications and try again.


Visual Basic found an instance of 'item' in a binary form file. VBX's cannot be converted from binary form files in the 32-bit version

Versions of Visual Basic later than 5.0 cannot convert VBXs in binary form files to the equivalent ActiveX controls.

You can use versions prior to Visual Basic 5.0 to convert the form file from binary to a text format form, then load it into the newer version of Visual Basic.


MultiSelect must be 0 - None when Style is 1 - Checkbox

You tried to set the MultiSelect property to something other that 0 (None), when the Style property of a ListBox control is set to 1 (CheckBox). This is not allowed.


Non-modal forms cannot be displayed in this host application from an ActiveX DLL (Error 406)

Non-modal forms cannot be displayed from most host applications. This error has the following cause and solution:

  • You have code in your ActiveX DLL that displays a non-modal form.

    If you need to display a modal form, change your project type to ActiveX EXE and rebuild your project.


No object (Error 31004)

You tried to perform an action on an object that doesn't exist.


The OLE client control and OLE embeddings are not allowed on UserControls, UserDocuments, or PropertyPages

You tried to paste an OLE client control from the Clipboard onto a UserControl, UserDocument, or PropertyPage. This is not allowed.


RecordSource property of the associated data control is empty

An error has occurred while attempting to retrieve information from the associated data control.

Verify that the data control and any objects that it references are correctly registered. Contact the control's vendor for more information if the problem persists.


Line 'item1': Cannot set Shortcut property in menu 'item2'. Parent menu cannot have a shortcut key.

A top-level Menu control appeared in the ASCII form file with a shortcut key defined. Top-level menus can't have a shortcut key. The Menu control will be loaded, but its Shortcut property won't be set.


The Instancing property for Class 'item' cannot be set to Creatable SingleUse for an ActiveX DLL

The Instancing property for the specified class was set to an invalid setting for an ActiveX DLL. Valid settings for the Instancing property for an ActiveX DLL are: 1 - Private, 2 - PublicNotCreatable, 5 - MultiUse, or 6 - GlobalMultiUse.


The VBIDE can't provide multiple instances of a SingleUse class

This error occurs under one or more of the following conditions:

  • A project that is running in the development environment contains a class whose Instancing property is set to SingleUse.

  • A client project has previously created an instance of this SingleUse class.

  • A client (it may be the same client, or another client) attempts to create a second instance of the SingleUse class.

The error occurs because a SingleUse object can only be created once per instance of the component that provides it. (That is, once an ActiveX Exe project is compiled, creating multiple instances of its SingleUse class will run multiple instances of the Exe component.) However, when the project is in the development environment, it is not possible to start a second instance of the project.

This is a restriction on debugging projects that provide SingleUse classes.

Note The error will occur even if the first client has released its instance of the SingleUse class. This is because a compiled Exe cannot provide a second instance of a SingleUse class, even after the first has been released.

For more information, see "Scalability Through Multiple Processes: SingleUse Objects," in "Building Code Components" in "Creating ActiveX Components" in the Component Tools Guide.


Source Document is not set (Error 31019)

When creating a linked object, or creating an object from a file (set Action = 1), the SourceDoc property must be set to a valid file name.

At design time, select the SourceDoc property in the Properties window and click the three dots in the settings box to browse your disk for a valid filename.


Must have startup form or Sub Main()

No form in the current project is designated as the startup form, and the current project doesn't have a Sub procedure named Main in any module. You must have one or the other to run a Visual Basic application.


The file 'item' was not registerable as an ActiveX Component.

You tried to register a control or DLL which is not a valid ActiveX component. Make sure that you have the correct control or DLL. Contact the ActiveX component's vendor for more information.


Can't clear Index property without changing Name

This control is part of a control array. If you want to delete its index value, which deletes it from the control array, you must first rename it with a unique Name property setting.


Not a legal name

The name you entered is not a legal name for a WebItem or Event name. Visual Basic defines the criteria in the same manner as it does for form or control names.


Object not running (Error 31028)

You can't perform the following actions on an object unless the application that created the object is currently running:

  • Copy an object to the Clipboard (set Action = 4).

  • Set or read the Data property.

  • Set or read the DataText property.

  • Read the ObjectAcceptFormats property.

  • Read the ObjectAcceptFormatsCount property.

  • Read the ObjectGetFormats property.

  • Read the ObjectGetFormatsCount property.

Use the AppIsRunning property to determine if the application that created an object is running.

If the object exists, you activate it (and therefore invoke the application that created it) by setting Action = 7 (Activate). To activate an object without displaying the application that created it, first set the Verb property to – 3.


Permission to use object denied (Error 419)

You don't have the necessary permissions for the specified object. This error has the following cause and solution:

  • You don't currently have the authority to access this object.

    To change your permission assignments, see your system administrator or the object's creator.


Invalid object type; Menu control required (Error 427)

The first argument for the PopupMenu method must be a Menu control. This error has the following cause and solution:

  • You specified some object other than a Menu control as the menuname argument for the PopupMenu method.

    Use the name of a Menu control with at least one submenu as the menuname argument.


License information for this component not found. You do not have an appropriate license to use this functionality in the design environment (Error 429)

You are not a licensed user of the ActiveX control. This error has the following cause and solution:

  • You tried to place an ActiveX control on a form at design time or tried to add a form to a project with an ActiveX control on it, but the associated information in the registry could not be found.

    The information in the registry may have been deleted or become corrupted. Reinstall the ActiveX control or contact the control vendor.


Line 'item1': Cannot create embedded object in 'item2'; license not found

An embedded object could not be created during the load of a Form, User Control, User Document, or Property Page from a text file, due to the license file not being found. You must have a license to use this object. Check with the object's vendor for more information. This message is written to the error log file.


Object is not registered. Looking for object with CLSID: |1.

Object is not registered. Looking for object with CLSID: <number>.

The object you are trying to use is not registered. This is a system error. If this problem persists, re-install Visual Basic or the affected application, and try again.


Only one MDI Form allowed (Error 426)

A project can only have one MDIForm. This error has the following causes and solutions:

  • You tried to load a file containing an MDIForm into a project that already has an MDIForm in it.

    Remove the file containing the loaded MDIForm before loading another.

  • You tried to load a second instance of an MDIForm created with a Dim or Set statement.

    You can only create one instance of an MDIForm in a project.


Popup menu must have at least one submenu (Error 428)

You have defined a pop-up menu with no submenus. This error has the following cause and solution:

  • You specified a Menu control that doesn't have a submenu as the menuname argument for the PopupMenu method.

    Use the name of a Menu control with at least one submenu as the menuname argument.


Version 'item3' of 'item1' is not registered. The control will be upgraded to version 'item2'

Your project was saved with a version of the specified ActiveX control that is not available on your system. A newer version of the specified ActiveX control is registered on your system, so your project will be loaded using the newer version of this control.

In addition, this message may occur from time to time when you are authoring ActiveX controls with Visual Basic. The message is harmless and requires no action on your part, but can be avoided (described later).

The message may appear if the following circumstances occur:

  1. You compile your ActiveX control project to an .Ocx file.

  2. You create a test project in another copy of Visual Basic and use the Controls tab of the Components dialog box (accessed from the Project menu) to select the .Ocx file, which then appears in the Toolbox.

  3. You place an instance of a control on a form, and then save the test project.

  4. At some later date, you recompile the .Ocx file.

  5. When you open the test project, the message appears as the project is loaded.

Given the above events, the message occurs if you use the default Version Compatibility setting (Project Compatibility, on the Components tab of the Project Properties dialog box). The Project Compatibility setting causes the type library version number of a control component (.Ocx file) to be incremented each time you compile it. This setting allows easy upgrades of released controls.

Normally, when a new release of an .Ocx file is installed on a developer's computer, it does not replace the old version (because the file names are different). When the developer opens an existing project that uses the old version of the control, Visual Basic asks whether the control instances in the project should be upgraded to the new version.

In this case, there is no old version of the .Ocx file, so Visual Basic automatically upgrades the controls and provides a message informing you of this.

Note The type library version number is not in any way associated with the file version number you set using the Make tab of the Project Properties dialog box. The numbers displayed in this message are the decimal equivalents of the hexadecimal type library version numbers stored in the Windows Registry.

The message requires no action on your part in this scenario, because Visual Basic automatically incorporates the new type library version number into the test project.

You can avoid the message in two ways:

  • Instead of compiling your .Ocx file and testing it with a separate copy of Visual Basic, you can include both the ActiveX control project and the Standard Exe test project in a project group, and run them in the same copy of the development environment. This is described in "Creating an ActiveX Control," in Creating ActiveX Components in the Component Tools Guide.

  • Use the Component tab of the Project Properties dialog box to select Binary Compatibility with an earlier version of your .ocx file. The drawback to this is that if you later make a version incompatible change to your control (such as removing a property), you will get Version Compatibility warning messages when you compile.

Note If you're creating a new version of an existing control, and you intend to make incompatible changes in the interface, binary compatibility may not be your best option; Project Compatibility is better in that case, because it preserves the ability of developers to upgrade the controls in their projects to your new version. You should change the file name, however, so that the new .Ocx file doesn't overwrite the old.

For more information on type library versions and the Version Compatibility feature, see "Version Compatibility" in "Debugging, Testing, and Deploying Components" in Creating ActiveX Components in the Component Tools Guide.


No public UserControl detected. Press F1 for more information

You tried to build an ActiveX Control project but no UserControl was available in the project. A UserControl is required in this type of project.


There is a newer version of 'item1' registered. Do you want to upgrade to version 'item2' ?

There is a newer version of the specified ActiveX control registered on your system (in addition to the original one). This message has the following cause:

  • You saved a project with an older version of an ActiveX control, then installed a newer version on your system.

    Select Yes to load the newer one or No to load the original control.


The declaration in the Compatible ActiveX Component was: 'item'

The declaration shown is missing from the component you are attempting to compile. It has either been deleted or renamed.

Click OK to return to the Incompatible Component dialog. You can then:

  • Click Accept to accept this version incompatible change.

  • Click Accept All to accept this and all subsequent version incompatible changes.

  • Click Edit to change the member name back to what it was, or add the missing member.

Note Accepting even one incompatible change will render this version of your component incompatible with all clients compiled using prior versions. It is strongly recommended that you change the file name and Project Name settings to avoid potentially serious program errors in those clients.


'Item' has an old file format. When saved it will be saved in a newer format.

This file was created with an earlier version of Visual Basic. When you save it, it will be saved in the new Visual Basic file format.


Cannot create embedded object. OleTypeAllowed property of 'item' control is set to Linked (Error 31041)

You tried to create an embedded object using the CreateEmbed method while the OleTypeAllowed property was set to 0 - Linked.

The OleTypeAllowed property must be set to 1 - Embedded or 2 - Either, before using the CreateEmbed method to create an embedded object.


Only one property per module can bind to DataField. Property 'item' already binds to it. Selecting this attribute will void the previous setting.

You tried to set the Data Binding attribute of a property to bind to DataField, but another property has this attribute set. This can occur in the Procedure Attributes dialog box.

Only one property in a module is allowed to bind to DataField. Click OK to set the current property to bind to DataField or click Cancel to void the change.


Only one resource file allowed

You chose Add File from the Project menu and tried to add a second .res file to your project, or the .vbp file lists more than one .res file. You can only have one Windows resource file in a Visual Basic project.


Only one property and one event per module can be selected User Interface Default. 'item' already has this attribute. Selecting this attribute will void the previous setting.

You tried to set the procedure attribute of a property or event to User Interface Default but it was already set on another property or event. This can occur in the Procedure Attributes dialog box.

Only one property or event is allowed to have the User Interface Default attribute set at once. Click OK to make the current property or event the User Interface Default or click Cancel to void the change.


Not enough memory to run; quitting

Visual Basic couldn't obtain enough memory to run. Close other applications and try again.


Out of memory (31001)

Could not allocate or access enough memory or disk space for the specified operation.


Line 'item1': Parent menu 'item2' cannot be loaded as a separator.

The ASCII file contains a Menu control whose parent or top-level menu is defined as a menu separator. Top-level menus can't be menu separators. The separator won't be set.


Valid values are whole numbers from 24 to 1188

You attempted to set the Grid Width or Grid Height beyond the permitted range. A number between 24 and 1188 (inclusive) is acceptable for this field.


Valid values are whole numbers from 1 to 32

You attempted to set the TabStop Width beyond the permitted range. A number between 1 and 32 (inclusive) is acceptable for this field.


Programmatic ID string too long 'item'

The ProgID string of the ActiveX component can't be longer than 39 characters. The ProgID is created by concatenating the project name with the class module name.


Project file is read-only

A change was attempted that would modify the project file, but the project file is under source code control and is not checked out.


This project is referenced from another project. Are you sure you want to remove it?

You are trying to remove a project that is referenced by another project in the group. Selecting Yes on this dialog will cause Visual Basic to try to reference the disk version instead of the in-memory project. This may cause a missing reference.


'Item' already exists in project

The file you specified is already part of the project. You can't add the same file to a project more than once. You can't save a file with the same name as another file in the project.


The project file 'item1' contains invalid key 'item2'. The project can't be loaded

Visual Basic did not recognize the specified key in the .VBP file. This error has the following cause and solution:

  • The .VBP file contains a key that Visual Basic doesn't recognize. The file may be corrupt.

    Install a backup copy of the specified file or modify the file using a text editor to correct the error.

Warning Modifying a Visual Basic file in an editor other than Visual Basic may corrupt the file. This is only recommended for advanced users.


A project with the name 'item' is already loaded

You tried to load a project that has the same name as a project that is already loaded. You cannot have two projects with the same name.


The project name is too long. Name has been truncated

The project name has been truncated because it was too long.


Project 'Start Mode' property has been changed

When converting an ActiveX project to a Standard .exe project, the project's Start Mode is changed.


Property is readonly at runtime (3011)

Property is read-only at runtime (9014)

You cannot write to this property during run-time.


Property must be unique across WebClasses

The specified property must be unique across WebClasses in the project or project group. Otherwise, .Asp file name conflicts will occur when the WebClass is run or compiled.


'item' can not be public in this type of project. Use Project Properties to change the project type

This occurs when you try to change a User Control's Public property to True when the User Control is not in an ActiveX control project. Either change the Project Type on the General Tab of the Project Properties dialog to ActiveX control, or don't set the User Control's Public property to True.


Invalid property array index (Error 381)

An inappropriate property array index value is being used. This error has the following cause and solution:

  • You tried to set a property array index to a value outside its permissible range.

    Change the index value of the property array to a valid setting. For example, the index value of the List property for a ListBox must be from 0 to 32,766.


'Item' property can't be set on this control (Error 387)

The property’s setting can't be set at run time or can only be set under certain conditions. This error has the following causes and solutions:

  • You tried to change the Appearance, ControlBox, MinButton, or MaxButton property settings for the form at run time.

    You may only read these property values at run time.

  • You tried to set the Visible property to False for the last remaining visible submenu on a parent menu.

    You can't have a parent menu with no visible submenu items.


Invalid property value (Error 380)

An inappropriate value is assigned to a property. This error has the following cause and solution:

  • You tried to set one of the properties of an object or control to a value outside its permissible range.

    Change the property’s value to a valid setting. For example, the MousePointer property must be set to an integer from 0 to 15 or 99.


Must specify index when using property array (Error 385)

You must specify an index value when referring to a property array. This error has the following cause and solution:

  • You tried to refer to an element in a property array but omitted the index value specifying the element.

    Change your code to include the index value. For example, List1.List is invalid but List1.List(3) is valid.


Invalid key (Error 389)

The key that was pressed is invalid.


'Item' property is write-only (Error 394)

The property can’t be read. This error has the following cause and solution.

  • A property can't be read; for example, ctl.property = 3 might be legal, but "Print ctl.property" would generate this error.

    Change your code and remove the reference to the property.


'Item' property cannot be read at run time (Error 393)

The property is only available at design time. This error has the following cause and solution:

  • You tried to read a property at run time that is only accessible at design time.

    Change your code and remove the reference to the property.


Cannot use separator bar as menu name for this control (Error 395)

A Menu caption that has submenus can't be changed to a separator bar. This error has the following causes and solutions:

  • At either design time or run time, you tried to change the Caption property on a parent or top-level Menu to a separator bar.

    Remove the dash character from the Caption text box in the Menu Editor dialog or the Caption property in the Properties window, or change the reference in your code.

  • At run time, you tried to change the Caption property on a Menu which is checked, disabled, or has a shortcut key to a separator bar.

    Change the reference in your code or read the setting of the Checked or Enabled properties before trying to change the Caption property. You can't read the setting of the Shortcut property at run time.


'Item' property cannot be set within a page (Error 395)

'Item' property cannot be set within a page (Error 396)

Certain properties of the Printer object can't be changed within a page. This error has the following cause and solution:

  • You tried to change the Height, Width, or PaperSize properties of the Printer object before advancing the print job to the next page.

    Use the NewPage method before changing the Height, Width, or PaperSize properties.


Can't load, unload, or set Visible property for top level menus while they are merged (Error 397)

The Visible property can't be set for a top-level menu while an ActiveX component's menu is merged with a container form's menu. This error has the following cause and solution:

  • You tried to change the Visible property of a top level menu while a Visual Basic container form's menu and a linked or embedded ActiveX component's menu were sharing the same menu bar.

    Test to ensure that menus are not merged before setting Visible for top-level menus.


'Item' property is read-only (Error 383)

The property is read-only at both design time and run time. This error has the following cause and solution:

  • You tried to set or change a property whose value can only be read.

    Remove the reference to the property from your code or change the reference to only return the value of the property at run time.


'item' cannot be set while loading (Error 378)

You cannot set the specified value while loading. This error has the following cause and solution:

  • You tried to modify a property of the Extender object from a UserControl, but the value cannot be changed while the container is loading. For example, you tried to change the Extender.Name property in your ReadProperties event.

    To solve this problem, move your code to an event that occurs later in the load process.


A form can't be moved or sized while minimized or maximized (Error 384)

The Left, Top, Height, and Width properties can't be changed on a minimized or maximized form. This error has the following causes and solutions:

  • You tried to use the Move method or change the Left, Top, Height, or Width of the form while it was maximized or minimized.

    Check the WindowState property of the form before using the Move method or prevent the user from maximizing or minimizing the form.

  • The Resize event occurred while the form was maximized or minimized and code in it tried to change the Left, Top, Height, or Width of the form.

    Rewrite the code in the Resize event procedure to check the WindowState property of the form and exit the procedure if WindowState is 1 - Minimized or 2 - Maximized.


'Item' property cannot be set at run time (Error 382)

The property is read-only at run time. This error has the following cause and solution:

  • You tried to set or change a property whose value can only be set at design time.

    Remove the reference to the property from your code or change the reference to only return the value of the property at run time.


Can't set Visible property from a parent menu (Error 388)

The Visible property of a submenu item can’t be set from its parent's menu code. This error has the following cause and solution:

  • You tried to set the Visible property of a submenu item from a procedure associated with the submenu item’s parent Menu.

    Place the code reference to the submenu item’s Visible property in some other control’s or object’s procedure.


This User Control is private and will not be accessible from other projects. Set public to true to change this

A private UserControl is only accessible to the project in which it is in. To access the control from other projects, you must set its Public property to True.


The Public property for Class 'item' cannot be set to True. You do not have an appropriate license to use this functionality in the design environment.

You can only make Public class modules (ActiveX components accessible from outside the project) with the Professional and Enterprise editions of Visual Basic 5.0 or later.


Line 'item1': 'item2' has a quoted string where the property name should be.

A quoted string appeared in the ASCII form file where the property name was expected. Property names are not placed inside quotation marks.


Recursive invocation of OLE drag and drop (Error 674)

There was an attempt to recursively invoke an OLE drag and drop operation. This error has the following cause and solution:

  • The user tried to invoke a new OLE drag and drop operation using the OLEDrag method while an OLE drag and drop operation was currently in process. This is not allowed.

    Don't use the OLEDrag method while an OLE drag and drop operation is in process.


A property or method call included a reference to a private object, either as an argument or as a return value.

You included a reference to a private object as an argument or return value in a property or method call. Private objects should never be passed outside a project. The following, all of which are prohibited, are possible causes for the error:

  • A client invoked a property or method of an out-of-process component and attempted to pass a reference to a private object as one of the arguments.

  • A client invoked a property or method of an out-of-process component and the component attempted to return a reference to a private object, or to assign such a reference to a ByRef argument.

  • An out-of-process component has invoked a call-back method on its client and attempted to pass a reference to a private object.

  • An out-of-process component attempted to pass a reference to a private object as an argument of an event it was raising.

  • A client attempted to assign a private object reference to a ByRef argument of an event it was handling.

The error will always appear in the client, even if it is the fault of the server code.

Note Although Visual Basic prevents you from passing references to private objects across processes, there are some cases in which Visual Basic can't detect this error and thus can't prevent it. Private objects are not designed to be used outside your project. If you pass them to a client, you may jeopardize program stability and cause incompatibility with future versions of Visual Basic. If you need to pass a private class to a client, set the Instancing property to a value other than Private.

For additional information, highlight the name of the item in question and press F1.


Could not access system registry (Error 335)

An attempt to read from or write to the system registry failed.


Object server 'item' not correctly registered or not found (Error 339)

This error has the following causes and solution:

  • The specified file was moved or deleted.

  • The specified file was incorrectly registered.

Reinstall the specified file to correctly register it. See the object's vendor for more information.


ActiveX component not correctly registered (Error 336)

The ActiveX component has not been properly registered in the system registry.


Object server did not correctly run (Error 338)

The ActiveX component's EXE file failed to run correctly. There may be a problem with the information in the registry.


Object server not found (Error 337)

The required EXE or DLL file can't be found.


Duplicate resources with same type and name

The Windows resource file you are trying to use in your project contains two or more resources with the same type and name, or the resource file has a resource that Visual Basic automatically creates.

Use another resource file or recreate the invalid resource file and delete one of the duplicate resources.


The row has been deleted since the update was started (Error 542)

A record can’t be updated because it was previously deleted. This error has the following cause and solution:

  • Because the LockEdits property for the Recordset object was set to False (optimistic locking) while the record was being edited, another user was able to delete the record before it could be updated.

    Set the LockEdits property to True (pessimistic locking).


'Item' is not a valid resource file (Error 325)

A resource file in your project doesn't follow the standard format for a Windows resource file or there is a mismatch between the resource file and the Visual Basic project. This error has the following causes and solutions:

  • You tried to use the LoadResString, LoadResPicture, or LoadResData methods on a resource file with an invalid format.

    Recreate the resource source and resource files and adhere to the syntax documented in the Windows Software Development Kit.

  • You tried to make an .EXE file from a project that includes a resource file with an invalid format.

    Remove the invalid resource file from the project.

  • You tried to use the Project Add File command to add a 16-bit resource file to a project.


Resource with identifier 'item' not found (Error 326)

The resource with the specified ID doesn't exist in the resource file. This error has the following cause and solution:

  • You tried to use the LoadResString, LoadResPicture, or LoadResData methods to load a resource whose ID doesn't exist in the resource file associated with this project or .EXE file.

    Change the reference to the resource ID to one that does exist, or remove the resource file from the project and add a resource file that contains the specified resource ID.


ActiveX component could not be created

An ActiveX component or instance of it couldn't be created with the CreateObject function, or you tried to compile the project, but Visual Basic couldn't create the file.


There is a compatibility error between the current project and the version-compatible component: 'item'

This error occurs if you run into a compatible component error during a command-line build.


Other applications are currently accessing an object in your program. Ending the program now could cause errors in those programs. End program at this time?

An automation object in the Visual Basic program you are currently running is being accessed by at least one other application. Terminating your program could cause an error in the other application. Choose Yes to quit your program or choose No to continue.


The ActiveX Control can not be used because it defines an event named 'item' which conflicts with Visual Basic

An event in the specified ActiveX control conflicts with a Visual Basic Extender event. Visual Basic automatically adds standard events to ActiveX controls that are added to a project.

When creating your own ActiveX control project, events such as GotFocus and SetFocus are automatically created (by the Extender object) so they don't need to be added to your control.

For controls not created in Visual Basic, see the control's vendor for more information.


Multiple copies of the shared file 'item' have been modified. In the following dialog, select the copy that should be saved

You have modified a file that is shared between two or more projects. Visual Basic doesn't know which file you want saved. Using the list box in the following dialog, choose the files that you want saved for this project.


The Public and/or Instancing property value of shared item '|1' has changed in one of the projects. The property has been changed in all sharing projects

The Public and/or Instancing property value of shared item '<name>' has changed in one of the projects. The property has been changed in all sharing projects

A Public and/or Instancing property which is shared betwen one or more projects was changed. This property value was changed in all of the shared projects.


The copy of this file which might have changes is already opened

You are trying to access a file that is already open in another project in the project group. For example, you may have a form that belongs to more than one project in the project group. If that form is displayed for the first project, you will get this error if you try to display it in the second project in the project group.


Source name is too long (Error 31026)

The combined number of characters in the SourceDoc and SourceItem strings can't exceed 256.


Specified object is not a WebItem of this WebClass (3008)

Specified object is not a WebItem of this WebClass (9012)

The specified object is not a WebItem of this WebClass. The specified method or property accepts only a WebItem of the same WebClass.


Specified TagPrefix value is too large (2003)

Specified TagPrefix value is too large (9002)

TagPrefix values must be between 1 and 32,000 characters.


Sub Main() doesn't exist

Sub Main is designated as the Startup Object in the Project Properties dialog, however, the current project doesn't have a Sub procedure named Main in any module.

  • Sub Main was created in a Form or Class module, instead of in a standard module.

    Add a standard module to the project, and in that module create a Sub procedure named Main.

  • The project was created as a Visual Basic 4.0 OLE server (that is, it had at least one class module whose Public property was True) and a form was designated as its Startup Object.

    A form should not be used as the startup object of a component (see “Starting and Ending a Component,” in “General Principles of Component Design” in the Component Tools Guide). Visual Basic 4.0 could not prevent forms as startup objects of components (OLE servers).

    Later versions of Visual Basic correct this problem. When loading a project that has both a public class and a form that's been designated as the Startup Object, Visual Basic designates Sub Main as the Startup Object instead. The resulting error message alerts the user to the change.

    If you wish to show a form when your component starts, you can do so from Sub Main. It is recommended that you do so only if your program is an EXE project, and is starting because the user selected it from the Startup menu or from the Windows Explorer. You can detect this by testing App.StartMode at the beginning of Sub Main.


No timer available (Error 260)

The number of Timer controls in a project, and the amount of memory each Timer object requires are limited. This error has the following causes and solutions:

  • There are too many active Timer controls. The maximum number varies from environment to environment.

    Remove one or more Timer controls from the project.

  • There isn't enough memory to load another Timer control.

    Try to free up some memory by closing other applications.


System Error 'item'

Visual Basic encountered an error that was generated by the system or an external component and no other useful information was returned.

The specified error number is returned by the system or external component (usually from an Application Interface call) and is displayed in hexadecimal and decimal format.


TagPrefix must begin with an alphabetic character (2002)

TagPrefix must begin with an alphabetic character (9001)

The TagPrefix property must begin with an alphabetic character.


Can't save file to TEMP

The directory established by your TEMP environment variable can't be written to. Make sure that your TEMP environment variable is set to a valid directory and that the disk isn't full.


The attribute <attribute name> for the tag <tag name> was connectedto the webitem <webitem name>. The HTML template <file name> for <template name> no longer contains that connection. The attribute will not be marked as connected in the WebClass

The attribute <attribute name> for the tag <tag name> was connected to the webitem <webitem name>. The HTML template <file name> for <template name> no longer contains that connection. The attribute will not be marked as connected in the WebClass

This error message appears after a template loads if connected tags or attributes have been deleted from the HTML file.


The following FORM tag (<tag name>) in the HTML template <file name> for <template name> does not specify METHOD=POST. WebClasses require the POST method. The tag will be changed to use METHOD=POST

The FORM tag in the HTML template does not specify METHOD=POST, which is required by WebClasses. The tag will be changed to use METHOD=POST.


The following system error occurred: <system error message>

This error displays whenever a system error occurs that is not associated with a specific task, such as loading a template.


The following system error occurred while loading the template <filename> for the template <template name>: <system error message>

This error displays during the loading of a template if a correctable system error occurs.


The HTML template file <file name> for <template name> is missing from the project directory. You may copy the file to the directory and retry or cancel loading of the template

This error occurs if, after loading a project, you select a template to load and the file is missing.

This may also occur if you change the project directory for the designer and do not move the templates into the new project directory. You can change the project directory by saving the designer's .Dsr file or the project's .Vbp file into a new directory, or by physically moving the designer's .Dsr or the project's .Vbp file externally.


The maximum number of WebItems has been reached

The maximum number of WebItems for a WebClass has been reached. See the documentation on WebClass designers for details.


The project must be saved before adding an HTML template

You attempted to add an HTML template before the project has been saved. Save the project now.


You may only load or create projects with two modules (Forms, MDI Forms, Modules, Classes) in the Visual Basic Working Model. Projects may contain an unlimited (system dependant) number of modules in full versions of Visual Basic.

The Visual Basic Working Model allows only two modules (Forms, MDI Forms, Modules, Classes) for each project. In order to increase the capacity of your Visual Basic projects, you must purchase a full version of Visual Basic, such as the Professional or Enterprise version.


Unable to bind to field: 'item' (Error 545)

The control was unable to bind to the field specified by the DataField property. This error has the following causes and solutions:

  • The DataField property of the bound control was set to a field that is not in the record set provided by the Data control.

    Set the DataField property of the bound control to a valid field. At design time, you can get a list of available fields by selecting the DataField property drop-down list from the Properties window. At run time, use the Fields collection of the Data control's Recordset to get a list of fields.

  • The RecordSource property of the Data control was changed and the Data control's Refresh method was executed, but the DataField property of an associated bound control was not updated.

    Set the DataField property of the bound control to a valid field. At design time, you can get a list of available fields by selecting the DataField property drop-down list from the Properties window. At run time, use the Fields collection of the Data control's Recordset to get a list of fields.

  • The Recordset property of the Data control was set to a new Recordset and a bound control was set to a field that is not in the record set provided by the Data control.

    Set the DataField property of the bound control to a valid field. At design time, you can get a list of available fields by selecting the DataField property drop-down list from the Properties window. At run time, use the Fields collection of the Data control's Recordset to get a list of fields.


Control projects cannot be run alone. Use File, Add Project to add a Standard Exe project, close the User Control design window, and then place a test instance of the control on Form1.

An ActiveX control cannot be run as an independent project. To test your control project:

  • On the File menu, click Add Project to open the Add Project dialog box. Double-click the Standard EXE icon to add a standard executable project to the project group.

  • On the File menu, click Save Project Group to save the project group. In future sessions, you can load both the control project and the test project by opening the project group.

  • In the Project window, double-click your UserControl to bring its designer to the front. Press CTRL+F4 to close the design window and run the control.

  • In the Toolbox, the control's icon is now enabled. Place a copy of the control on Form1 of the Standard EXE project.

Testing controls at design time and run time is introduced in the step-by-step procedures in "Creating an ActiveX Control" in the Component Tools Guide. More information on testing components can be found in "Debugging, Testing, and Deploying Components" and "Debugging Controls" in the Component Tools Guide.


Unexpected error

You have received a system error. If this problem persists, re-install Visual Basic or the affected application, and try again.


One or more of the properties in 'item' was bad. Some or all of the properties might not be set correctly.

The specified .VBP file has one or more invalid property settings. This error occurs only in regard to a project's .vbp file.


An unknown protocol was specified in Target parameter (Error 693)

You must specify a valid protocol in the target parameter for the AsyncRead method. This error has the following cause and solution:

  • You specified an invalid protocol in the target parameter for the AsyncRead method.

From a UserControl or UserDocument, you must specify a known value such as HTTP: or FILE: as the prefix for the Target parameter of the AsyncRead method. For example, "http://vbdocs/userdoc1.vbd" or "file:\\vbdocs\userdoc1.vbd".


Do you want to upgrade all 'item1' objects in this project to 'item2' objects?

The class of the specified object has changed. Choose Yes to upgrade all instances of the specified object in this project to reflect the changes made to the class, or choose No if you don't want to upgrade.


URL contains invalid event (3010)

The URL contains one or more invalid events. Valid events are covered in the documentation on WebClass designers.


URL contains invalid item (3005)

URL contains invalid WebItem (9008)

The URL contains an invalid WebItem name. See the WebClass designer documentation for correct WebItem naming standards.


User Documents are not allowed in this type of project. Item(s) has(ve) to be removed. Are you sure you want to change the project type?

UserDocuments are not allowed in Standard EXE or ActiveX Control project types. Changing the Project Type will remove the UserDocuments from the project. Choose Yes to change the Project Type or No to cancel the change.


User Documents are not allowed in Standard EXE and User Control project types. Item(s) not loaded

UserDocuments are not allowed in Standard EXE or ActiveX Control project types. The items won't be loaded.


Non-intrinsic OLE drag and drop formats used with SetData require Byte array data. GetData may return more bytes than were given to SetData (Error 675)

You specified a non-intrinsic data format in the SetData method but didn't pass the data in a byte array. Make sure to pass data to the SetData method in a byte array.

When retrieving the data, GetData may return more bytes (depending on the operating system) than were actually passed in with SetData. The target should expect this and interpret the data in a meaningful way.


Can't create a UserControl instance on its own designer

You are not allowed to have an instance of a UserControl on its own designer.

For example, if you create a UserControl, copy it to the Clipboard, then open the controls designer and paste the control onto it, you get this error.


String value too long to process; form load aborted

A string embedded in the form being loaded was too long to process.


The project file 'item' is corrupt, and can't be loaded

Visual Basic cannot read the project file. This can occur if the file has been modified by an editor outside of Visual Basic. To fix the problem, undo any changes that were made to the file.


Version number missing or invalid; Visual Basic 98 assumed

Either the version signature was not found, or the specified version isn't recognized. Make sure that the first line is not blank or a comment. It should read VERSION 98 in the ASCII form.


The interactive user must have power user or administrator privileges

In order to work correctly, the interactive user must have Power User or Administrator privileges on the system.


< > already exists and cannot be temporarily renamed for the run to occur due to a file system error

When a WebClass is run from the Visual Basic IDE, an .Asp is generated for that WebClass. If an .Asp of the same name already exists, it is backed up before the WebClass is run and restored after the WebClass runs. An error has occurred backing up the existing .Asp.


Cannot set NextItem to the current WebItem from its Respond event (3009)

Cannot set NextItem to the current WebItem from its Respond event (9013)

You have attempted to set the NextItem property to the current WebItem from within its own Respond event handler, which would cause an infinite loop, as setting NextItem causes Respond to be called.


Cannot identify version of Internet Information Service or Peer Web Services (3012)

Cannot identify version of Internet Information Service or Peer Web Services (9015)

The version of Internet Information Service or Peer Web Services cannot be identified. You should re-install IIS or PWS.


The attribute <attribute name> for the tag <tag name> was connectedto an event. The HTML template <file name> for <template name> nolonger contains that connection. The attribute will not be marked asconnected in the WebClass. If you wrote any code

The attribute <attribute name> for the tag <tag name> was connected to an event. The HTML template <file name> for <template name> no longer contains that connection. The attribute will not be marked as connected in the WebClass. If you wrote any code in the event handler, it will remain part of your project

This error message appears after a template loads if connected tags or attributes have been deleted from the HTML file.


<file name> already exists. Do you want to replace it?

A name you selected for a template file is already used by another file. You can choose whether or not to replace it. If you choose not to replace it, you are prompted to enter a new file name.


You must install Internet Explorer in order to run the WebClass Designer

The WebClass Designer requires Internet Explorer (version 3.x or 4.x) to run. Before loading a template, Visual Basic checks whether Internet Explorer is installed. If it is not detected, the result is this error message.


An internal error occurred while loading the HTML template file <filename> for <template name>

This error occurs when, during the loading of a template, an error is received from a component external to Visual Basic.

If this error occurs, you should attempt to narrow down a reproducible scenario and contact Microsoft Technical Support.


Invalid MTXEX.DLL. GetContextObject not exported

The current version of the MTXEX.DLL file on your system is invalid. Please update to IIS version 4 or later and attempt the operation again.


MTXEX.DLL is not installed

The MTXEX.DLL file must be installed for this process to work correctly.


Internet Information Server or Peer Web Services version 3.0 or later must be installed to run WebClasses

You should install either Internet Information Server or Peer Web Services version 3.0 in order to run WebClasses.


Loading the HTML template <filename> for <template name> is taking an unusually long time. Would you like to continue loading the template?

If the loading of an HTML template takes longer than a few minutes, there may be a problem with the template file, unless the file is unusually large or the system it is running on is particularly slow.


The following HTML tag is bound to a WebItem that does not exist. It will be unbound

The following HTML tag is connected to a WebItem that does not exist. It will be disconnected

The HTML tag is connected to a WebItem that does not exist, so it will be disconnected.

This error can occur if the target WebItem was removed from the project, or if the WebItem was connected using manual notation and there is an error in the WebItem name.


Changing the value of this property will cause the WebClass designer to update all URLs within all templates of this WebClass

Changing the value of this property causes the WebClass designer to automatically load all the templates contained within this WebClass and regenerate the URLs of tags connected to this WebClass.


An error occurred while updating the URLs in the template, <filename>. You must edit the template manually and update the necessary tag attributes

An error occurred while updating the URLs of the specified template. You should open the HTML template in an editor and ensure each HTML tag attribute connected to the WebClass has the correct URL.


Project is located on a network drive. Please associate a virtual root with the project directory in <IIS Service Manager><PWS Service Manager> and run the project again

A virtual root is required to run the project and the virtual root cannot be located on a network drive. Please associate a virtual root with the project directory in either IIS Service Manager or PWS Service Manager and then run the project again.

For more information, see "Debugging Your IIS Application" in "Building Internet Applications" in the Component Tools Guide.


WebClass Manager was not installed correctly (3001)

WebClass runtime component is not installed correctly (9004)

The WebClass run-time component is not installed correctly. Uninstall the WebClass run-time and then re-install it to ensure that it is installed correctly.


No ActiveX Designer Support in Control Creation Edition of Visual Basic

The Visual Basic Control Creation Edition does not support ActiveX designers. To use ActiveX designers, purchase the full version of Visual Basic.


No Exe Compilation in Control Creation Edition of Visual Basic

The Visual Basic Control Creation Edition does not support the compilation of Exe files. To use this feature, purchase the full version of Visual Basic.


No Data Control Support in Control Creation Edition of Visual Basic

The Visual Basic Control Creation Edition does not support the Data control. To use the Data control, purchase the full version of Visual Basic.


No Document Object Support in Control Creation Edition of Visual Basic

The Visual Basic Control Creation Edition does not support Document objects. To use Document objects, purchase the full version of Visual Basic.


No /MakeDll command line option in Control Creation Edition of Visual Basic

The Visual Basic Control Creation Edition does not support the /MakeDll command-line option. To use this option, purchase the full version of Visual Basic.


Invalid Project Type Compilation for Control Creation Edition of Visual Basic

The Visual Basic Control Creation Edition does not support the type of project you have attempted to compile. To compile this type of project, purchase the full version of Visual Basic.


The wizard file 'item' is in an unknown format, and can't be loaded

This can occur if the version number or header in the .VBZ file is not correct. To correct this, for example, in Visual Basic 98, the version number should be VBWIZARD 6.X, where is X can be 0-9.


The wizard file 'item' is corrupt, and can't be loaded

A line in the .VBZ file is not in the format: <property>=<value>, the <value> string is too big (>260 chars), or <property> is not equal to Wizard or Param. This can occur if the .VBZ file was edited outside of Visual Basic.


Wrong version of run-time DLL

Visual Basic can't find MSVBVM60.DLL, or it is finding the wrong version of one or more of the ActiveX control .ocx files. Make sure your system contains only one copy of these files (the latest version) in your \SYSTEM or \SYSTEM32 directory.


Wrong OS or OS version for application. Looking for object with CLSID: |1.

Wrong OS or OS version for application. Looking for object with CLSID: <number>.

You are using an incompatible operating system or the wrong version of the operating system. Install a compatible operating system and try again.


Wrong version of operating system; requires Windows NT 4.0 (build 'item1' or above), or Windows 95 (build 'item2' or above)

To run this version of Visual Basic, you must be running the specified build of Windows 95 or Windows NT version 4.0, Service Pack 3 (SP3) or the specified build above.


You must install < > in order to run the WebClass designer

If your program manipulates either the Internet Information Server or Peer Web Server from the WebClass designer, you must install either IIS or PWS prior to running WebClass designer.


Your version (<version number>) of Internet Explorer is too old to be used with the WebClass Designer. Please install version <version number> or newer of Internet Explorer

The WebClass Designer requires the named version of Internet Explorer to run correctly.


Add Method (DEDesigner Extensibility)

Adds a member to a DECommands or DEConnections collection.

Syntax

object.Add(string, Boolean)

The Add property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string This specifies a unique name for the DEConnection or DECommand object.

Note If the name already exists in the collection, an error occurs and a DEConnection or DECommand object is not added.
Boolean | Optional. A Boolean expression that specifies whether the Command or Connection Properties dialog box displays after the object is added to the Data Environment.

Remarks

For the DEAggregates, DEGroupingFields, and DERelationConditions collections, the Boolean is not used. Thus, for these three collections, the Add method is the same as Visual Basic's Add method.


AddItem Method

Adds an item to a ListBox or ComboBox control or adds a row to a MS Flex Grid control. Doesn't support named arguments.

Syntax

object.AddItem item, index

The AddItem method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
item | Required. string expression specifying the item to add to the object. For the MS Flex Grid control only, use the tab character (character code 09) to separate multiple strings you want to insert into each column of a newly added row.
index | Optional. Integer specifying the position within the object where the new item or row is placed. For the first item in a ListBox or ComboBox control or for the first row in a MS Flex Grid control, index is 0.

Remarks

If you supply a valid value for index, item is placed at that position within the object. If index is omitted, item is added at the proper sorted position (if the Sorted property is set to True) or to the end of the list (if Sorted is set to False).

A ListBox or ComboBox control that is bound to a Data control doesn't support the AddItem method.


AddItem Method Example

This example uses the AddItem method to add 100 items to a list box. To try this example, paste the code into the Declarations section of a form with a ListBox control named List1, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Entry, I, Msg   ' Declare variables.
   Msg = "Choose OK to add 100 items to your list box."
   MsgBox Msg   ' Display message.
   For I = 1 To 100   ' Count from 1 to 100.
      Entry = "Entry " & I   ' Create entry.
      List1.AddItem Entry   ' Add the entry.
   Next I
   Msg = "Choose OK to remove every other entry."
   MsgBox Msg   ' Display message.
   For I = 1 To 50   ' Determine how to
      List1.RemoveItem I   ' remove every other
   Next I   ' item.
   Msg = "Choose OK to remove all items from the list box."
   MsgBox Msg   ' Display message.
   List1.Clear   ' Clear list box.
End Sub


Add Method

Add Method (Format Objects)

Adds a StdDataFormat object to a StdDataFormats collection.

Syntax

object.Add(dataformat, [index])

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
dataformat | Required. A string expression specifying the name of the object to add to the collection.
index | Optional. An integer that uniquely identifies a member of the collection.


Add Method (BindingCollection)

Adds a Binding object to the BindingCollection object.

Syntax

object.Add(object, PropertyName, DataField, DataFormat, Key)

The Add method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
object | Required. The control or other data consumer which will be bound.
PropertyName | Required. The property of the data consumer to which the data field will be bound.
DataField | Required. The column of the data source that will be bound to the property specified in the PropertyName argument.
DataFormat | Optional. A DataFormat object or a reference to a DataFormat variable that will be used to format the bound property.
Key | Optional. A unique string that identifies the member of the collection.

Remarks

The Binding object represents a property of an object bound to a data field of a data source. Use the BindingCollection object to bind a data source that has no design time interface, such as a Class configured as a data source, to a data consumer. You can also bind an OLE Simple Provider (OSP) data source to a data consumer using the Binding object.

You cannot use the Binding object to bind a complex bound control (such as the DataGrid control) to a data source. Instead, simply set the DataSource property of the control to the source.


Add Method (Controls Collection)

Adds a control to the Controls collection and returns a reference to the control.

Syntax

object.Add (ProgID, name, container)

The Add method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
ProgID | Required. A string that identifies the control. The ProgID of most controls can be determined by viewing the Object Browser. The ProgID is composed of the Library and Class of the control. For example, the CommandButton control's ProgID is VB.CommandButton. In cases where the ProgID differs from that shown in the Object Browser, Visual Basic displays an error message that contains the correct ProgId.
name | Required. A string that identifies the member of the collection.
container | Optional. An object reference that specifies a container of the control. If not specified or NULL, defaults to the container to which the Controls collection belongs. You can put a control in any existing container control (such as the Frame control) by specifying this argument. A user control or an ActiveX document can also be a container.

Remarks

Note The Controls collection is a late-bound collection. This means the compiler cannot determine in advance which controls are contained by the collection, their objects or their interfaces. Without this information, the Auto Statement Builder will not function.

This method allows you to add controls to an application at run time. Dynamic control addition can be used to add the functionality of a control to an application, even after the application has been compiled and deployed. For example, you may have several complex user controls, each suited to a different task. Depending on an external factor, such as time or date or user input, a different user control could be added to an existing form in an application. You can also use the container argument of the method to specify a container control (such as the Frame control) to position the control. Or you can design an application that automatically reads a file, database, or registry entry for new controls to load. In this way, you can modify an application without having to redeploy it.

Important When you add an unreferenced control that requires a license to an existing (deployed) application, you must also add the license key for the control before using the Add method. For information on when and how to add licenses, see "Licenses Collection" in the See Also list.

Adding Unreferenced Controls at Run Time

You can also use the Add method to dynamically add a control that is not referenced in the project. (An "unreferenced" control is a control that is not present in the Toolbox.) To do so, you must also add the control's License key to the Licenses collection as well. The example below adds a control's license key before adding the control itself:

Option Explicit
Private WithEvents extCtl As VBControlExtender

Private Sub Form_Load()
   Licenses.Add "prjWeeks.WeeksCtl", "xydsfasfjewfe"
   Set extCtl = Form1.Controls.Add("prjWeeks.WeeksCtl", "ctl1")
   extCtl.Visible = True ' The control is invisible by default.
End Sub

Note See Add Method (Licenses Collection) in the See Also list for more information about retrieving a control's license key.

In order to program the events of such an unreferenced control, however, you must declare an object variable using the WithEvents keyword as a VBControlExtender object (shown above), and set the object variable to the reference returned by the Add method. Then use the VBControlExtender object's ObjectEvent event to program the control's events. An abbreviated example is shown below.

Option Explicit
Dim WithEvents objExt As VBControlExtender ' Declare VBControlExtender variable

Private Sub LoadControl()
   Licenses.Add "Project1.Control1", "xydsfasfjewfe"
   Set objExt = Controls.Add("Project1.Control1", "myCtl")
   objExt.Visible = True
End Sub

Private Sub extObj_ObjectEvent(Info As EventInfo)
   ' Program the events of the control using Select Case.
   Select Case Info.Name
   Case "Click"
      ' Handle Click event here.
   ' Other cases now shown
   Case Else ' Unknown Event
      ' Handle unknown events here.
   End Select
End Sub

Note You can't assign an intrinsic control to the VBControlExtender variable; any attempt will result in a type mismatch error.

You can also program the events of a dynamically added control by declaring an object variable using the WithEvents keyword, and setting the reference returned by the method to the variable, as shown below:

Option Explicit
' Declare object variable as CommandButton.
Private WithEvents cmdObject As CommandButton

Private Sub Form_Load()
   Set cmdObject = Form1.Controls.Add("VB.CommandButton", "cmdOne")
   cmdObject.Visible = True
   cmdObject.Caption = "Dynamic CommandButton"
End Sub

Private Sub cmdObject_Click()
    Print "This is a dynamically added control"
End Sub

If you intend to add a user control or any ActiveX control to your form, you must either add the control to the Toolbox, or add its License key to the Licenses collection. See the Add Method (Licenses Collection) for more information.

Note If you add an ActiveX or user control to your project but don't use it on a form, you must also uncheck the Remove Information About Unused ActiveX Controls option on the Make tab of the Project Properties dialog box. If your application attempts to add the control, the Add method will fail because the necessary information has been discarded.

Removing Controls

To remove any controls added dynamically, use the Remove method. It should be noted that you can only remove controls added using the Add method (in contrast to controls added using the Load statement). The example below removes a dynamically added control:

Form1.Controls.Remove "ctl1" ' The control's name is ctl1.


Add Method (Controls Collection) Examples

Private Sub Form_Load()
   Form1.Controls.Add "VB.CommandButton", "cmdObj1", Frame1
   With Form1!cmdObj1
      .Visible = True
      .Width = 2000
      .Caption = "Dynamic Button"
   End With
End Sub

Note The code example above uses ! as a syntax element. You can also use standard collection syntax such as Form1.Controls("cmdObj1") to reference the control.

This second example declares an object variable of type CommandButton using the WithEvents keyword, allowing you to program the events of the control. The object variable is set to the reference returned by the Add method. To try the example, paste the code into the Declarations section and run the project.

Option Explicit
Private WithEvents btnObj As CommandButton

Private Sub btnObj_Click()
   MsgBox "This is a dynamically added button."
End Sub

Private Sub Form_Load()
   Set btnObj = Controls.Add("VB.CommandButton", "btnObj")
   With btnObj
      .Visible = True
      .Width = 2000
      .Caption = "Hello"
      .Top = 1000
      .Left = 1000
   End With
End Sub

The third example adds an unreferenced control to the Controls collection. To program such a control's events, however, you must declare an object variable of type VBControlExtender, and set the reference returned by the method to the object. Then program the control's events using the ObjectEvent event.

Option Explicit
Dim ctlExtender As VBControlExtender

Private Sub Form_Load()
   Set ctlExtender = Controls.Add("Project1.UserControl1", "MyControl")
   With ctlExtender
      .Visible = True
      .Top = 1000
      .Left = 1000
   End With
End Sub

Private Sub extObj_ObjectEvent(Info As EventInfo)
   ' Program the events of the control using Select Case.
   Select Case Info.Name
   Case "UserName"
      ' Check User name value.
      MsgBox Info.EventParameters("UserName").Value
   ' Other cases now shown
   Case Else ' Unknown Event
      ' Handle unknown events here.
   End Select
End Sub


Add Method (DataMembers Collection)

Adds a data member to the DataMembers Collection.

Syntax

object.Add (DataMember)

The Add method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
DataMember | Required. A unique string that can be used to identify a specific data member.

Remarks

A data member can be either ADO recordset, an object that implements the OLE Simple Provider (OSP) interface using the Implements statement with the OSP class, or an OLEDB provider created with Visual Basic.


Add Method (DataObjectFiles Collection)

Adds a filename to the Files collection of a DataObject object.

Syntax

object.Add (filename, [index])

The Add method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
filename | Required. A string that sets the name of the file.
index | Optional. An integer specifying where in the collection you want to insert the filename. If you don't specify an index value, the filename is added to the end of the collection.

Remarks

The Files collection can be filled only with filenames that are of type vbCFFiles (as found in the ClipBoardConstants list in the Object Browser). The DataObject object itself, however, can contain several different types of data. To retrieve a list of file names, iterate through the Files collection.


Add Method (ExportFormats Collection)

Adds an ExportFormat object to the ExportFormats collection and returns a reference to the newly created object.

Syntax

object.Add (Key, FormatType, FileFormatString, FileFilter, Template)

The Add method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
Key | Required. A unique string that identifies the member of the collection.
FormatType | Required. Sets the report type of the object, as shown in Settings.
FileFormatString | Required. Sets the text displayed in the Save As combo box of the Export dialog box.
FileFilter | Required. Sets the file extension to be used if the user selects the ExportFormat object in Export dialog box. If multiple file filters are used, the first becomes the default extension.
Template | Optional. Sets the template to be used for the report.

Settings

The settings for FormatType are:

Constant | Value | Description
rptFmtHTML | 0 | HTML
rptFmtText | 1 | Text
rptFmtUnicodeText | 2 | Unicode
rptFmtUnicodeHTML_UTF8 | 3 | HTML encoded using Universal Character Set (UTF – 8)

Return Type

ExportFormat object

Remarks

If you do not specify a Template, Visual Basic supplies a default template appropriate to the FormatType.


Add Method (Licenses Collection)

Adds a license to the Licenses collection and returns the license key.

Syntax

object.Add (ProgID, LicenseKey)

The Add method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
ProgID | Required. A string that specifies the control for which a license key will be added.
LicenseKey | Optional. A string that specifies the license key.

Remarks

Use the Add method whenever you want to dynamically add a control that requires a license key. For more information about controls that require license keys, see "Licensing Issues for Controls" in the See Also list.

When you compile a user control that requires a license key, and you want to dynamically add that control to an existing application, you must use the Add method for the Licenses collection in two different ways.

First, use the method to return the license key that is hard-coded into a user control. Second, use the method to add the same license key to the Licenses collection before adding the user control to the Controls collection.

In most cases, you will have to use the method in both ways in order to properly deploy a compiled user control. The steps for this are outlined below.

After you have compiled a user control that requires a license key, use the Add method to return the license key. Store that license key where it can be retrieved by the deployed application. For example, the example below writes the key to a file. You could also store it in a database, or in the Windows registry.

Private Sub GenerateLicenseKey()
   Dim intFile As Integer
   intFile = FreeFile
   ' Open a file to write the license key to.
   Open "c:\Temp\Ctl_Licenses.txt" For Output As #intFile
   Dim strLicense As String
   strLicense = Licenses.Add("prjWeeks.WeeksCtl")
   ' Write the license key to the file.
   Write #intFile, strLicense
   Close #intFile
End Sub

When you deploy your control, the deployed application adds the license key to the Licenses collection before adding the control to the Controls collection. (Of course, the control must have been installed on the machine as well.) The code example below adds the license key, then adds the control:

Option Explicit
Dim WithEvents extObj As VBControlExtender

Private Sub LoadDynamicControl()
   Dim intFile As Integer
   intFile = FreeFile
   Open "c:\Download\Ctl_Licenses.txt" For Input As #intFile
   Dim strKey As String
   ' On the client machine, read the license key from the file.
   Input #intFile, strKey
   Licenses.Add "prjWeeks.WeeksCtl", strKey
   Close #intFile
   Set extObj = Controls.Add("prjWeeks.WeeksCtl", "ctl1")
   With Controls("ctl1")
      .Visible = True
   End With
End Sub

When To Add a License Key

When you create a user control and you want to distribute the control for dynamic control addition, you must consider the following question: Does the user control contain only intrinsic controls? If the answer is yes, then ask, "Do I want to require that the end user have a license key in order to use the control?" If the answer to both questions is "yes," then be sure to check the Require License Key option on the General tab of the Project Properties dialog box.

Note Even if you clear the Require License Key option, a user control that contains third-party controls will still require a license key.

When No License Key Is Needed

There are two circumstances when you do not have to add a license key in order to add a control to the Controls collection:

  1. When the control is an intrinsic control and you have not checked the Require License Key option.

  2. When you add a control that is referenced in the project. In other words, if the control is present in the Toolbox.

Note When you do have a control in the Toolbox and you plan to add that control only at run time, be sure to clear the Remove Information About Unused ActiveX Controls option on the Make tab of the Project Properties dialog box; otherwise, trying to add the control will fail.


AddToAddInToolbar Method

Inserts a button on the Add-In toolbar which references an add-in or Wizard.

Syntax

object.AddToAddInToolbar (sfilename As String, sprogid As String, showontoolbar As Boolean, forceaddintoolbar As Boolean)

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
sfilename | Required. A string expression specifying the path to the add-in or Wizard and the name of its .Exe or .Dll file.
sprogid | Required. A string expression specifying the programmatic ID (ProgID) of the add-in or Wizard.
saddinname | Required. A string expression specifying the title of the add-in or Wizard.
showontoolbar | Required. A Boolean expression specifying whether the add-in or Wizard referred to will appear on the Add-In toolbar. True = yes, False = no.
forceaddintoolbar | Required. A Boolean expression specifying whether the Add-In toolbar is automatically displayed the next time Visual Basic is started. True = yes, False = no.


AddToAddInToolbar Method Example

This example uses the AddToAddInToolbar method to add a button to the Add-In toolbar for a fictitious add-in called MyAdd.Dll. Setting ForceAddInToolbar to True ensures that the Add-In toolbar is loaded the next time Visual Basic is started.

You could modify the following in a small Visual Basic application to serve as a Setup for your add-in.

Sub Main()
 dim x as Object
 Set x=CreateObject("AddInToolbar.Manager")
 x.AddToAddInToolbar sFileName:="C:\VB5\MyAdd.DLL", _
  sProgID:="MyAddIn.Connect", _
  sAddInName:="MyAddIn Title", _
  ShowOnToolBar:=True, _
  ForceAddInToolbar:=True
End Sub


Arrange Method

Arranges the windows or icons within an MDIForm object. Doesn't support named arguments.

Syntax

object.Arrange arrangement

The Arrange method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
arrangement | Required. A value or constant that specifies how to arrange windows or icons on an MDIForm object, as described in Settings.

Settings

The settings for arrangement are:

Constant | Value | Description
vbCascade | 0 | Cascades all nonminimized MDI child forms
vbTileHorizontal | 1 | Tiles all nonminimized MDI child forms horizontally
vbTileVertical | 2 | Tiles all nonminimized MDI child forms vertically
vbArrangeIcons | 3 | Arranges icons for minimized MDI child forms

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

Windows or icons are arranged even if the MDIForm object is minimized. Results are visible when the MDIForm is maximized.


Arrange Method Example

This example uses the Arrange method to arrange windows and icons in an MDI form. To try this example, paste the code into the Declarations section of an MDI form named MDIForm1 that has an MDI child form (named Form1, with its MDIChild property set to True) and a picture box on the MDI Form (named Picture1). Press F5 and click anywhere in the picture box to see the effects of the Arrange method.

Const FORMCOUNT = 5
Dim F(1 To FORMCOUNT) As New Form1
Private Sub MDIForm_Load ()
   Dim I   ' Declare local variable.
   Load Form1   ' Load original Form1.
   For I = 1 To FORMCOUNT
      F(I).Caption = "Form" & I + 1   ' Change caption on copies.
   Next I
End Sub

Private Sub Picture1_Click ()
   Static ClickCount   ' Declare variables.
   Dim I, PrevWidth, Start
   ClickCount = ClickCount + 1   ' Increment click counter.
   Select Case ClickCount
      Case 1
         MDIForm1.Arrange 1   ' Tile horizontally.
      Case 2
         MDIForm1.Arrange 2   ' Tile vertically.
      Case 3   ' Minimize each form.
         PrevWidth = MDIForm1.Width   ' Get MDI form width.
         MDIForm1.Width = PrevWidth / 2  ' Divide it in half.
         Form1.WindowState = 1   ' Minimize the original.
         For I = 1 To FORMCOUNT   ' Look at each instance of F.
            F(I).WindowState = 1   ' Minimize each copy of F.
         Next I
         Start = Timer
         Do
         Loop Until Timer = Start + 5
         MDIForm1.Width = PrevWidth   ' Resize to original size.
         MDIForm1.Arrange 3   ' Arrange icons.
   End Select
End Sub


AsyncRead Method

Initiates the asynchronous reading of data from a file or URL by a container, control, or ActiveX component.

Syntax

object.AsyncRead Target, AsyncType [, PropertyName], [AsyncReadOptions]

The AsyncRead method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
Target | A string expression specifying the location of the data. This can be a path or a URL.
AsyncType | An integer expression specifying how the data is presented, as described in Settings.
PropertyName | An optional string expression specifying the name of the property to be loaded. Required for differentiating between simultaneous downloads.
AsyncReadOptions | An optional string expression specifying additional options for AsyncRead as described in Settings.

Settings

The settings for AsyncType are:

Setting | Description
vbAsyncTypeFile | The data is provided in a file created by Visual Basic.
vbAsyncTypeByteArray | The data is provided as a byte array that contains the retrieved data. It is assumed that the component author knows how to handle the data.
vbAsyncTypePicture | The data is provided in a Picture object.

The settings for AsyncReadOptions are:

Constant | Setting | Description
vbAsyncReadSynchronousDownload | 1 | AsyncRead doesn't return until the AsyncReadComplete event has occurred.
vbAsyncReadOfflineOperation | 8 | AsyncRead uses only the locally cached resource.
vbAsyncReadForceUpdate | 16 | AsyncRead forces a download of the resource from the server, ignoring a locally cached copy.
vbAsyncReadResynchronize | 512 | AsyncRead updates the locally cached copy only if the server version is newer.
vbAsyncReadGetFromCacheIfNetFail | 524288 | AsyncRead uses the cached copy if the server connection is unsuccessful.

Remarks

The progress of a download that is requested by the AsyncRead method can be tracked by the AsyncReadProgress event. Once the data is available, the AsyncReadComplete event is raised in the object. The asynchronous read can be canceled before it is completed by calling the CancelAsyncRead method.

The PropertyName parameter is a tag, meaning that it can be any arbitrary string, since its only function is to act as an identifier for this particular data request. The value in PropertyName is used to identify the particular asynchronous read to cancel in the CancelAsyncRead method, and the value in PropertyName is also used to identify the particular asynchronous read that has completed in the AsyncReadComplete event. Only one AsyncRead event with a given PropertyName can be active at one time.

The AsyncRead method initiates an asynchronous download. The AsyncRead events fire synchronously (before this method returns) if the data is already available on the client machine. AsyncRead can raise some errors synchronously (such as "bad parameter", "unknown protocol", "UrlMon.dll missing", and so forth), so it's a good idea to have appropriate error handling code before calling AsyncRead. If the data is not available locally, then AsyncRead returns immediately and the AsyncRead events occur later.


BeginQueryEdit Method

Returns or sets the DECommand object which the Query designer will begin to edit.

Note The Data Environment designer cannot edit the DECommand object until the EndQueryEdit method is called.

Syntax

object.BeginQueryEdit

The BeginQueryEdit method syntax has one part:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.

Remarks

This property enables communication between Data View and the Data Environment designer.


CancelAsyncRead Method

Cancels an asynchronous data request.

Syntax

object.CancelAsyncRead [PropertyName]

The CancelAsyncRead method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
PropertyName | An optional string expression specifying the name of the asynchronous data request to cancel.

Remarks

Only the asynchronous data read request specified by PropertyName is canceled; all others continue normally.

The value in PropertyName specifies the particular asynchronous data read request to cancel, and should match the value given in a previous AsyncRead method invocation. If PropertyName is not given, then the last AsyncRead method invocation that did not give a PropertyName will be canceled.


CanPropertyChange Method

Asks the container if a property bound to a data source can have its value changed. The CanPropertyChange method is most useful if the property specified in PropertyName is bound to a data source.

Syntax

object.CanPropertyChange PropertyName

The CanPropertyChange method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
PropertyName | A string expression that represents a name of the property that the control is requesting to change.

Return values

The possible return values for CanPropertyChange are:

Setting | Description
True | The property specified in PropertyName can be changed at this time.
False | The property specified in PropertyName cannot be changed at this time; the container has the bound data table open as read only. Do not set the property value; doing so may cause errors in some control containers.

Remarks

The control should always call CanPropertyChange before changing the value of a property that can be data-bound.

Note At present, CanPropertyChange always returns True in Visual Basic, even if the bound field is read-only in the data source. Visual Basic doesn’t raise an error when the control attempts to change a read-only field; it just doesn’t update the data source.

As an example, the following code shows how the CanPropertyChange method is used:

Public Property Let Address(ByVal cValue As String)
   If CanPropertyChange("Address") Then
      m_Address = cValue
      PropertyChanged "Address"
   End If
End Property


Clear Method (Clipboard, ComboBox, ListBox)

Clears the contents of a ListBox, ComboBox, or the system Clipboard.

Syntax

object.Clear

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

A ListBox or ComboBox control bound to a Data control doesn't support the Clear method.


Clear Method (DataObject Object)

Deletes the contents of the DataObject object.

Syntax

object.Clear

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

This method is available only for component drag sources. If Clear is called from a component drop target, an error is generated.

Most components support manual OLE drag and drop events, and some support automatic OLE drag and drop events.


Clear Method

Clear Method (Format Objects)

Removes all objects in a collection.

Syntax

object.Clear

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

To remove only one object from a collection, use the Remove method.


Clear Method Example

This example uses the Clear method to clear all items from a list box. To try this example, paste the code into the Declarations section of a form with a ListBox control named List1, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Entry, I, Msg   ' Declare variables.
   Msg = "Choose OK to add 100 items to your list box."
   MsgBox Msg   ' Display message.
   For I = 1 To 100   ' Count from 1 to 100.
      Entry = "Entry " & I   ' Create entry.
      List1.AddItem Entry   ' Add the entry.
   Next I
   Msg = "Choose OK to remove every other entry."
   MsgBox Msg   ' Display message.
   For I = 1 To 50   ' Determine how to
      List1.RemoveItem I   ' remove every other
   Next I   ' item.
   Msg = "Choose OK to remove all items from the list box."
   MsgBox Msg   ' Display message.
   List1.Clear   ' Clear list box.
End Sub

This example uses the Clear method to clear the Clipboard object. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Const CF_BITMAP = 2   ' Define bitmap format.
   Dim Msg   ' Declare variable.
   On Error Resume Next   ' Set up error handling.
   Msg = "Choose OK to load a bitmap onto the Clipboard."
   MsgBox Msg   ' Display message.
   Clipboard.Clear   ' Clear Clipboard.
   Clipboard.SetData LoadPicture("PAPER.BMP")  ' Get bitmap.
   If Err Then
      Msg = "Can't find the .BMP file."
      MsgBox Msg   ' Display error message.
      Exit Sub
   End If
   Msg = "A bitmap is now on the Clipboard. Choose OK to copy "
   Msg = Msg & "the bitmap from the Clipboard to the form."
   MsgBox Msg   ' Display message.
   Picture = Clipboard.GetData()   ' Copy from Clipboard.
   Msg = "Choose OK to clear the picture."
   MsgBox Msg   ' Display message.
   Picture = LoadPicture()   ' Clear picture.
End Sub


Close Method (OLE Container)

Closes an object and terminates the connection to the application that provided the object.

Syntax

object.Close

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

This method applies only to embedded objects and is equivalent to closing the object. It has no effect on linked objects.


Cls Method

Clears graphics and text generated at run time from a Form or PictureBox.

Syntax

object.Cls

The object placeholder represents an object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with the focus is assumed to be object.

Remarks

Cls clears text and graphics generated at run time by graphics and printing statements. Background bitmaps set using the Picture property and controls placed on a Form at design time aren't affected by Cls. Graphics and text placed on a Form or PictureBox while the AutoRedraw property is set to True aren't affected if AutoRedraw is set to False before Cls is invoked. That is, you can maintain text and graphics on a Form or PictureBox by manipulating the AutoRedraw property of the object you're working with.

After Cls is invoked, the CurrentX and CurrentY properties of object are reset to 0.


Cls Method Example

This example uses the Cls method to delete printed information from a form. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Msg   ' Declare variable.
   AutoRedraw = -1   ' Turn on AutoRedraw.
   ForeColor = QBColor(15)   ' Set foreground to white.
   BackColor = QBColor(1)    ' Set background to blue.
   FillStyle = 7   ' Set diagonal crosshatch.
   Line (0, 0)-(ScaleWidth, ScaleHeight), , B  ' Put box on form.
   Msg = "This is information printed on the form background."
   CurrentX = ScaleWidth / 2 - TextWidth(Msg) / 2  ' Set X position.
   CurrentY = 2 * TextHeight(Msg)   ' Set Y position.
   Print Msg   ' Print message to form.
   Msg = "Choose OK to clear the information and background "
   Msg = Msg & "pattern just displayed on the form."
   MsgBox Msg   ' Display message.
   Cls   ' Clear form background.
End Sub


Copy Method (OLE Container Control)

Copies the object within an OLE container control to the system Clipboard.

Syntax

object.Copy

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

When you copy an object onto the system Clipboard, all the data and link information associated with the object is placed on the system Clipboard. You can copy both linked and embedded objects onto the system Clipboard.

You can use this method to support an Edit Copy command on a menu.


CreateEmbed Method

Creates an embedded object. Doesn't support named arguments.

Syntax

object.CreateEmbed sourcedoc, class

The CreateEmbed method syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Sourcedoc | Required. The filename of a document used as a template for the embedded object. Must be a zero-length string ("") if you don't specify a source document.
Class | Optional. The name of the class of the embedded object. Ignored if you specify a filename for sourcedoc.

Remarks

To view a list of valid class names available on your system, select a control, such as the OLE container control, select the Class property in the Properties window, and then click the builder button.

Note You don't need to set the Class and SourceDoc properties when using the CreateEmbed method to create an embedded object.

When you create a new object, the application associated with the class name (for example, Excel.exe) must be correctly registered with the operating system. (The application setup program should register the application correctly.)


CreateLink Method

Creates a linked object from the contents of a file. Doesn't support named arguments.

Syntax

object.CreateLink sourcedoc, sourceitem

The CreateLink method syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Sourcedoc | Required. The file from which the object is created.
Sourceitem | Optional. The data within the file to be linked in the linked object.

Remarks

If you specify values for the arguments of this method, those values override the settings of the SourceDoc and SourceItem properties. Those properties are updated to reflect the argument values when the method is invoked.

When an object is created with this method, the OLE container control displays an image of the file specified by the SourceDoc property. If the object is saved, only the link references are saved because the OLE container control contains only a metafile image of the data and no actual source data.

When you create a new object, the application associated with the class name (for example, Excel.exe) must be correctly registered with the operating system. (The application setup program should register the application correctly.)


DataMemberChanged Method

Notifies data consumers that a data member of a data source has changed.

Syntax

Object.DataMemberChanged DataMember

The DataMemberChanged method has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
DataMember | A string specifying a member of the DataMembers collection of a data source object

Remarks

The DataMemberChanged method is only available when an object's DataSourceBehavior property is set to vbDataSource.


Delete Method (OLE Container)

Deletes the specified object and frees the memory associated with it.

Syntax

object.Delete

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

This method enables you to explicitly delete an object. Objects are automatically deleted when a form is closed or when the object is replaced with a new object.


DoVerb Method

Opens an object for an operation, such as editing. Doesn't support named arguments.

Syntax

object.DoVerb (verb)

The DoVerb method syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Verb | Optional. The verb to execute of the object within the OLE container control. If not specified, the default verb is executed. The value of this argument can be one of the standard verbs supported by all objects or an index of the ObjectVerbs property array.

Remarks

If you set the AutoActivate property to 2 (Double-Click), the OLE container control automatically activates the current object when the user double-clicks the control.

Each object can support its own set of verbs. The following values represent standard verbs every object should support:

Constant | Value | Description
VbOLEPrimary | 0 | The default action for the object.
VbOLEShow | -1 | Activates the object for editing. If the application that created the object supports in-place activation, the object is activated within the OLE container control.
VbOLEOpen | -2 | Opens the object in a separate application window. If the application that created the object supports in-place activation, the object is activated in its own window.
VbOLEHide | -3 | For embedded objects, hides the application that created the object.
VbOLEUIActivate | -4 | If the object supports in-place activation, activates the object for in-place activation and shows any user interface tools. If the object doesn't support in-place activation, the object doesn't activate, and an error occurs.
VbOLEInPlaceActivate | -5 | If the user moves the focus to the OLE container control, creates a window for the object and prepares the object to be edited. An error occurs if the object doesn't support activation on a single mouse click.
VbOLEDiscardUndoState | -6 | Used when the object is activated for editing to discard all record of changes that the object's application can undo.

Note These verbs may not be listed in the ObjectVerbs property array.


Drag Method

Begins, ends, or cancels a drag operation of any control except the Line, Menu, Shape, Timer, or CommonDialog controls. Doesn't support named arguments.

Syntax

object.Drag action

The Drag method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list. If object is omitted, the object whose event procedure contains the Drag method is assumed.
action | Optional. A constant or value that specifies the action to perform, as described in Settings. If action is omitted, the default is to begin dragging the object.

Settings

The settings for action are:

Constant | Value | Description
vbCancel | 0 | Cancels drag operation
vbBeginDrag | 1 | Begins dragging object
vbEndDrag | 2 | Ends dragging and drop object

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

Using the Drag method to control a drag-and-drop operation is required only when the DragMode property of the object is set to Manual (0). However, you can use Drag on an object whose DragMode property is set to Automatic (1 or vbAutomatic).

If you want the mouse pointer to change shape while the object is being dragged, use either the DragIcon or MousePointer property. The MousePointer property is only used if no DragIcon is specified.

The Drag method generally acts synchronously, meaning that subsequent statements aren't executed until the drag action is complete. It can, however, act asynchronously if the DragMode property for the control is set to Manual (0 or vbManual).


Drag Method Example

This example uses the Drag method to drag the filename of a bitmap (.bmp) file to a picture box where the bitmap is displayed. To try this example, paste all of the code into the Declarations section of a form that contains DriveListBox, DirListBox, FileListBox, PictureBox, and Label controls. Use the default names for all of the controls. Size and position all controls so they can be easily seen and used. The size and position of the label is unimportant because it's changed at run time. When the program begins, you can browse your file system and load any bitmaps. Once you've located a bitmap that you want to display, click the filename of that bitmap, and drag it to the picture box.

Private Sub Form_Load ()
   Picture1.AutoSize = -1   ' Turn on AutoSize.
   Label1.Visible = 0   ' Make the label invisible.
   File1.Pattern = "*.BMP; *.ICO; *.WMF"   ' Set file patterns.
End Sub

Private Sub Dir1_Change ()   ' Any change in Dir1
   File1.Path = Dir1.Path   ' is reflected in File1.
End Sub

Private Sub Drive1_Change ()   ' Any change in Drive1
   Dir1.Path = Drive1.Drive   ' is reflected in Dir1.
End Sub

Private Sub File1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
   Dim DY   ' Declare variable.
   DY = TextHeight("A")   ' Get height of one line.
   Label1.Move File1.Left, File1.Top + Y - DY /2, File1.Width, DY
   Label1.Drag   ' Drag label outline.
End Sub

Private Sub Dir1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
   ' Change pointer to no drop.
   If State = 0 Then Source.MousePointer = 12
   ' Use default mouse pointer.
   If State = 1 Then Source.MousePointer = 0
End Sub

Private Sub Drive1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
   ' Change pointer to no drop.
   If State = 0 Then Source.MousePointer = 12
   ' Use default mouse pointer.
   If State = 1 Then Source.MousePointer = 0
End Sub

Private Sub Form_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
   ' Change pointer to no drop.
   If State = 0 Then Source.MousePointer = 12
   ' Use default mouse pointer.
   If State = 1 Then Source.MousePointer = 0
End Sub

Private Sub File1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
   On Error Resume Next
   If State = 0 And Right$(File1.Filename,4) = ".ICO" Then
      Label1.DragIcon = LoadPicture(File1.Path + "\" + File1.Filename)
   If Err Then MsgBox "The icon file can't be loaded."
   ElseIf State = 1 Then
      Label1.DragIcon = LoadPicture ()   ' Use no drag icon.
   End If
End Sub

Private Sub Picture1_DragDrop (Source As Control, X As Single, Y As Single)
   On Error Resume Next
   Picture1.Picture = LoadPicture(File1.Path + "\" + File1.Filename)
   If Err Then MsgBox "The picture file can't be loaded."
End Sub


EndDoc Method

Terminates a print operation sent to the Printer object, releasing the document to the print device or spooler.

Syntax

object.EndDoc

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

If EndDoc is invoked immediately after the NewPage method, no additional blank page is printed.


EndDoc Method Example

This example uses the EndDoc method to end a document after printing two pages, each with a centered line of text indicating the page number. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim HWidth, HHeight, I, Msg   ' Declare variables.
   On Error GoTo ErrorHandler   ' Set up error handler.
   Msg = "This is printed on page"
   For I = 1 To 2   ' Set up two iterations.
      HWidth = Printer.TextWidth(Msg) / 2   ' Get half width.
      HHeight = Printer.TextHeight(Msg) /2   ' Get half height.
      Printer.CurrentX = Printer.ScaleWidth / 2 - HWidth
      Printer.CurrentY = Printer.ScaleHeight / 2 - HHeight
      Printer.Print Msg & Printer.Page & "."   ' Print.
      Printer.NewPage   ' Send new page.
   Next I
   Printer.EndDoc   ' Printing is finished.
   Msg = "Two pages, each with a single, centered line of text, "
   Msg = Msg & "have been sent to your printer."
   MsgBox Msg   ' Display message.
   Exit Sub
ErrorHandler:
   MsgBox "There was a problem printing to your printer."
   Exit Sub
End Sub


EndQueryEdit Method

Returns or sets a DECommand object which the query edit has completed editing.

Syntax

object.EndQueryEdit

The EndQueryEdit method syntax has one part:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.

Remarks

This property enables communication between Data View and the Data Environment designer.


ExportReport Method

Exports the text of a report to a file using a specified ExportFormat object. Images and shapes cannot be exported.

Syntax

object.ExportReport(ExportFormat, filename, Overwrite, ShowDialog, Range, PageFrom, PageTo)

The ExportReport method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
ExportFormat Optional. The ExportFormat object to be used. The argument can be an object reference, or a string key that specifies one of the members of the ExportFormats collection as shown in Settings.

If not specified, the Export dialog box will display.
filename | Optional. A string expression that evaluates to the name of the file. If not specified, the Export dialog box will display.
overwrite | Optional. A boolean expression that determines if the file will be overwritten.
showDialog | Optional. A boolean expression that determines if the Save As dialog box will be displayed. If no ExportFormat object or filename is specified, the Export dialog box will be displayed, even if this argument is set to False.
Range | Optional. Sets an integer that determines if all the pages in the report will be executed, or a range of pages, as shown in Settings.
PageFrom | Optional. A numeric expression that specifies the page where the export will start.
PageTo | Optional. A numeric expression that specifies the page where the export will end.

Settings

The settings for ExportFormat are:

Constant | Value | Description
rptKeyHTML | key_def_HTML | Specifies the HTML default member of the ExportFormats collection.
rptKeyUnicodeHTML | key_def_UnicodeHTML_UTF8 | Specifies the Unicode HTML default member of the ExportFormats collection
rptKeyText | key_def_Text | Specifies the text default member of the ExportFormats collection
rptKeyUnicodeText | key_def_UnicodeText | Specifies the Unicode text default member of the ExportFormats collection

When adding an ExportFormat object to the ExportFormats collection, you must specify a Key for the object. That key can be used in the ExportFormat argument.

The settings for Range are:

Constant | Value | Description
rptRangeAllPages | 0 | (Default) All pages will be printed.
rptRangeFromTo | 1 | Only the specified range of pages will be exported.

Return Value

Long

Remarks

If all necessary arguments are not supplied with the method, a dialog box is displayed, prompting the user for appropriate information (such as filename).

The ExportReport method performs an asynchronous operation. The method returns the identifier of the "cookie" that identifies the asynchronous operation.

Important The range of pages specified will not match the pages seen in the Print Preview mode. Whereas export page numbers are based on font attributes of the ExportFormat object's ExportType property, print and preview pages are based on the current printer object used by the computer.


ExportReport Method Example

The first example uses the ExportReport method to display the Export dialog box. The second example exports the file without displaying the Export dialog box. The third example specifies an ExportFormat object to use when exporting the report.

Private Sub ExportTheReport()
   DataReport1.ExportReport , , True, True
End Sub

Private Sub ExportWithoutDialog()
   ' Export to a file named Output.htm, overwriting if needed.
   DataReport1.ExportReport rptKeyHTML, "C:\Temp\Output", True, False
End Sub

Private Sub ExportMyReport()
   ' Export to a file named Daily.htm using the MyReport ExportFormat.
   DataReport1.ExportReport "MyReport", "C:\Temp\Daily", True, False
End Sub


FetchVerbs Method

Updates the list of verbs an object supports.

Syntax

object.FetchVerbs

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

You can read the updated list of verbs using the ObjectVerbs property.


Files Method

Returns a collection of filenames used by the vbCFFiles format (a DataObjectFiles collection) which in turn contains a list of all filenames used by a DataObject object; for example, the names of files that a user drags to or from the Windows File Explorer.

Syntax

object.Files(index)

The Files collection syntax has these parts:

Part | Description
object | An object expression that evaluates to a DataObject object.
index | An integer which is an index to an array of filenames.

Remarks

The Files collection is filled with filenames only when the DataObject object contains data of type vbCFFiles. The DataObject object can contain several different types of data. You can iterate through the collection to retrieve the list of file names.

The Files collection can be filled to allow Visual Basic applications to act as a drag source for a list of files.


GetData Method

Returns a graphic from the Clipboard object. Doesn't support named arguments.

Syntax

object.GetData (format)

The GetData method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
format | Optional. A constant or value that specifies the Clipboard graphics format, as described in Settings. Parentheses must enclose the constant or value. If format is 0 or omitted, GetData automatically uses the appropriate format.

Settings

The settings for format are:

Constant | Value | Description
vbCFBitmap | 2 | Bitmap (.bmp files)
vbCFMetafile | 3 | Metafile (.wmf files)
vbCFDIB | 8 | Device-independent bitmap (DIB)
vbCFPalette | 9 | Color palette

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

If no graphic on the Clipboard object matches the expected format, nothing is returned. If only a color palette is present on the Clipboard object, a minimum size (1 x 1) DIB is created.


GetData Method (DataObject Object)

Returns data from a DataObject object in the form of a variant.

Syntax

object.GetData (format)

The GetData method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
format | A constant or value that specifies the data format, as described in Settings. Parentheses must enclose the constant or value. If format is 0 or omitted, GetData automatically uses the appropriate format.

Settings

The settings for format are:

Constant | Value | Description
vbCFText | 1 | Text (.txt files)
vbCFBitmap | 2 | Bitmap (.bmp files)
vbCFMetafile | 3 | metafile (.wmf files)
vbCFEMetafile | 14 | Enhanced metafile (.emf files)
vbCFDIB | 8 | Device-independent bitmap (DIB)
vbCFPalette | 9 | Color palette
vbCFFiles | 15 | List of files
vbCFRTF | -16639 | Rich text format (.rtf files)

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

It's possible for the GetData and SetData methods to use data formats other than those listed in Settings, including user-defined formats registered with Windows via the RegisterClipboardFormat() API function. However, there are a few caveats:

  • The SetData method requires the data to be in the form of a byte array when it does not recognize the data format specified.

  • The GetData method always returns data in a byte array when it is in a format that it doesn't recognize, although Visual Basic can transparently convert this returned byte array into other data types, such as strings.

  • The byte array returned by GetData will be larger than the actual data when running on some operating systems, with arbitrary bytes at the end of the array. The reason for this is that Visual Basic does not know the data's format, and knows only the amount of memory that the operating system has allocated for the data. This allocation of memory is often larger than is actually required for the data. Therefore, there may be extraneous bytes near the end of the allocated memory segment. As a result, you must use appropriate functions to interpret the returned data in a meaningful way (such as truncating a string at a particular length with the Left function if the data is in a text format).

Note Not all applications support vbcfBitmap or vbCFPalette, so it is recommended that you use vbCFDIB whenever possible.


GetData Method Example

This example uses the GetData method to copy a bitmap from the Clipboard object to a form. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Const CF_BITMAP = 2   ' Define bitmap format.
   Dim Msg   ' Declare variable.
   On Error Resume Next   ' Set up error handling.
   Msg = "Choose OK to load a bitmap onto the Clipboard."
   MsgBox Msg   ' Display message.
   Clipboard.Clear   ' Clear Clipboard.
   Clipboard.SetData LoadPicture("PAPER.BMP")  ' Get bitmap.
   If Err Then
      Msg = "Can't find the .bmp file."
      MsgBox Msg   ' Display error message.
      Exit Sub
   End If
   Msg = "A bitmap is now on the Clipboard. Choose OK to copy "
   Msg = Msg & "the bitmap from the Clipboard to the form "
   MsgBox Msg   ' Display message.
   Picture = Clipboard.GetData()   ' Copy from Clipboard.
   Msg = "Choose OK to clear the form."
   MsgBox Msg   ' Display message.
   Picture = LoadPicture()   ' Clear form.
End Sub


GetFormat Method

Returns an integer indicating whether an item on the Clipboard object matches a specified format. Doesn't support named arguments.

Syntax

object.GetFormat (format)

The GetFormat method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
format | Required. A value or constant that specifies the Clipboard object format, as described in Settings. Parentheses must enclose the constant or value.

Settings

The settings for format are:

Constant | Value | Description
vbCFLink | &HBF00 | DDE conversation information
vbCFText | 1 | Text
vbCFBitmap | 2 | Bitmap (.bmp files)
vbCFMetafile | 3 | Metafile (.wmf files)
vbCFDIB | 8 | Device-independent bitmap (DIB)
vbCFPalette | 9 | Color palette

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

The GetFormat method returns True if an item on the Clipboard object matches the specified format. Otherwise, it returns False.

For vbCFDIB and vbCFBitmap formats, whatever color palette is on the Clipboard is used when the graphic is displayed.


GetFormat Method (DataObject Object)

Returns an boolean value indicating whether an item in the DataObject object matches a specified format. Doesn't support named arguments.

Syntax

object.GetFormat format

The GetFormat method syntax has these parts:

Part | Description
Object | Required. An object expression that evaluates to an object in the Applies To list.
Format | A constant or value that specifies the data format, as described in Settings.

Settings

The settings for format are:

Constant | Value | Description
VbCFText | 1 | Text (.txt files)
VbCFBitmap | 2 | Bitmap (.bmp files)
VbCFMetafile | 3 | metafile (.wmf files)
VbCFEMetafile | 14 | Enhanced metafile (.emf files)
VbCFDIB | 8 | Device-independent bitmap (DIB)
VbCFPalette | 9 | Color palette
VbCFFiles | 15 | List of files
VbCFRTF | -16639 | Rich text format (.rtf files)

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

The GetFormat method returns True if an item in the DataObject object matches the specified format. Otherwise, it returns False.


GetFormat Method Example

This example uses the GetFormat method to determine the format of the data on the Clipboard object. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   ' Define bitmap formats.
   Dim ClpFmt, Msg   ' Declare variables.
   On Error Resume Next   ' Set up error handling.
   If Clipboard.GetFormat(vbCFText) Then ClpFmt = ClpFmt + 1
   If Clipboard.GetFormat(vbCFBitmap) Then ClpFmt = ClpFmt + 2
   If Clipboard.GetFormat(vbCFDIB) Then ClpFmt = ClpFmt + 4
   If Clipboard.GetFormat(vbCFRTF) Then ClpFmt = ClpFmt + 8
   Select Case ClpFmt
      Case 1
         Msg = "The Clipboard contains only text."
      Case 2, 4, 6
         Msg = "The Clipboard contains only a bitmap."
      Case 3, 5, 7
         Msg = "The Clipboard contains text and a bitmap."
      Case 8, 9
         Msg = "The Clipboard contains only rich text."
      Case Else
         Msg = "There is nothing on the Clipboard."
   End Select
   MsgBox Msg   ' Display message.
End Sub


GetText Method

Returns a text string from the Clipboard object. Doesn't support named arguments.

Syntax

object.GetText (format)

The GetText method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
format | Optional. A value or constant that specifies the Clipboard object format, as described in Settings. Parentheses must enclose the constant or value.

Settings

The settings for format are:

Constant | Value | Description
vbCFLink | &HBF00 | DDE conversation information
vbCFText | 1 | (Default) Text
vbCFRTF | &HBF01 | Rich Text Format (.rtf file)

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

If no text string on the Clipboard object matches the expected format, a zero-length string ("") is returned.


GetText Method Example

This example uses the GetText method to copy a text string from the Clipboard object to a string variable. To try this example, paste the code into the Declarations section of a form with a TextBox control named Text1, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim I, Msg, Temp   ' Declare variables.
   On Error Resume Next   ' Set up error handling.
   Msg = "Type anything you like into the text box below."
   Text1.Text = InputBox(Msg)  ' Get text from user.
   Msg = "Choose OK to copy the contents of the text box "
   Msg = Msg & "to the Clipboard."
   MsgBox Msg   ' Display message.
   Clipboard.Clear   ' Clear Clipboard.
   Clipboard.SetText Text1.Text  ' Put text on Clipboard.
   If Clipboard.GetFormat(vbCFText) Then
      Text1.Text = ""   ' Clear the text box.
      Msg = "The text is now on the Clipboard. Choose OK "
      Msg = Msg & "to copy the text from the Clipboard back "
      Msg = Msg & "to the text box."
      MsgBox Msg   ' Display message.
      Temp = Clipboard.GetText(vbCFText)   ' Get Clipboard text.
      For I = Len(Temp) To 1 Step -1   ' Reverse the text.
         Text1.Text = Text1.Text & Mid(Temp, I, 1)
      Next I
   Else
      Msg = "There is no text on the Clipboard."
      MsgBox Msg   ' Display error message.
   End If
End Sub


GoBack Method

Execute a hyperlink jump back in the history list.

Syntax

object.GoBack

The GoBack method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

If the object is in a container that supports OLE hyperlinking, then the container will jump to the location that is back in the history list. If the object is in a container that does not support OLE hyperlinking, then this method will raise an error.


GoForward Method

Execute a hyperlink jump forward in the history list.

Syntax

object.GoForward

The GoForward method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

If the object is in a container that supports OLE hyperlinking, then the container will jump to the location that is forward in the history list. If the object is in a container that does not support OLE hyperlinking, then this method will raise an error.


Hide Method

Hides an MDIForm or Form object but doesn't unload it.

Syntax

object.Hide

The object placeholder represents an object expression that evaluates to an object in the Applies To list. If object is omitted, the form with the focus is assumed to be object.

Remarks

When a form is hidden, it's removed from the screen and its Visible property is set to False. A hidden form's controls aren't accessible to the user, but they are available to the running Visual Basic application, to other processes that may be communicating with the application through DDE, and to Timer control events.

When a form is hidden, the user can't interact with the application until all code in the event procedure that caused the form to be hidden has finished executing.

If the form isn't loaded when the Hide method is invoked, the Hide method loads the form but doesn't display it.

Note When closing a modal form that has been opened from another modal form, the following code worked in previous versions of Visual Basic:

Me.Hide
Me.Hide ' This now causes an error.

In current versions of Visual Basic, this code now fails on the second Me.Hide. You can substitute Me.Hide with Me.Visible = False as shown below:

Me.Visible = False
Me.Visible = False ' No error occurs.


Hide Method Example

This example uses the Hide method to hide a form. To try this example, paste the code into the Declarations section of a non-MDI form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Msg   ' Declare variable.
   Hide   ' Hide form.
   Msg = "Choose OK to make the form reappear."
   MsgBox Msg   ' Display message.
   Show   ' Show form again.
End Sub


Insert Method

Inserts an existing ExportFormat object into the ExportFormats collection.

Syntax

object.Insert format

The Insert method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
format | The ExportFormat object to insert.


Insert Method, FileFilter, FileFormatString Property Example

The example creates a new ExportFormat object and inserts it into the ExportFormats collection.

Dim exfSpecial As New ExportFormat
With exfSpecial
   .FileFormatString = "Special Report (*.txt)"
   .FileFilter = "*.txt"
   .FormatType = rptFmtText
   .Key = "Special"
   .Template = "Special Report" & vbCrLf & rptTagBody
End With

With DataReport1
   .ExportFormats.Insert exfSpecial
   .ExportReport "Special"
End With


KillDoc Method

Immediately terminates the current print job.

Syntax

object.KillDoc

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

If the operating system's Print Manager is handling the print job (the Print Manager is running and has background printing enabled), KillDoc deletes the current print job and the printer receives nothing.

If Print Manager isn't handling the print job (background printing isn't enabled), some or all of the data may be sent to the printer before KillDoc can take effect. In this case, the printer driver resets the printer when possible and terminates the print job.


KillDoc Method Example

This example uses the KillDoc method to terminate the current print job. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click()
   For i = 1 To 40
      Printer.CurrentX = 1440   ' Set left margin.
      Printer.CurrentY = (i * 300)   ' Advance page to next line.
      Printer.Print "This is line" & Str$(i) & " of text."
      On Error Resume Next   ' Catch any printer error.
      If i = 26 Then
         Printer.KillDoc   ' Terminate print job abruptly.
         Printer.EndDoc
         End
      End If
   Next i
End Sub


LinkExecute Method

Sends a command string to the source application in a DDE conversation. Doesn't support named arguments.

Syntax

object.LinkExecute string

The LinkExecute method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
string | Required. String expression containing a command recognized by the source application.

Remarks

The actual value of string varies depending on the source application. For example, Microsoft Excel and Microsoft Word for Windows accept command strings that consist of their macro commands enclosed in square brackets ([ ]). To see command strings that a source application accepts, consult documentation for that application.


LinkExecute Method Example

This example establishes a DDE link with Microsoft Excel, places some values into cells in the first row of a new worksheet, and charts the values. LinkExecute sends Microsoft Excel the command to activate a worksheet, select some values, and chart them. To try this example, Microsoft Excel must be installed on your computer and in the path statement of your Autoexec.bat file. Paste the code into the Declarations section of a form that has a TextBox control with the default name Text1, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Cmd, I, Q, Row, Z   ' Declare variables.
   Q = Chr(34)   ' Define quotation marks.
   ' Create a string containing Microsoft Excel macro commands.
   Cmd = "[ACTIVATE(" & Q &"SHEET1" & Q & ")]"
   Cmd = Cmd & "[SELECT(" & Q & "R1C1:R5C2" & Q & ")]"
   Cmd = Cmd & "[NEW(2,1)][ARRANGE.ALL()]"
   If Text1.LinkMode = vbNone Then
      Z = Shell("Excel", 4)   ' Start Microsoft Excel.
      Text1.LinkTopic = "Excel|Sheet1"   ' Set link topic.
      Text1.LinkItem = "R1C1"   ' Set link item.
      Text1.LinkMode = vbLinkManual   ' Set link mode.
   End If
   For I = 1 To 5
      Row = I   ' Define row number.
      Text1.LinkItem = "R" & Row & "C1"   ' Set link item.
      Text1.Text = Chr(64 + I)   ' Put value in Text.
      Text1.LinkPoke   ' Poke value to cell.
      Text1.LinkItem = "R" & Row & "C2"   ' Set link item.
      Text1.Text = Row   ' Put value in Text.
      Text1.LinkPoke   ' Poke value to cell.
   Next I
   On Error Resume Next
   Text1.LinkExecute Cmd   ' Carry out Microsoft Excel commands.
   MsgBox "LinkExecute DDE demo with Microsoft Excel finished.", 64
 End
End Sub


LinkPoke Method

Transfers the contents of a Label, PictureBox, or TextBox control to the source application in a DDE conversation.

Syntax

object.LinkPoke

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The object is the name of a Label, PictureBox, or TextBox involved in a DDE conversation as a destination. If object is a Label, LinkPoke transfers the contents of the Caption property to the source. If object is a PictureBox, LinkPoke transfers the contents of the Picture property to the source. If object is a TextBox, LinkPoke transfers the contents of the Text property to the source.

Typically, information in a DDE conversation flows from source to destination. However, LinkPoke allows a destination object to supply data to the source. Not all source applications accept information supplied this way; if the source application doesn't accept the data, an error occurs.


LinkPoke Method Example

This example establishes a DDE link with Microsoft Excel, places some values into cells in the first row of a new worksheet, and charts the values. LinkPoke sends the values to be charted to the Microsoft Excel worksheet. To try this example, Microsoft Excel must be installed and in the path statement of your Autoexec.bat file. Paste the code into the Declarations section of a form that has a TextBox control with the default name Text1, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Cmd, I, Q, Row, Z   ' Declare variables.
   Q = Chr(34)   ' Define quotation marks.
   ' Create a string containing Microsoft Excel macro commands.
   Cmd = "[ACTIVATE(" & Q &"SHEET1" & Q & ")]"
   Cmd = Cmd & "[SELECT(" & Q & "R1C1:R5C2" & Q & ")]"
   Cmd = Cmd & "[NEW(2,1)][ARRANGE.ALL()]"
   If Text1.LinkMode = vbNone Then
      Z = Shell("Excel", 4)   ' Start Microsoft Excel.
      Text1.LinkTopic = "Excel|Sheet1"   ' Set link topic.
      Text1.LinkItem = "R1C1"   ' Set link item.
      Text1.LinkMode = vbLinkManual   ' Set link mode.
   End If
   For I = 1 To 5
      Row = I   ' Define row number.
      Text1.LinkItem = "R" & Row & "C1"   ' Set link item.
      Text1.Text = Chr(64 + I)   ' Put value in Text.
      Text1.LinkPoke   ' Poke value to cell.
      Text1.LinkItem = "R" & Row & "C2"   ' Set link item.
      Text1.Text = Row   ' Put value in Text.
      Text1.LinkPoke   ' Poke value to cell.
   Next I
   Text1.LinkExecute Cmd   ' Carry out Microsoft Excel commands.
   On Error Resume Next
   MsgBox "LinkPoke DDE demo with Microsoft Excel finished.", 64
 End
End Sub


LinkRequest Method

Asks the source application in a DDE conversation to update the contents of a Label, PictureBox, or TextBox control.

Syntax

object.LinkRequest

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The object is the name of a Label, PictureBox, or TextBox involved in a DDE conversation as a destination. LinkRequest causes the source application to send the most current data to object, updating the Caption property setting if object is a Label, the Picture property setting if object is a PictureBox, or the Text property setting if object is a TextBox.

If the LinkMode property of object is set to Automatic (1 or vbLinkAutomatic), the source application automatically updates object and LinkRequest isn't needed. If the LinkMode property of object is set to Manual (2 or vbLinkManual), the source application updates object only when LinkRequest is used. If the LinkMode property of object is set to Notify (3 or vbLinkNotify), the source notifies the destination that data has changed by invoking the LinkNotify event. The destination must then use LinkRequest to update the data.


LinkRequest Method Example

This example uses LinkRequest to update the contents of a text box with the values in a Microsoft Excel worksheet. To try this example, you must have Microsoft Excel running on your computer. Place some data in the first cells in the first column in the default worksheet (Sheet1.xls). Paste the code into the Declarations section of a form that has a TextBox control called Text1, and then press F5 and click the form.

Private Sub Form_Click ()
   If Text1.LinkMode = vbNone Then   ' Test link mode.
      Text1.LinkTopic = "Excel|Sheet1"   ' Set link topic.
      Text1.LinkItem = "R1C1"   ' Set link item.
      Text1.LinkMode = vbLinkManual   ' Set link mode.
      Text1.LinkRequest   ' Update text box.
   Else
      If Text1.LinkItem  = "R1C1" Then
         Text1.LinkItem = "R2C1"
         Text1.LinkRequest   ' Update text box.
      Else
         Text1.LinkItem = "R1C1"
         Text1.LinkRequest   ' Update text box.
      End If
   End If
End Sub


LinkSend Method

Transfers the contents of a PictureBox control to the destination application in a DDE conversation.

Syntax

object.LinkSend

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The object must be a PictureBox on a Form object that is a source in a DDE conversation.

When other applications establish automatic links with a Form in your application, Visual Basic notifies them when the contents of a TextBox or a Label on the Form change. However, Visual Basic doesn't automatically notify a DDE destination application when the Picture property setting of a PictureBox on a source Form changes. Because the amount of data in a graphic can be very large and because it seldom makes sense to update a destination application as each pixel in the picture changes, Visual Basic requires that you use the LinkSend method to explicitly notify DDE destination applications when the contents of a PictureBox changes.


LoadResData Function

Loads data of several possible types from a resource (.res) file and returns a Byte array.

Syntax

LoadResData(index, format)

The LoadResData function syntax has these parts:

Part | Description
index | Required. Integer or string specifying the identifier (ID) of the data in the resource file. The resource whose ID is 1 is reserved for the application icon.
format | Required. Value that specifies the original format of the data being returned, as described in Settings. Value can also be the string name of a user-defined resource.

Settings

The settings for format are:

Setting | Description
1 | Cursor resource
2 | Bitmap resource
3 | Icon resource
4 | Menu resource
5 | Dialog box
6 | String resource
7 | Font directory resource
8 | Font resource
9 | Accelerator table
10 | User-defined resource
12 | Group cursor
14 | Group icon

Remarks

The data that LoadResData loads from the resource file can be up to 64K.

Using LoadResData with a bitmap, icon, or cursor resource type returns a string containing the actual bits in the resource. If you want to use the actual bitmap, icon, or resource, use the LoadResPicture function.

Using LoadResData is useful for localizing a Visual Basic application because the resources that need to be translated are isolated in one resource file and there is no need to access the source code or recompile the application.


LoadResPicture Function

Loads a bitmap, icon, or cursor from a resource (.res) file.

Syntax

LoadResPicture(index, format)

The LoadResPicture function syntax has these parts:

Part | Description
index | Required. Integer or string specifying the identifier (ID) of the data in the resource file. The resource whose ID is 1 is reserved for the application icon.
format | Required. Value or constant that specifies the format of the data being returned, as described in Settings.

Settings

The settings for format are:

Constant | Value | Description
vbResBitmap | 0 | Bitmap resource
vbResIcon | 1 | Icon resource
vbResCursor | 2 | Cursor resource

Remarks

You can use the LoadResPicture function instead of referring to graphics stored in the Picture property of a Form or controls.

Storing bitmaps, icons, or cursors in and accessing them from resource files improves load time because you can load them individually as needed from the resource file, rather than all at once when a Form is loaded.

Using LoadResPicture is useful for localizing a Visual Basic application because the resources that need to be translated are isolated in one resource file and there is no need to access the source code or recompile the application.


LoadResString Function

Loads a string from a resource (.res) file.

Syntax

LoadResString(index)

The LoadResString function syntax has these parts:

Part | Description
index | Required. Integer specifying the identifier (ID) of the data in the resource file. The resource whose ID is 1 is reserved for the application icon.

Remarks

You can use the LoadResString function instead of string literals in your code. Storing long strings of data in and accessing them from resource files improves load time because you can load them individually as needed from the resource file, rather than all at once when a form is loaded.

Using LoadResString is useful for localizing a Visual Basic application because the resources that need to be translated are isolated in one resource file and there is no need to access the source code or recompile the application.


LogEvent Method

Logs an event in the application's log target. On Windows NT platforms, the method writes to the NT Event log. On Windows 95 platforms, the method writes to the file specified in the LogPath property; by default, if no file is specified, events will be written to a file named vbevents.log.

Syntax

object.LogEvent (logBuffer, eventType)

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
logBuffer | Required. String to be written to the log.
eventType | Optional. A Long integer that specifies the type of event, as shown in Settings.

Settings

The settings for eventType are:

Constant | Value | Description
vbLogEventTypeError | 1 | Error.
vbLogEventTypeWarning | 2 | Warning.
vbLogEventTypeInformation | 4 | Information.

Remarks

Guidelines for logging are available in the Win32 SDK, and those guidelines should be followed when logging either to the NT Event log or the file specified in the LogPath property (on Windows 95 platforms).


Move Method

Moves an MDIForm, Form, or control. Doesn't support named arguments.

Syntax

object.Move left, top, width, height

The Move method syntax has these parts:

Part | Description
object | Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the form with the focus is assumed to be object.
left | Required. Single-precision value indicating the horizontal coordinate (x-axis) for the left edge of object.
top | Optional. Single-precision value indicating the vertical coordinate (y-axis) for the top edge of object.
width | Optional. Single-precision value indicating the new width of object.
height | Optional. Single-precision value indicating the new height of object.

Remarks

Only the left argument is required. However, to specify any other arguments, you must specify all arguments that appear in the syntax before the argument you want to specify. For example, you can't specify width without specifying left and top. Any trailing arguments that are unspecified remain unchanged.

For forms and controls in a Frame control, the coordinate system is always in twips. Moving a form on the screen or moving a control in a Frame is always relative to the origin (0,0), which is the upper-left corner. When moving a control on a Form object or in a PictureBox (or an MDI child form on an MDIForm object), the coordinate system of the container object is used. The coordinate system or unit of measure is set with the ScaleMode property at design time. You can change the coordinate system at run time with the Scale method.


Move Method Example

This example uses the Move method to move a form around on the screen. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Inch, Msg   ' Declare variables.
   Msg = "Choose OK to resize and move this form by "
   Msg = Msg & "changing the value of properties."
   MsgBox Msg   ' Display message.
   Inch = 1440   ' Set inch in twips.
   Width = 4 * Inch   ' Set width.
   Height = 2 * Inch   ' Set height.
   Left = 0   ' Set left to origin.
   Top = 0   ' Set top to origin.
   Msg = "Now choose OK to resize and move this form "
   Msg = Msg & "using the Move method."
   MsgBox Msg   ' Display message.
   Move Screen.Width - 2 * Inch, Screen.Height - Inch, 2 * Inch, Inch
End Sub


NavigateTo Method

Execute a hyperlink jump to the specified target.

Syntax

object.NavigateTo Target [, Location [, FrameName]]

The NavigateTo method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
Target | A string expression specifying the location to jump to. This can be a document or a URL.
Location | A string expression specifying the location within the URL specified in Target to jump to. If Location is not specified, the default document will be jumped to.
FrameName | A string expression specifying the frame within the URL specified in Target to jump to. If FrameName is not specified, the default frame will be jumped to.

Remarks

If the object is in a container that supports OLE hyperlinking, then the container will jump to the specified location. If the object is in a container that does not support OLE hyperlinking, then an application that is registered as supporting hyperlinking is started to handle the request.

If Target does not specify a valid location, an error is raised.


NewPage Method

Ends the current page and advances to the next page on the Printer object.

Syntax

object.NewPage

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

NewPage advances to the next printer page and resets the print position to the upper-left corner of the new page. When invoked, NewPage increments the Printer object's Page property by 1.


NewPage Method Example

This example uses the NewPage method to begin a new printer page after printing a single, centered line of text on a page. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim HWidth, HHeight, I, Msg   ' Declare variables.
   On Error GoTo ErrorHandler   ' Set up error handler.
   Msg = "This is printed on page"
   For I = 1 To 2   ' Set up two iterations.
      HWidth = Printer.TextWidth(Msg) / 2   ' Get one-half width.
      HHeight = Printer.TextHeight(Msg) /2   ' Get one-half height.
      Printer.CurrentX = Printer.ScaleWidth / 2 - HWidth
      Printer.CurrentY = Printer.ScaleHeight / 2 - HHeight
      Printer.Print Msg & Printer.Page & "."   ' Print.
      Printer.NewPage   ' Send new page.
   Next I
   Printer.EndDoc   ' Print done.
   Msg = "Two pages, each with a single, centered line of text, "
   Msg = Msg & "have been sent to your printer."
   MsgBox Msg   ' Display message.
   Exit Sub
ErrorHandler:
   MsgBox "There was a problem printing to your printer."
   Exit Sub
End Sub


InsertObjDlg Method

Displays the Insert Object dialog box.

Syntax

object.InsertObjDlg

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

At run time, you display this dialog box to enable the user to create a linked or embedded object by choosing the type of object (linked or embedded) and the application provides the object.

Use the OLETypeAllowed property to determine the type of object that can be created (linked, embedded, or either) using this dialog box.

When you create a new object, the application associated with the class name (for example, Excel.exe) must be correctly registered with the operating system. (The application setup program should register the application correctly.)


OLEDrag Method

Causes a component to initiate an OLE drag/drop operation.

Syntax

object.OLEDrag

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

When the OLEDrag method is called, the component’s OLEStartDrag event occurs, allowing it to supply data to a target component.


PaintPicture Method

Draws the contents of a graphics file (.bmp, .wmf, .emf, .cur, .ico, or .dib) on a Form, PictureBox, or Printer. Doesn't support named arguments.

Syntax

object.PaintPicture picture, x1, y1, width1, height1, x2, y2, width2, height2, opcode

The PaintPicture method syntax has these parts:

Part | Description
object | Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the Form object with the focus is assumed to be object.
Picture | Required. The source of the graphic to be drawn onto object. Must be the Picture property of a Form or PictureBox.
x1, y1 | Required. Single-precision values indicating the destination coordinates (x-axis and y-axis) on object for picture to be drawn. The ScaleMode property of object determines the unit of measure used.
Width1 | Optional. Single-precision value indicating the destination width of picture. The ScaleMode property of object determines the unit of measure used. If the destination width is larger or smaller than the source width (width2), picture is stretched or compressed to fit. If omitted, the source width is used.
Height1 | Optional. Single-precision value indicating the destination height of picture. The ScaleMode property of object determines the unit of measure used. If the destination height is larger or smaller than the source height (height2), picture is stretched or compressed to fit. If omitted, the source height is used.
x2, y2 | Optional. Single-precision values indicating the coordinates (x-axis and y-axis) of a clipping region within picture. The ScaleMode property of object determines the unit of measure used. If omitted, 0 is assumed.
Width2 | Optional. Single-precision value indicating the source width of a clipping region within picture. The ScaleMode property of object determines the unit of measure used. If omitted, the entire source width is used.
Height2 | Optional. Single-precision value indicating the source height of a clipping region within picture. The ScaleMode property of object determines the unit of measure used. If omitted, the entire source height is used.
Opcode Optional. Long value or code that is used only with bitmaps. It defines a bit-wise operation (such as vbMergeCopy or vbSrcAnd) that is performed on picture as it's drawn on object. For a complete list of bit-wise operator constants, see the RasterOp Constants topic in Visual Basic Help.

There are some limitations in the usage of opcodes. For example, you can't use any opcode other than vbSrcCopy if the source is an icon or metafile, and the opcodes that interact with the pattern (or "brush" in SDK terms) such as MERGECOPY, PATCOPY, PATPAINT, and PATINVERT actually interact with the FillStyle property of the destination.

Note Opcode is used to pass a bitwise operation on a bitmap. Placing a value in this argument when passing other image types will cause an "Invalid procedure call or argument" error. This is by design. To avoid this error, leave the Opcode argument blank for any image other than a bitmap.

Remarks

You can flip a bitmap horizontally or vertically by using negative values for the destination height (height1) and/or the destination width (width1).

You can omit as many optional trailing arguments as you want. If you omit an optional trailing argument or arguments, don't use any commas following the last argument you specify. If you want to specify an optional argument, you must specify all optional arguments that appear in the syntax before it.

Note that there is a difference between loading a .Bmp into a PictureBox control, and using the Windows API function BitBlt() to add a picture to it. When you BitBlt an image, the PictureBox control doesn't know to resize like it does if you use the LoadPicture method. Setting the ScaleWidth and ScaleHeight properties to the size of the image also doesn't work. If you want the PictureBox to resize to the new picture after BitBlt'ing, you must do so manually by code, converting units and dealing with borders. Below is a simple example of how to do this:

Sub ResizePictureBoxToImage(pic as PictureBox, twipWd _
  as Integer, twipHt as Integer)
 ' This code assumes that all units are in twips.  If
 ' not, you must convert it to twips before calling
 ' this routine.  This also assumes that the image
 ' was blt'ed to 0,0.
 Dim BorderHt as Integer, BorderWd as Integer
 BorderWd = Pic.Width - Pic.ScaleWidth
 BorderHt = Pic.Height - Pic.ScaleHeight
 pic.Move pic.Left, pic.Top, twipWd + BorderWd, _
   twipHt + BorderHt
End Sub


Paste Method

Copies data from the system Clipboard to an OLE container control.

Syntax

object.Paste

The object is an object expression that evaluates to an object in the Applies To list

Remarks

To use this method, set the OLETypeAllowed property, and then check the value of the PasteOK property. You can't paste successfully unless PasteOK returns a value of True.

If the Paste method was carried out, the OLEType property is set to vbOLELinked (0) or vbOLEEmbedded (1). If the Paste method wasn't carried out, the OLEType property is set to vbOLENone (3).

You can use this method to support an Edit Paste command on a menu.

If the PasteOK property setting is True and Visual Basic can't paste the object, the OLE container control deletes any object already in the control.


PasteSpecialDlg Method

Displays the Paste Special dialog box.

Syntax

object.PasteSpecialDlg

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

At run time, you display this dialog box to enable the user to paste an object from the system Clipboard. This dialog box displays several options to the user, including pasting either a linked or embedded object.

Use the OLETypeAllowed property to determine the type of object that can be created (linked, embedded, or either) using this dialog box.

If the PasteOK property setting is True and Visual Basic can't paste the object, the OLE container control deletes any object already in the control.


Point Method

Returns, as a long integer, the red-green-blue (RGB) color of the specified point on a Form or PictureBox. Doesn't support named arguments.

Syntax

object.Point(x, y)

The Point method syntax has these parts:

Part | Description
object | Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the Form object with the focus is assumed to be object.
x, y | Required. Single-precision values indicating the horizontal (x-axis) and vertical (y-axis) coordinates of the point in the ScaleMode property of the Form or PictureBox. Parentheses must enclose the values.

Remarks

If the point referred to by the x and y coordinates is outside object, the Point method returns -1.


Point Method Example

This example uses the Point method to determine the color of a specific point on a form. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim LeftColor, MidColor, Msg, RightColor   ' Declare variables.
   AutoRedraw = -1   ' Turn on AutoRedraw.
   Height = 3 * 1440   ' Set height to 3 inches.
   Width = 5 * 1440   ' Set width to 5 inches.
   BackColor = QBColor(1)   ' Set background to blue.
   ForeColor = QBColor(4)   ' Set foreground to red.
   Line (0, 0)-(Width / 3, Height), , BF   ' Red box.
   ForeColor = QBColor(15)   ' Set foreground to white.
   Line (Width / 3, 0)-((Width / 3) * 2, Height), , BF
   LeftColor = Point(0, 0)   ' Find color of left box,
   MidColor = Point(Width / 2, Height / 2)   ' middle box, and
   RightColor = Point(Width, Height)   ' right box.
   Msg = "The color number for the red box on the left side of "
   Msg = Msg & "the form is " & LeftColor & ". The "
   Msg = Msg & "color of the white box in the center is "
   Msg = Msg & MidColor & ". The color of the blue "
   Msg = Msg & "box on the right is " & RightColor & "."
   MsgBox Msg   ' Display message.
End Sub


PopupMenu Method

Displays a pop-up menu on an MDIForm or Form object at the current mouse location or at specified coordinates. Doesn't support named arguments.

Syntax

object.PopupMenu menuname, flags, x, y, boldcommand

The PopupMenu method syntax has these parts:

Part | Description
object | Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the form with the focus is assumed to be object.
Menuname | Required. The name of the pop-up menu to be displayed. The specified menu must have at least one submenu.
Flags | Optional. A value or constant that specifies the location and behavior of a pop-up menu, as described in Settings.
X | Optional. Specifies the x-coordinate where the pop-up menu is displayed. If omitted, the mouse coordinate is used.
Y | Optional. Specifies the y-coordinate where the pop-up menu is displayed. If omitted, the mouse coordinate is used.
boldcommand | Optional. Specifies the name of a menu control in the pop-up menu to display its caption in bold text. If omitted, no controls in the pop-up menu appear in bold.

Settings

The settings for flags are:

Constant (location) | Value | Description
vbPopupMenuLeftAlign | 0 | (Default) The left side of the pop-up menu is located at x.
vbPopupMenuCenterAlign | 4 | The pop-up menu is centered at x.
vbPopupMenuRightAlign | 8 | The right side of the pop-up menu is located at x.

Constant (behavior) | Value | Description
vbPopupMenuLeftButton | 0 | (Default) An item on the pop-up menu reacts to a mouse click only when you use the left mouse button.
vbPopupMenuRightButton | 2 | An item on the pop-up menu reacts to a mouse click when you use either the right or the left mouse button.

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

You specify the unit of measure for the x and y coordinates using the ScaleMode property. The x and y coordinates define where the pop-up is displayed relative to the specified form. If the x and y coordinates aren't included, the pop-up menu is displayed at the current location of the mouse pointer.

When you display a pop-up menu, the code following the call to the PopupMenu method isn't executed until the user either chooses a command from the menu (in which case the code for that command's Click event is executed before the code following the PopupMenu statement) or cancels the menu. In addition, only one pop-up menu can be displayed at a time; therefore, calls to this method are ignored if a pop-up menu is already displayed or if a pull-down menu is open.


PopupMenu Method Example

This example displays a pop-up menu at the cursor location when the user clicks the right mouse button over a form. To try this example, create a form that includes a Menu control named mnuFile (mnuFile must have at least one submenu). Copy the code into the Declarations section of the form, and press F5.

Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
   If Button = 2 Then
      PopupMenu mnuFile
   End If
End Sub


PrintForm Method

Sends a bit-by-bit image of a Form object to the printer.

Syntax

object.PrintForm

The object placeholder represents an object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with the focus is assumed to be object.

Remarks

PrintForm prints all visible objects and bitmaps of the Form object. PrintForm also prints graphics added to a Form object or PictureBox control at run time if the AutoRedraw property is True when the graphics are drawn.

The printer used by PrintForm is determined by the operating system's Control Panel settings.


PrintForm Method Example

This example uses the PrintForm method to print the current form. To try this example, paste the code into the Declarations section of a form. Place on the form any controls you want to see on the printed form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Msg   ' Declare variable.
   On Error GoTo ErrorHandler   ' Set up error handler.
   PrintForm   ' Print form.
   Exit Sub
ErrorHandler:
   Msg = "The form can't be printed."
   MsgBox Msg   ' Display message.
   Resume Next
End Sub


PrintReport Method

At run time, prints the data report created with the Data Report designer.

Syntax

object.PrintReport(ShowDialog, Range, PageFrom, PageTo)

The PrintReport method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
ShowDialog | Optional. A boolean expression that determines if the Print dialog box is shown.
Range | Optional. Sets an integer that determines if all the pages in the report will be executed or a range of pages, as shown in Settings.
PageFrom | Optional. An integer that sets the page from which to start printing.
PageTo | Optional. An integer that sets the page at which to stop printing.

Settings

Constant | Value | Description
rptRangeAllPages | 0 | (Default) All pages will be printed.
rptRangeFromTo | 1 | Only the specified range of pages will be exported.

Return Type

Long

Remarks

If no arguments are supplied with the method, a dialog box will be displayed prompting the user for appropriate information.

The PrintReport method performs an asynchronous operation. The PrintReport method returns the identifier of the "cookie" that identifies the asynchronous operation.


PrintReport Method Example

The first example displays the Print dialog box, allowing the user to specify the file name and page range. The second example prints the report without displaying the dialog box.

Private Sub DisplayPrintDialog()
   DataReport1.PrintReport True
End Sub

Private Sub PrintWithoutDialog()
   ' Prints all pages in the report.
   DataReport1.PrintReport False, rptRangeAllPages
End Sub


PropertyChanged Method

Notifies the container that a property’s value has been changed.

Syntax

object.PropertyChanged PropertyName

The PropertyChanged method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
PropertyName | A string expression that represents a name of the property that the control has changed the value of.

Remarks

By notifying the container that a property’s value has changed, the container can synchronize its Properties window with the new values of the object’s properties. Also, the container would not know if an instance of the object needed to be saved (through raising a WriteProperties event) unless the container was notified that a property’s value had changed.

This method needs to be called, for example, when a user changes a property value on a property page, or the object itself changes a property value. This method should also be called when a databound property is modified; otherwise the data source will not be updated.

Properties that are available only at run time do not need to call the PropertyChanged method, unless they can be data-bound.

As an example, the following code shows how the PropertyChanged method is used:

Public Property Let Address(ByVal cValue As String)
   m_Address = cValue
   PropertyChanged "Address"
End Property


Quit Method (Add-Ins)

Attempts to exit Visual Basic.

Syntax

object.Quit

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


ReadFromFile Method

Loads an object from a data file created using the SaveToFile method. Doesn't support named arguments.

Syntax

object.ReadFromFile filenumber

The ReadFromFile method syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Filenumber | Required. A numeric expression specifying the file number used when loading an object. This number must correspond to an open, binary file.

Remarks

You can save an object to a data file using the SaveToFile or SaveToOle1File methods.


ReadProperty

ReadProperty Method

Returns a saved value from a PropertyBag class object.

Syntax

object.ReadProperty(DataName[, DefaultValue])

The ReadProperty method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
DataName | A string expression that represents a data value in the property bag.
DefaultValue | The value to be returned if no value is present in the property bag.

Remarks

The ReadProperty method will return the value of the saved data that is represented by the string expression DataName, or DefaultValue if there is no saved value. DataName should match the string expression that was used to store the saved data value in the property bag.

Note Specifying a default value reduces the size of the file belonging to the container of the control. A line for the property is written to the file only if the value to be written is different from the default. Wherever possible, you should specify default values for the properties of the control when initializing, saving, and retrieving property values.


Refresh Method

Forces a complete repaint of a form or control.

Syntax

object.Refresh

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use the Refresh method when you want to:

  • Completely display one form while another form loads.

  • Update the contents of a file-system list box, such as a FileListBox control.

  • Update the data structures of a Data control.

Refresh can't be used on MDI forms, but can be used on MDI child forms. You can't use Refresh on Menu or Timer controls.

Generally, painting a form or control is handled automatically while no events are occurring. However, there may be situations where you want the form or control updated immediately. For example, if you use a file list box, a directory list box, or a drive list box to show the current status of the directory structure, you can use Refresh to update the list whenever a change is made to the directory structure.

You can use the Refresh method on a Data control to open or reopen the database (if the DatabaseName, ReadOnly, Exclusive, or Connect property settings have changed) and rebuild the dynaset in the control's Recordset property.


Refresh Method Example

This example uses the Refresh method to update a FileListBox control as test files are created. To try this example, paste the code into the Declarations section of a form with a FileListBox control named File1, and then run the example and click the form.

Private Sub Form_Click ()
   ' Declare variables.
   Dim FilName, Msg as String, I as Integer
   File1.Pattern = "TestFile.*"   ' Set file pattern.
   For I = 1 To 8   ' Do eight times.
      FilName = "TESTFILE." & I
      ' Create empty file.
      Open FilName For Output As FreeFile
      File1.Refresh   ' Refresh file list box.
      Close   ' Close file.
   Next I
   Msg = "Choose OK to remove the created test files."
   MsgBox Msg   ' Display message.
   Kill "TESTFILE.*"   ' Remove test files.
   File1.Refresh   ' Update file list box.
End Sub


RemoveAddInFromToolbar Method

Removes a button from the Add-In toolbar which references an add-in or Wizard.

Syntax

object.RemoveAddInFromToolbar (saddinname As String)

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
saddinname | Required. A string expression specifying the name of the add-in or Wizard to remove from the Add-In toolbar (as specified by the saddinname parameter from the AddToAddInToolbar method).


RemoveAddInFromToolbar Method Example

This example removes an existing button from the Add-In toolbar that references a fictitious add-in called MyAddIn Title:

Sub Main()
  dim x as Object
  Set x=CreateObject("AddInToolbar.Manager")
  x.RemoveAddInFromToolbar sAddInName:="MyAddIn Title"
End Sub


Remove Method (DEDesigner Extensibility)

Removes a member from a DEConnections or DECommands collection.

Syntax

object.Remove(index, Boolean)

The Remove property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
index | An integer or string expression that specifies the index number of the DECommand or DEConnection object to remove from the collection. Use an integer to specify the value of the Index property; use a string to specify the value of the Key property.
Boolean | Optional. A Boolean expression that specifies whether any warning messages display during the remove. If False, the default, no warning messages display.

Remarks

For the DEAggregates, DEGroupingFields, and DERelationConditions collections, the Boolean is not used. Thus, for these three collections, the Remove method is the same as Visual Basic's Remove method.

When removing an object using the Data Environment Extensibility Object Model, first set the PromptDelete property to False to prevent the confirmation dialog box from appearing.


RemoveItem Method

Removes an item from a ListBox or ComboBox control or a row from an MS Flex Grid control. Doesn't support named arguments.

Syntax

object.RemoveItem index

The RemoveItem method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
index | Required. Integer representing the position within the object of the item or row to remove. For the first item in a ListBox or ComboBox or for the first row in an MS Flex Grid control, index = 0.

Remarks

A ListBox or ComboBox that is bound to a Data control doesn't support the RemoveItem method.


RemoveItem Method Example

This example uses the RemoveItem method to remove entries from a list box. To try this example, paste the code into the Declarations section of a form with a ListBox control named List1, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Entry, I, Msg   ' Declare variables.
   Msg = "Choose OK to add 100 items to your list box."
   MsgBox Msg   ' Display message.
   For I = 1 To 100   ' Count from 1 to 100.
      Entry = "Entry " & I   ' Create entry.
      List1.AddItem Entry   ' Add the entry.
   Next I
   Msg = "Choose OK to remove every other entry."
   MsgBox Msg   ' Display message.
   For I = 1 To 50   ' Determine how to
      List1.RemoveItem I   ' remove every other
   Next I   ' item.
   Msg = "Choose OK to remove all items from the list box."
   MsgBox Msg   ' Display message.
   List1.Clear   ' Clear list box.
End Sub


Render Method

Draws all or part of a source image to a destination object.

Syntax

object.Render(hdc, xdest, ydest, destwid, desthgt, xsrc, ysrc, srcwid, srchgt, wbounds)

The Render method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
hdc | Required. The handle to the destination object's device context.
xdest | Required. The x-coordinate of upper left corner of the drawing region in the destination object. This coordinate is in the scale units of the destination object.
ydest | Required. The y-coordinate of upper left corner of the drawing region in the destination object. This coordinate is in the scale units of the destination object.
destwid | Required. The width of drawing region in the destination object, expressed in the scale units of the destination object.
desthgt | Required. The height of drawing region in the destination object, expressed in the scale units of the destination object.
xsrc | Required. The x-coordinate of upper left corner of the drawing region in the source object. This coordinate is in HIMETRIC units.
ysrc | Required. The y-coordinate of upper left corner of the drawing region in the source object. This coordinate is in HIMETRIC units.
srcwid | Required. The width of drawing region in the source object, expressed in HIMETRIC units.
srchgt | Required. The height of drawing region in the source object, expressed in HIMETRIC units.
wbounds | Required. The world bounds of a metafile. This argument should be passed a value of Null unless drawing to a metafile, in which case the argument is passed a user-defined type corresponding to a RECTL structure.

Remarks

The recommended way to paint part of a graphic into a destination is through the PaintPicture method.


SaveToFile Method

Saves an object to a data file. Doesn't support named arguments.

Syntax

object.SaveToFile filenumber

The SaveToFile method syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Filenumber | Required. A numeric expression specifying the file number used when saving an object. This number must correspond to an open, binary file.

Remarks

Use this method to save ActiveX components. To save an ActiveX component in the OLE version 1.0 format, use the SaveToOle1File method instead.

If the object is linked (OLEType = vbOLELinked, 0), only the link information and an image of the data is saved to the specified file. The object's data is maintained by the application that created the object. If the object is embedded (OLEType = vbOLEEmbedded, 1), the object's data is maintained by the OLE container control and can be saved by your Visual Basic application.

You can load an object saved to a data file with the ReadFromFile method.


SaveToOle1File Method

Saves an object in the OLE version 1.0 file format. Doesn't support named arguments.

Syntax

object.SaveToOle1File filenumber

The SaveToOle1File method syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Filenumber | Required. A numeric expression specifying the file number used when saving or loading an object. This number must correspond to an open, binary file.

Remarks

If the object is linked (OLEType = vbOLELinked, 0), only the link information and an image of the data is saved to the specified file. The object's data is maintained by the application that created the object. If the object is embedded (OLEType = vbOLEEmbedded, 1), the object's data is maintained by the OLE container control and can be saved by your Visual Basic application.

If you want to save the object in the current ActiveX component format, use the SaveToFile method instead.


Scale Method

Defines the coordinate system for a Form, PictureBox, or Printer. Doesn't support named arguments.

Syntax

object.Scale (x1, y1) - (x2, y2)

The Scale method syntax has these parts:

Part | Description
object | Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the Form object with the focus is assumed to be object.
x1, y1 | Optional. Single-precision values indicating the horizontal (x-axis) and vertical (y-axis) coordinates that define the upper-left corner of object. Parentheses must enclose the values. If omitted, the second set of coordinates must also be omitted.
x2, y2 | Optional. Single-precision values indicating the horizontal and vertical coordinates that define the lower-right corner of object. Parentheses must enclose the values. If omitted, the first set of coordinates must also be omitted.

Remarks

The Scale method enables you to reset the coordinate system to any scale you choose. Scale affects the coordinate system for both run-time graphics statements and the placement of controls.

If you use Scale with no arguments (both sets of coordinates omitted), it resets the coordinate system to twips.


Scale Method Example

This example uses the Scale method to set up a custom coordinate system so that a bar chart can be drawn on a form. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim I, OldFontSize   ' Declare variables.
   Width = 8640: Height = 5760   ' Set form size in twips.
   Move 100,100   ' Move form origin.
   AutoRedraw = -1   ' Turn on AutoRedraw.
   OldFontSize = FontSize   ' Save old font size.
   BackColor = QBColor(7)   ' Set background to gray.
   Scale (0, 110)-(130, 0)   ' Set custom coordinate system.
   For I = 100 To 10 Step -10
      Line (0, I)-(2, I)   ' Draw scale marks every 10 units.
      CurrentY = CurrentY + 1.5   ' Move cursor position.
      Print I   ' Print scale mark value on left.
      Line (ScaleWidth - 2, I)-(ScaleWidth, I)
      CurrentY = CurrentY + 1.5   ' Move cursor position.
      CurrentX = ScaleWidth - 9
      Print I   ' Print scale mark value on right.
   Next I
   ' Draw bar chart.
   Line (10, 0)-(20, 45), RGB(0, 0, 255), BF   ' First blue bar.
   Line (20, 0)-(30, 55), RGB(255, 0, 0), BF   ' First red bar.
   Line (40, 0)-(50, 40), RGB(0, 0, 255), BF
   Line (50, 0)-(60, 25), RGB(255, 0, 0), BF
   Line (70, 0)-(80, 35), RGB(0, 0, 255), BF
   Line (80, 0)-(90, 60), RGB(255, 0, 0), BF
   Line (100, 0)-(110, 75), RGB(0, 0, 255), BF
   Line (110, 0)-(120, 90), RGB(255, 0, 0), BF
   CurrentX = 18: CurrentY = 100   ' Move cursor position.
   FontSize = 14   ' Enlarge font for title.
   Print "Widget Quarterly Sales"   ' Print title.
   FontSize = OldFontSize   ' Restore font size.
   CurrentX = 27: CurrentY = 93   ' Move cursor position.
   Print "Planned Vs. Actual"   ' Print subtitle.
   Line (29, 86)-(34, 88), RGB(0, 0, 255), BF   ' Print legend.
   Line (43, 86)-(49, 88), RGB(255, 0, 0), BF
End Sub


ScaleX, ScaleY Methods

Converts the value for the width or height of a Form, PictureBox, or Printer from one of the ScaleMode property's unit of measure to another. Doesn't support named arguments.

Syntax

object.ScaleX (width, fromscale, toscale)

object.ScaleY (height, fromscale, toscale)

The ScaleX and ScaleY method syntaxes have these parts:

Part | Description
object | Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the Form object with the focus is assumed to be object.
width | Required. Specifies, for object, the number of units of measure to be converted.
height | Required. Specifies, for object, the number of units of measure to be converted.
fromscale | Optional. A constant or value specifying the coordinate system from which width or height of object is to be converted, as described in Settings. The possible values of fromscale are the same as for the ScaleMode property, plus the new value of HiMetric.
toscale | Optional. A constant or value specifying the coordinate system to which width or height of object is to be converted, as described in Settings. The possible values of toscale are the same as for the ScaleMode property, plus the new value of HiMetric.

Settings

The settings for fromscale and toscale are:

Constant | Value | Description
vbUser | 0 | User-defined: indicates that the width or height of object is set to a custom value.
vbTwips | 1 | Twip (1440 twips per logical inch; 567 twips per logical centimeter).
vbPoints | 2 | Point (72 points per logical inch).
vbPixels | 3 | Pixel (smallest unit of monitor or printer resolution).
vbCharacters | 4 | Character (horizontal = 120 twips per unit; vertical = 240 twips per unit).
vbInches | 5 | Inch.
vbMillimeters | 6 | Millimeter.
vbCentimeters | 7 | Centimeter.
vbHimetric | 8 | HiMetric. If fromscale is omitted, HiMetric is assumed as the default.
vbContainerPosition | 9 | Determines control's position.
vbContainerSize | 10 | Determines control's size.

Remarks

The ScaleX and ScaleY methods take a value (width or height), with its unit of measure specified by fromscale, and convert it to the corresponding value for the unit of measure specified by toscale.

You can also use ScaleX and ScaleY with the PaintPicture method.


SelectAll Method

Selects all of the controls contained on a form.

Syntax

object.SelectAll

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


SetAutoServerSettings Method

Sets the Remote Automation registry values to meet ActiveX and Remote Automation requirements, including configuration settings for remote server access.

Syntax

object. SetAutoServerSettings(remote, [progid], [clsid], [servername], [protocol], [authentication])

The SetAutoServerSettings method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
remote | Required. Boolean. True if the server is remote, False if local.
progid | Optional. A variant expression specifying the ProgID for the server.
clsid | Optional. A variant expression specifying the CLSID for the server.
servername | Optional. A variant expression specifying the name of the server machine.
protocol | Optional. A variant expression specifying the RPC name of the protocol to be used.
authentication | Optional. A variant expression specifying the RPC authentication level.

Return Values

The SetAutoServerSettings method returns the following error codes:

Value | Description
0 | No error.
1 | Unknown run time error occurred.
2 | No protocol was specified.
3 | No server machine name was specified.
4 | An error occurred reading from the registry.
5 | An error occurred writing to the registry.
6 | Both the ProgID and CLSID parameters were missing.
7 | There is no local server (either in-process or cross-process, 16-bit or 32-bit).
8 | There was an error looking for the Proxy DLLs, check that they were installed properly.

Remarks

The SetAutoServerSettings method takes either a CLSID or a ProgID and sets the registry information to local or remote depending on the value of the remote parameter. If both a CLSID and a ProgID are passed to the method, the CLSID takes precedence.


SetAutoServerSettings Method Example

This example switches a server named "Hello" from local registration to remote, and then back again:

Sub SwitchHello()
   Dim oRegClass As New RegClass
   ' Register Hello to run remotely on a machine
 ' called Server1.
   oRegClass.SetAutoServerSettings True, _
  "HelloProj.HelloClass",1 _
   ServerName:="Server1", Protocol:="ncacn_ip_tcp"
   ' Register Hello to run locally again.
   oRegClass.SetAutoServerSettings False, _
  "HelloProj.HelloClass"
End Sub


ReleaseInstance Method

Releases a WebClass object.

Syntax

object.ReleaseInstance

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

If StateManagement is set to wcRetainInstance, then the WebClass object run-time releases the WebClass object. Developers should call the ReleaseInstance method during the processing of an HTTP request when the WebClass has completed its processing and should be terminated. The final HTTP response typically contains some UI element, for example, a hyperlink, that allows the user to navigate to another URL outside of the WebClass. If there is no such element then the user would need to manually enter another URL in the browser in order to navigate elsewhere. The response should not contain URLs to other WebItems in the WebClass, for example, created using URLFor. If such a URL is in the response and the user navigates to it, a new instance of the WebClass will be created.


SetData Method

Puts a picture on the Clipboard object using the specified graphic format. Doesn't support named arguments.

Syntax

object.SetData data, format

The SetData method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
data | Required. A graphic to be placed on the Clipboard object.
format | Optional. A constant or value that specifies one of the Clipboard object formats recognized by Visual Basic, as described in Settings. If format is omitted, SetData automatically determines the graphic format.

Settings

The settings for format are:

Constant | Value | Description
vbCFBitmap | 2 | Bitmap (.bmp files)
vbCFMetafile | 3 | Metafile (.wmf files)
vbCFDIB | 8 | Device-independent bitmap (DIB)
vbCFPalette | 9 | Color palette

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

You set the graphic that is to be placed onto the Clipboard object with either the LoadPicture function or the Picture property of a Form, Image, or PictureBox.


SetData Method (DataObject Object)

Inserts data into a DataObject object using the specified data format.

Syntax

object.SetData [data], [format]

The SetData method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
data | Optional A variant containing the data to be passed to the DataObject object.
format | Optional. A constant or value that specifies the format of the data being passed, as described in Settings.

Settings

The settings for format are:

Constant | Value | Description
vbCFText | 1 | Text (.txt files)
vbCFBitmap | 2 | Bitmap (.bmp files)
vbCFMetafile | 3 | Metafile (.wmf files)
vbCFEMetafile | 14 | Enhanced metafile (.emf files)
vbCFDIB | 8 | Device-independent bitmap (DIB)
vbCFPalette | 9 | Color palette
vbCFFiles | 15 | List of files
vbCFRTF | -16639 | Rich text format (.rtf files)

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

The data argument is optional. This allows you to set several different formats that the source component can support without having to load the data separately for each format. Multiple formats are set by calling SetData several times, each time using a different format. If you wish to start fresh, use the Clear method to clear all data and format information from the DataObject.

The format argument is also optional, but either the data or format argument must be specified. If data is specified, but not format, then Visual Basic will try to determine the format of the data. If it is unsuccessful, then an error is generated. When the target requests the data, and a format was specified, but no data was provided, the source’s OLESetData event occurs, and the source can then provide the requested data type.

It's possible for the GetData and SetData methods to use data formats other than those listed in Settings, including user-defined formats registered with Windows via the RegisterClipboardFormat() API function. However, there are a few caveats:

  • The SetData method requires the data to be in the form of a byte array when it does not recognize the data format specified.

  • The GetData method always returns data in a byte array when it is in a format that it doesn't recognize, although Visual Basic can transparently convert this returned byte array into other data types, such as strings.

  • The byte array returned by GetData will be larger than the actual data when running on some operating systems, with arbitrary bytes at the end of the array. The reason for this is that Visual Basic does not know the data's format, and knows only the amount of memory that the operating system has allocated for the data. This allocation of memory is often larger than is actually required for the data. Therefore, there may be extraneous bytes near the end of the allocated memory segment. As a result, you must use appropriate functions to interpret the returned data in a meaningful way (such as truncating a string at a particular length with the Left function if the data is in a text format).


SetFocus Method

Moves the focus to the specified control or form.

Syntax

object.SetFocus

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The object must be a Form object, MDIForm object, or control that can receive the focus. After invoking the SetFocus method, any user input is directed to the specified form or control.

You can only move the focus to a visible form or control. Because a form and controls on a form aren't visible until the form's Load event has finished, you can't use the SetFocus method to move the focus to the form being loaded in its own Load event unless you first use the Show method to show the form before the Form_Load event procedure is finished.

You also can't move the focus to a form or control if the Enabled property is set to False. If the Enabled property has been set to False at design time, you must first set it to True before it can receive the focus using the SetFocus method.


SetText Method

Puts a text string on the Clipboard object using the specified Clipboard object format. Doesn't support named arguments.

Syntax

object.SetText data, format

The SetText method syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
data | Required. String data to be placed onto the Clipboard.
Format | Optional. A constant or value that specifies one of the Clipboard formats recognized by Visual Basic, as described in Settings.

Settings

The settings for format are:

Constant | Value | Description
vbCFLink | &HBF00 | DDE conversation information
vbCFRTF | &HBF01 | RichText Format
vbCFText | 1 | (Default) Text

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.


SetText Method Example

This example uses the SetText method to copy text from a text box to the Clipboard. To try this example, paste the code into the Declarations section of a form with a text box named Text1, and then press F5 and click the form.

Private Sub Form_Click ()
   Const CF_TEXT = 1   ' Define bitmap format.
   Dim I, Msg, Temp   ' Declare variables.
   On Error Resume Next   ' Set up error handling.
   Msg = "Type anything you like into the text box below."
   Text1.Text = InputBox(Msg)   ' Get text from user.
   Msg = "Choose OK to copy the contents of the text box "
   Msg = Msg & "to the Clipboard."
   MsgBox Msg   ' Display message.
   ClipBoard.Clear   ' Clear Clipboard.
   Clipboard.SetText Text1.Text   ' Put text on Clipboard.
   If Clipboard.GetFormat(CF_TEXT) Then
      Text1.Text = ""   ' Clear the text box.
      Msg = "The text is now on the Clipboard. Choose OK "
      Msg = Msg & "to copy the text from the Clipboard back "
      Msg = Msg & "to the text box."
      MsgBox Msg   ' Display message.
      Temp = Clipboard.GetText(CF_TEXT)   ' Get Clipboard text.
      For I = Len(Temp) To 1 Step -1   ' Reverse the text.
         Text1.Text = Text1.Text & Mid(Temp, I, 1)
      Next I
   Else
      Msg = "There is no text on the Clipboard."
      MsgBox Msg   ' Display error message.
   End If
End Sub


SetViewport Method

Sets the left and top coordinates of the UserDocument that will be visible in the Viewport.

Syntax

object.SetViewPort left, top

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
left | Required. A value of type Single that specifies the left coordinate of the UserDocument.
top | Required. A value of type Single that specifies the top coordinate of the UserDocument.


SetViewport Method Example

The example uses SetViewport method to automatically place the TextBox control with focus into the top left corner of the Viewport of container. To try the example, place an array of three or more TextBox controls onto a UserDocument object. Paste the code below into the General section. Press F5 to run the project, then run Internet Explorer (3.0 or later). In Internet Explorer, type the path and file name of the ActiveX document (UserDocument1.vbd) into the Address box (the file will be in the same directory as the Visual Basic executable). When the ActiveX document is displayed, type any distinctive text into the first TextBox control. Press TAB to move to the next control to see the effect of the SetViewPort method.

Private Sub Text1_GotFocus(Index As Integer)
   UserDocument.SetViewport Text1(Index).Left, _
      Text1(Index).Top
End Sub

Private Sub UserDocument_Initialize()
   ' The container must be small enough for scrollbars
   ' to appear. To assure this, set the MinHeight and
   ' MinWidth properties to be larger than the
   ' container.
   UserDocument.MinHeight = 10000
   UserDocument.MinWidth = 10000
End Sub


Show Method

Displays an MDIForm or Form object. Doesn't support named arguments.

Syntax

object.Show style, ownerform

The Show method syntax has these parts:

Part | Description
object | Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the form associated with the active form module is assumed to be object.
style | Optional. Integer that determines if the form is modal or modeless. If style is 0, the form is modeless; if style is 1, the form is modal.
ownerform | Optional. A string expression that specifies the component which "owns" the form being shown. For standard Visual Basic forms, use the keyword Me

Remarks

If the specified form isn't loaded when the Show method is invoked, Visual Basic automatically loads it.

When Show displays a modeless form, subsequent code is executed as it's encountered. When Show displays a modal form, no subsequent code is executed until the form is hidden or unloaded.

When Show displays a modal form, no input (keyboard or mouse click) can occur except to objects on the modal form. The program must hide or unload a modal form (usually in response to some user action) before input to another form can occur. An MDIForm can't be modal.

Although other forms in your application are disabled when a modal form is displayed, other applications aren't.

The startup form of an application is automatically shown after its Load event is invoked.

Here is an example of how the ownerform argument is used with the Show method:

Private Sub cmdShowResults_Click()
   ' Show a modal form named frmResults.
   frmResults.Show vbModal, Me
End Sub


ShowWhatsThis Method

Displays a selected topic in a Help file using the What's This popup provided by Windows 95 Help.

Syntax

object.ShowWhatsThis

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The ShowWhatsThis method is very useful for providing context-sensitive Help from a context menu in your application. The method displays the topic identified by the WhatsThisHelpID property of the object specified in the syntax.


ShowWhatsThisMethod

ShowWhatsThis Method Example

This example displays the What's This Help topic for a CommandButton control by selecting a menu command from a context menu created for the button. Set the WhatsThisHelp property of the form to True. Place a CommandButton control on a form, create a menu using the Menu Editor with a top-level invisible item named mnuBtnContextMenu, and a sub-menu named mnuBtnWhatsThis with a caption of "What's This?".

Private ThisControl As Control

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
      If Button = vbRightButton Then
         Set ThisControl = Command1
         PopupMenu mnuBtnContextMenu
      End If
   Set ThisControl = Nothing
End Sub

Private Sub mnuBtnWhatsThis_Click()
   ThisControl.ShowWhatsThis
End Sub


Show Method Example

This example uses the Show method to show a hidden form. To try this example, paste the code into the Declarations section of a non-MDI form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Msg   ' Declare variable.
   Hide   ' Hide form.
   Msg = "Choose OK to make the form reappear."
   MsgBox Msg   ' Display message.
   Show   ' Show form again.
End Sub


Size Method

Changes the width and height of a UserControl object.

Syntax

object.Size width, height

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
width | Required. The width in twips of the object.
height | Required. The height in twips of the object.

Remarks

The Width and Height properties of a UserControl object are always given in Twips, regardless of ScaleMode.


StartLogging Method

Sets the log target and log mode of an operation.

Syntax

object.StartLogging logTarget, logMode

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
logTarget | Path and filename of the file used to capture output from the LogEvent method.
logMode | A value which determines how logging (through the LogEvent method) will be carried out. See Settings below.

Settings

The settings for logMode are:

Constant | Value | Description
vbLogAuto | 0 | If running on Windows 95, this option logs messages to the file specified in the LogFile property. If running on Windows NT, messages are logged to the Windows NT Application Event Log, with "VBRunTime" used as the application source and App.Title appearing in the description.
VbLogOff | 1 | Turns all logging off. Messages from UI shunts as well as from the LogEvent method are ignored and discarded.
VbLogToFile | 2 | Forces logging to a file. If no valid filename is present in LogPath, logging is ignored, and the property is set to vbLogOff.
VbLogToNT | 3 | Forces logging to the NT event log. If not running on Windows NT, or the event log is unavailable, logging is ignored and the property is set to vbLogOff.
VbLogOverwrite | 16 | Indicates that the logfile should be recreated each time the application starts. This value can be combined with other mode options using the OR operator. The default action for logging is to append to the existing file. In the case of NT event logging, this flag has no meaning.
VbLogThreadID | 32 | Indicates that the current thread ID be prepended to the message, in the form "[T:0nnn] ". This value can be combined with other mode options using the OR operator. The default action is to show the thread ID only when the application is multi-threaded (either explicitly marked as thread-safe, or implemented as an implicit multithreaded app, such as a local server with the instancing property set to Single-Use, multithreaded).


TextHeight Method

Returns the height of a text string as it would be printed in the current font of a Form, PictureBox, or Printer. Doesn't support named arguments.

Syntax

object.TextHeight(string)

The TextHeight method syntax has these parts:

Part | Description
object | Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the Form object with the focus is assumed to be object.
String | Required. A string expression that evaluates to a string for which the text height is determined. Parentheses must enclose the string expression.

Remarks

The height is expressed in terms of the ScaleMode property setting or Scale method coordinate system in effect for object. Use TextHeight to determine the amount of vertical space required to display the text. The height returned includes the normal leading space above and below the text, so you can use the height to calculate and position multiple lines of text within object.

If string contains embedded carriage returns, TextHeight returns the cumulative height of the lines, including the leading space above and below each line.


TextHeight Method Example

The TextHeight method is used to center a line of text vertically on a form. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim HalfWidth, HalfHeight, Msg   ' Declare variable.
   AutoRedraw = -1   ' Turn on AutoRedraw.
   BackColor = QBColor(4)   ' Set background color.
   ForeColor = QBColor(15)   ' Set foreground color.
   Msg = "Visual Basic"   ' Create message.
   FontSize = 48   ' Set font size.
   HalfWidth =  TextWidth(Msg) / 2    ' Calculate one-half width.
   HalfHeight = TextHeight(Msg) / 2   ' Calculate one-half height.
   CurrentX = ScaleWidth / 2 - HalfWidth   ' Set X.
   CurrentY = ScaleHeight / 2 - HalfHeight   ' Set Y.
   Print Msg   ' Print message.
End Sub


TextWidth Method

Returns the width of a text string as it would be printed in the current font of a Form, PictureBox, or Printer. Doesn't support named arguments.

Syntax

object.TextWidth(string)

The TextWidth method syntax has these parts:

Part | Description
object | Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with the focus is assumed to be object.
String | Required. A string expression that evaluates to a string for which the text width is determined. Parentheses must surround the string expression.

Remarks

The width is expressed in terms of the ScaleMode property setting or Scale method coordinate system in effect for object. Use TextWidth to determine the amount of horizontal space required to display the text. If string contains embedded carriage returns, TextWidth returns the width of the longest line.


TextWidth Method Example

The TextWidth method is used to center a line of text horizontally on a form. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim HalfHeight, HalfWidth, Msg   ' Declare variables.
   AutoRedraw = -1   ' Turn on AutoRedraw.
   BackColor = QBColor(4)   ' Set background color.
   ForeColor = QBColor(15)   ' Set foreground color.
   Msg = "Visual Basic"   ' Create message.
   FontSize = 48   ' Set font size.
   HalfWidth = TextWidth(Msg) / 2    ' Calculate one-half width.
   HalfHeight = TextHeight(Msg) / 2   ' Calculate one-half height.
   CurrentX = ScaleWidth / 2 - HalfWidth   ' Set X.
   CurrentY = ScaleHeight / 2 - HalfHeight   ' Set Y.
   Print Msg   ' Print message.
End Sub


Trace Method

Passes the specified string to the Win32 OutputDebugString API. The string may be captured by a suitable debugging tool, for example, DBMON.

Syntax

object.Trace(traceoutput As String)

The Trace method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
traceoutput | String written to the Win32 OutputDebugString API.

Remarks

The trace string typically contains debugging information during development. For a production WebClass the trace string might contain error messages, as well as performance and statistical data.


Update Method (OLE Container)

Retrieves the current data from the application that supplied the object and displays that data as a graphic in the OLE container control.

Syntax

object.Update

The object is an object expression that evaluates to an object in the Applies To list.


UpdateControls Method (BindingCollection Object)

Gets the current row from the BindingCollection object's data source and resets the contents of controls bound through the object.

Syntax

object.UpdateControls

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use this method to restore the contents of bound controls to their original values, as when a user makes changes to data and then decides to cancel the changes.

Calling UpdateControls has the same effect as resetting the DataChanged property on each Binding object to False, then making the current row current again, with the exception that no events occur when calling UpdateControls. By not invoking any events, this method can be used to simplify an update operation because no additional validation or change event procedures are triggered.


URLFor Method

Used to specify the uniform resource locator (URL) that the system needs to reference a webclass’s HTML template or WebItem in the browser.

Syntax

object.URLFor(WebItemobject As WebItem,[eventname])

The URLFor method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
WebItemobject | WebItem object for which you want to generate a URL and fire an event.
eventname | String that refers to an event in the WebItem — if omitted it refers to the Respond event. The returned URL can be embedded in the response to the client and, when referenced, will trigger the related event in the WebClass.

Remarks

Also used to generate a string containing a URL at run time that refers to a WebItem and specifies a custom event to fire.When receiving an event name that was not defined at design time, the URLFor method returns a URL which when processed by the client fires the UserEvent event on the respective WebItem. The UserEvent event will be passed the name of the run-time defined event.


ValidateControls Method

Ensures that the contents of the last control on the form are valid before exiting the form.

Syntax

object.ValidateControls

The object placeholder represents an object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with the focus is assumed to be object.


WhatsThisMode Method

Causes the mouse pointer to change into the What's This pointer and prepares the application to display What's This Help on the selected object.

Syntax

object.WhatsThisMode

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Executing the WhatsThisMode method places the application in the same state you get by clicking the What's This button in the title bar. The mouse pointer changes to the What's This pointer. When the user clicks an object, the WhatsThisHelpID property of the clicked object is used to invoke context-sensitive Help. This method is especially useful when invoking Help from a menu in the menu bar of your application.


WhatsThisModeMethod

WhatsThisMode Method Example

This example uses a command in a menu to change the mouse pointer to the What's This pointer and enable context-sensitive Help. To try the example, create a menu, and paste the code into the Click event of one of the Menu controls. Press F5, and click the menu command to toggle the application into the What's This state.

Private Sub mnuContextHelp_Click ()
   Form1.WhatsThisMode
End Sub


WriteProperty Method

Writes a value to be saved to a PropertyBag class object.

Syntax

object.WriteProperty(DataName, Value[, DefaultValue])

The WriteProperty method syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
DataName | A string expression to represents the data value to be placed in the property bag.
Value | The data value to save in the property bag.
DefaultValue | The default value for the data.

Remarks

The WriteProperty method will write a data value in the property bag, and associate it with the string value in DataName. This string value will be used to access the data value when the ReadProperty method is called to retrieve a saved data value from the property bag.

Note Specifying a default value reduces the size of the file belonging to the container of the control. A line for the property is written to the file only if the value to be written is different from the default. Wherever possible, you should specify default values for the properties of the control when initializing, saving, and retrieving property values.


WriteTemplate Method

Processes an HTML template attached to a WebItem object and returns it to the browser.

Syntax

object.WriteTemplate(Template As Variant)

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
Template | Optional. Indicates the template to return to the browser.

Remarks

Use this method to send the HTML template to the client. The ReplaceToken event is fired during processing of a template if that template contains replacement tokens. The template is written to the Response object.

The WriteTemplate method does not fire the Respond event for the associated WebItem. It is recommended that the WriteTemplate method only be called from within the Respond event of the WebItem and that the Respond event be triggered by setting the NextItem property.


ZOrder Method

Places a specified MDIForm, Form, or control at the front or back of the z-order within its graphical level. Doesn't support named arguments.

Syntax

object.ZOrder position

The ZOrder method syntax has these parts:

Part | Description
object | Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the form with the focus is assumed to be object.
Position | Optional. Integer indicating the position of object relative to other instances of the same object. If position is 0 or omitted, object is positioned at the front of the z-order. If position is 1, object is positioned at the back of the z-order.

Remarks

The z-order of objects can be set at design time by choosing the Bring To Front or Send To Back menu command from the Edit menu.

Within an MDIForm object, ZOrder sends MDI child forms to either the front or the back of the MDI client area, depending on the value of position. For an MDIForm or Form object, ZOrder sends the form to either the front or the back of the screen, depending on the value of position. As a result, forms can be displayed in front of or behind other running applications.

Three graphical layers are associated with forms and containers. The back layer is the drawing space where the results of the graphics methods are displayed. Next is the middle layer where graphical objects and Label controls are displayed. The front layer is where all nongraphical controls like CommandButton, CheckBox, or ListBox are displayed. Anything contained in a layer closer to the front covers anything contained in the layer(s) behind it. ZOrder arranges objects only within the layer where the object is displayed.


AmbientProperties Object

An AmbientProperties object holds ambient information from a container to suggest behavior to controls contained within the container.

Remarks

Containers provide ambient properties in order to suggest behavior to controls. As an example, BackColor is one of the standard ambient properties; the container is suggesting what the well-behaved control should set its BackColor property to.

The AmbientProperties object’s properties are the ambient properties of the container. These properties are read-only.

Some ambient properties are standard, while others are specific to certain containers. A control may access non-standard ambient properties, but this will make the control container-specific. The control should handle the case where an ambient property is not present in the current container.

When the control is compiled, Visual Basic has no way of knowing what container-specific ambient properties may be available when the control is run; therefore references to container-specific ambient properties will always be late bound.

The AmbientProperties object is not available when the Initialize event is raised; but is available when the InitProperties event or ReadProperties event is raised.

The AmbientProperties object has several standard properties:

  • The BackColor property, a Color that contains the suggested interior color of the contained control. The Visual Basic supplied default if the container does not support this property is 0x80000005: the system color for a window background.

  • The DisplayAsDefault property, a Boolean that specifies if the control is the default control. The Visual Basic supplied default if the container does not support this property is False.

  • The DisplayName property, a String containing the name that the control should display for itself. The Visual Basic supplied default if the container does not support this property is an empty string: "".

  • The Font property, a Font object that contains the suggested font information of the contained control. The Visual Basic supplied default if the container does not support this property is MS Sans Serif 8.

  • The ForeColor property, a Color that contains the suggested foreground color of the contained control. The Visual Basic supplied default if the container does not support this property is 0x80000008: the system color for window text.

  • The LocaleID property, a Long that specifies the language and country of the user. The Visual Basic supplied default if the container does not support this property is the current system locale ID.

  • The MessageReflect property, a Boolean that specifies if the container supports message reflection. The Visual Basic supplied default if the container does not support this property is False.

  • The Palette property, a Picture object whose palette specifies the suggested palette for the contained control.

  • The RightToLeft property, a Boolean that indicates the text display direction and control visual appearance on a bidirectional system. The Visual Basic supplied default if the container does not support this property is False.

  • The ScaleUnits property, a String containing the name of the coordinate units being used by the container. The Visual Basic supplied default if the container does not support this property is an empty string: "".

  • The ShowGrabHandles property, a Boolean that specifies if the container handles the showing of grab handles. The Visual Basic supplied default if the container does not support this property is True.

  • The ShowHatching property, a Boolean that specifies if the container handles the showing of hatching. The Visual Basic supplied default if the container does not support this property is True.

  • The SupportsMnemonics property, a Boolean that specifies if the container handles access keys for the control. The Visual Basic supplied default if the container does not support this property is False.

  • The TextAlign property, an enumeration that specifies how text is to be aligned. The Visual Basic supplied default if the container does not support this property is 0 - General Align.

  • The UserMode property, a Boolean that specifies if the environment is in design mode or end user mode. The Visual Basic supplied default if the container does not support this property is True.

  • The UIDead property, a Boolean that specifies if the User Interface is unresponsive. The Visual Basic supplied default if the container does not support this property is False.

Note When you access the Font property of the AmbientProperties object, you do not get a reference to the container's font. Rather, you get a copy (clone) of the font.

The reason for this is that AmbientProperties.Font is commonly used to initialize a control's font whenever an instance of the control is added to a container. If a reference to the font itself were supplied, then changing the control's font would change the container's font as well.

If for some reason your control requires a reference to the container's font, you can obtain it by accessing the container through the Parent property of the UserControl object.


App Object

The App object is a global object accessed with the App keyword. It determines or specifies information about the application's title, version information, the path and name of its executable file and Help files, and whether or not a previous instance of the application is running.

Syntax

App


AsyncProperty Object

The AsyncProperty object is passed in to the AsyncReadComplete event and contains the results of the AsyncRead method.


Binding Object

Represents the run time binding of a specific data consumer property to a data field of a data source.

Syntax

Binding

Remarks

Each Binding object in the Binding collection represents the combination of a data consumer (such as a control) and a single property of the consumer (such as the Text property), bound to a specific data source field.


Class

A class is a template from which an object is created. Code in a class module describes the attributes and behavior of objects that are created from the class.

Although a class isn’t an object, it does have design-time properties that define its attributes and events that define its behavior.


Clipboard Object

Provides access to the system Clipboard.

Syntax

Clipboard

Remarks

The Clipboard object is used to manipulate text and graphics on the Clipboard. You can use this object to enable a user to copy, cut, and paste text or graphics in your application. Before copying any material to the Clipboard object, you should clear its contents by as performing a Clear method, such as Clipboard.Clear.

Note that the Clipboard object is shared by all Windows applications, and thus, the contents are subject to change whenever you switch to another application.

The Clipboard object can contain several pieces of data as long as each piece is in a different format. For example, you can use the SetData method to put a bitmap on the Clipboard with the vbCFDIB format, and then use the SetText method with the vbCFText format to put text on the Clipboard. You can then use the GetText method to retrieve the text or the GetData method to retrieve the graphic. Data on the Clipboard is lost when another set of data of the same format is placed on the Clipboard either through code or a menu command.


Control Object

The class name of all Visual Basic internal controls.

Syntax

Control

Remarks

You can dimension a variable as a Control object and reference it as you would a control on a form. The following demonstrates this:

Dim C as Control
Set C = Command1


Controls Collection Example

This example enables all currently loaded controls on a form (except menus).

Sub EnableControlsOn (Frm As Form, State As Integer)
   Dim I   ' Declare variable.
   For I = 0 To Frm.Controls.Count - 1
      If Not TypeOf Frm.Controls(I) Is Menu Then
         Frm.Controls(I).Enabled = State
      End If
   Next I
End Sub


DataBinding Object

The DataBinding object represents a bindable property of a component.

Syntax

DataBinding

Remarks

There is one DataBinding object for each property of a component marked as Bindable in the Procedure Attributes dialog box.

Visual Basic version 4.0 supported binding only one property of a control to a database at a time. Later versions of Visual Basic give you the ability to bind multiple properties of a control to a database. This is used most commonly with User controls. For more information on this, see Chapter 9 in "Creating ActiveX Components" in the Component Tools Guide.


DataBindingsCollection Object

DataBindings Collection

The DataBindings collection is an extender property that collects the bindable properties that are available to the developer and end-user.

Remarks

All bindable properties appear in the DataBindings collection at end user run time. At developer design time (control run time), only properties marked "Show in DataBindings collection at design time" will appear when the DataBindings property is accessed in the Properties window.


DataFormat Object

Supports the DataFormat property in simple bound objects like the TextBox control. This object is also required to support data formatting functionality in user-created bound controls.


DataFormats Collection

Supports the DataFormats property in complex bound objects like the DataGrid control. This object is also required to support data formatting functionality in user-created bound controls.


DataObject Object

The DataObject object is a container for data being transferred from an component source to an component target. The data is stored in the format defined by the method using the DataObject object.

Syntax

DataObject

Remarks

The DataObject, which mirrors the IDataObject interface, allows OLE drag and drop and clipboard operations to be implemented.

Most components support manual OLE drag and drop events, and some support automatic OLE drag and drop events.


DataReport Object

The DataReport object is the programmable object that represents the Data Report designer.

Syntax

DataReport

Remarks

The Data Report generates reports using records from a database. To use it:

  1. Configure a data source, such as the Microsoft Data Environment, to access a database.

  2. Set the DataSource property of the DataReport object to the data source.

  3. Set the DataMember property of the DataReport object to a data member.

  4. Right-click the designer and click Retrieve Structure.

  5. Add appropriate controls to the appropriate sections.

  6. Set the DataMember and DataField properties for each control.

  7. At run time, use the Show method to display the Data Report.

Use the DataReport object to programmatically change the appearance and behavior of the Data Report by changing the layout of each Section object.

The Data Report designer also features the ability to export reports using the ExportReport method. This method allows you to specify an ExportFormat object, from the ExportFormats collection, to use as a template for the report.


StdDataValue Object

Sets or returns the value after formatting is performed by the StdDataFormat object, or the value written to the database after any work done in the Unformat event.

Syntax

StdDataValue

Remarks

The StdDataValue object is passed to the Format and Unformat events of the StdDataFormat object. Using the StdDataValue object in these events allows you to provide formatting not supported by the StdDataFormat object.


DEAggregate Object

Defines an aggregate field within a DECommand object.

Syntax

DEAggregate


DECommand Object

Stores the design-time properties of an ADO Command object.

Syntax

DECommand

Remarks

This object corresponds to the ADO Command object.


DEConnection Object

Stores the design-time properties of an ADO Connection object.

Syntax

DEConnection

Remarks

This object corresponds to the ADO Connection object.


DEExtDesigner Object

The DEExtDesigner object exposes itself, and its contained collections, through an object model. The DEExtDesigner object is the top-level container object in the Data Environment object model. This object provides a container for a set of related DEConnection and DECommand objects and collections.

Syntax

DEExtDesigner

Remarks

You can easily define, modify, and use the DEExtDesigner object using the properties, methods, and events associated with each of the objects in the Data Environment object model.

Data Environment Object Model

The Data Environment object model closely matches how the objects are exposed through the user interface. While the Data Environment versions of Connection, Command, Field, and Parameter objects closely match, they are not ActiveX® Data Objects (ADO). The objects contained in the Data Environment are used to persist the design-time settings of these objects, and at run time they create true ADO objects, such as Connections, Commands, and Recordsets.

For example, the Data Environment object model does not directly expose the ADO Recordset object. Therefore, the DEFields collection in the Data Environment object model branches from DECommands, whereas in the ADO model it branches from the Recordset object.

At design time, you can programmatically set these properties using the Extensibility Object Model. In addition, you can set these properties when designing a DataEnvironment object using the Command and Connection Properties dialog boxes or Visual Basic's Properties window.


DEField Object

Stores the design-time properties of an ADO Field object.

Syntax

DEField

Remarks

This object corresponds to the ADO Field object.


DEParameter Object

Stores the design-time properties of an ADO Parameter object.

Syntax

DEParameter

Remarks

This object corresponds to the ADO Parameter object.


DERelationCondition Object

Defines the relation conditions between the child and parent Command objects of a relation hierarchy.

Syntax

DERelationCondition


EventInfo Object

Represents event information raised by a control assigned to a VBControlExtender object variable.

Syntax

EventInfo

Remarks

The EventInfo object is available in the ObjectEvent event, which is an event of the VBControlExtender object. In common practice, a control that is dynamically added to the Controls collection using the Add method will be assigned to an object variable of the type VBControlExtender. The ObjectEvent event can then be used to trap all events raised by the control, and the EventInfo object specifically represents any parameters passed by the raised events.

The EventInfo object has two properties: the Name property returns the name of the raised event; the EventParameters property returns a reference to the EventParameters collection that allows you to return values of all event parameters.


ExportFormat Object

Using the ExportFormat object, you can programmatically determine various attributes of text exported from a Data Report.

Syntax

ExportFormat

Remarks

When exporting a report using the ExportReport method, you must specify an ExportFormat object.


Extender Object

An Extender object holds properties of the control that are actually controlled by the container of the control rather than by the control itself.

Syntax

Extender

Remarks

Some properties of a control are provided by the container rather than the control; these are extender properties. Examples of extender properties are: Name, Tag and Left. The control still needs to know what the value of these extender properties are, and sometimes needs to be able to change an extender property; the Extender object gives the control access to these properties.

Some extender properties are standard, while others are specific to certain containers. A control may access non-standard extender properties, but this will make the control container-specific. If the control makes use of an extender property, the control should handle the case where the extender property is not supported by the current container.

When the control is compiled, Visual Basic has no way of knowing what extender properties may be available when the control is run; therefore references to extender properties will always be late bound.

The Extender object is not available when the Initialize event is raised; but is available when the InitProperties event or ReadProperties event is raised.

The Extender object has several standard properties:

  • The Name property, a read only String that contains the user-defined name of the control.

  • The Visible property, a read/write Boolean that specifies if the control is visible or not.

  • The Parent property, a read only object that represents the container of the control, such as a form in Visual Basic.

  • The Cancel property, a read only Boolean that indicates that the control is the default Cancel button for the container.

  • The Default property, a read only Boolean that indicates that the control is the default button for the container.

Visual Basic provides several more extender methods, properties and events; other containers are not guaranteed to provide these extender methods, properties and events. These Visual Basic specific extender methods, properties and events are:

  • The Container property, a read only object that represents the visual container of the control.

  • The DragIcon property, a read/write Picture that specifies the icon to use when the control is dragged.

  • The DragMode property, a read/write Integer that specifies if the control will automatically drag, or if the user of the control must call the Drag method.

  • The Enabled property, a read only Boolean that specifies if the control is enabled. This extender property is not present unless the control also has an Enabled property with the correct procedure ID. For additional information, refer to the topic "Allowing Your Controls to be Enabled and Disabled" in Chapter 9: Building ActiveX Controls.

  • The Height property, a read/write Integer that specifies the height of the control in the container’s scale units.

  • The HelpContextID property, a read/write Integer that specifies the context ID to use when the F1 key is pressed when the control has the focus.

  • The Index property, a read only Integer that specifies the position in a control array this instance of the control occupies.

  • The Left property, a read/write Integer that specifies the position of the left edge of the control to the left edge of the container, specified in the container’s scale units.

  • The TabIndex property, a read/write Integer that specifies the position of the control in the tab order of the controls in the container.

  • The TabStop property, a read/write Boolean that specifies if Tab will stop on the control.

  • The Tag property, a read/write String that contains a user-defined value.

  • The ToolTipText property, a read/write String that contains the text to be displayed when the cursor hovers over the control for more than a second.

  • The Top property, a read/write Integer that specifies the position of the top edge of the control to the top edge of the container, specified in the container’s scale units.

  • The WhatThisHelpID property, a read/write Integer that specifies the context ID to use when the What’s This pop-up is used on the control.

  • The Width property, a read/write Integer that specifies the width of the control in the container’s scale units.

  • The Drag method, a method to begin, end, or cancel a drag operation of the control.

  • The Move method, a method to move the position of the control.

  • The SetFocus method, a method to set the focus to the control.

  • The ShowWhatsThis method, a method to display a selected topic in a Help file using the What's This popup provided by Help.

  • The ZOrder method, a method to place the control at the front or back of the z-order within its graphical level.

  • The DragDrop event, an event that is raised when another control on the form is dropped on this control.

  • The DragOver event, an event that is raised when another control on the form is dragged over this control.

  • The GotFocus event, an event that is raised when this control gets the focus.

  • The LostFocus event, an event that is raised when this control loses the focus.


VBControlExtender Object

Represents the Visual Basic VBControlExtender properties.

Syntax

VBControlExtender

Remarks

The VBControlExtender object is primarily used when dynamically adding a control to the Controls collection using the Add method. The VBControlExtender object is particularly useful for this purpose because it provides a generic set of properties, events, and methods to the developer. Another feature of the object is the ObjectEvent event which is designed to parse any event raised by a dynamically added control. The example below declares an object variable as VBControlExtender, and sets the variable when adding a control. The example also shows how you can program the ObjectEvent event.

Option Explicit
Dim WithEvents objExt As VBControlExtender ' Declare VBControlExtender variable WithEvents

Private Sub LoadControl()
   Licenses.Add "Project1.Control1", "ewrinvcmcoe"
   Set objExt = Controls.Add("Project1.Control1", "myCtl")
   objExt.Visible = True ' The control is invisible by default.
End Sub

Private Sub extObj_ObjectEvent(Info As EventInfo)
   ' Program the events of the control using Select Case.
   Select Case Info.Name
   Case "Click"
      ' Handle Click event here.
   ' Other cases now shown
   Case Else ' Unknown Event
      ' Handle unknown events here.
   End Select
End Sub

Restrictions on Setting the References to the Variable

There is one caveat to be aware of when setting the VBControlExtender object to a dynamically added control: intrinsic controls cannot be set to the variable.


Font Object

The Font object contains information needed to format text for display in the interface of an application or for printed output.

Syntax

Font

Remarks

You frequently identify a Font object using the Font property of an object that displays text (such as a Form object or the Printer object).

You cannot create a Font object using code like Dim X As New Font. If you want to create a Font object, you must use the StdFont object like this:

Dim X As New StdFont

If you put a TextBox control named Text1 on a form, you can dynamically change its font Font object to another using the Set statement, as in the following example:

Dim X As New StdFont
X.Bold = True
X.Name = "Arial"
Set Text1.Font = X


Form Object, Forms Collection

A Form object is a window or dialog box that makes up part of an application's user interface.

A Forms collection is a collection whose elements represent each loaded form in an application. The collection includes the application's MDI form, MDI child forms, and non-MDI forms. The Forms collection has a single property, Count, that specifies the number of elements in the collection.

Syntax

Form

Forms(index)

The placeholder index represents an integer with a range from 0 to Forms.Count - 1.

Remarks

You can use the Forms collection to iterate through all loaded forms in an application. It identifies an intrinsic global variable named Forms. You can pass Forms(index) to a function. whose argument is specified as a Forms class.

Forms have properties that determine aspects of their appearance, such as position, size, and color; and aspects of their behavior, such as whether or not they are resizable.

Forms can also respond to events initiated by a user or triggered by the system. For example, you could write code in a form's Click event procedure that would enable the user to change the color of a form by clicking it.

In addition to properties and events, you can use methods to manipulate forms using code. For example, you can use the Move method to change a form's location and size.

A special kind of form, the MDI form, can contain other forms called MDI child forms. An MDI form is created with the MDI Form command on the Insert menu; an MDI child form is created by choosing New Form from the File menu and then setting the MDIChild property to True.

You can create multiple instances of forms in code by using the New keyword in Dim, Set, and Static statements.

When designing forms, set the BorderStyle property to define a form's border, and set the Caption property to put text in the title bar. In code, you can use the Hide and Show methods to make forms invisible or visible at run time.

Note Setting BorderStyle to 0 removes the border. If you want your form to have a border without the title bar, Control-menu box, Maximize button, and Minimize button, delete any text from the form's Caption property, and set the form's ControlBox, MaxButton, and MinButton properties to False.

Form is an Object data type. You can declare variables as type Form before setting them to an instance of a type of form that was declared at design time. Similarly, you can pass an argument to a procedure as type Form.

Forms also can act as sources in a DDEconversation, with a Label, PictureBox, or TextBox control furnishing the data.

You can access the collection of controls on a Form using the Controls collection. For example, to hide all the controls on an Form you can use code similar to the following:

For Each Control in Form1.Controls
   Control.Visible = False
Next Control


Forms Collection Example

This example fills a list box with the captions of all the currently loaded forms.

Private Sub Form_Activate ()
   Dim I   ' Declare variable.
   ' Refill list (in case an instance was added or removed).
   lstForms.Clear   ' Clear list box.
   For I = 0 To Forms.Count - 1
      lstForms.AddItem Forms(I).Caption
   Next I
End Sub


Global Object

A Global object is an application object that enables you to access application-level properties and methods.

Syntax

Global

Remarks

Global is an Object data type. Because the Global object is an application object that is referenced automatically, it is not necessary to code a specific reference to this object.


Hyperlink Object

Using the properties and methods of the Hyperlink object, your ActiveX document or ActiveX control can request a hyperlink-aware container, such as Microsoft Internet Explorer, to jump to a given URL.

Remarks

Use the NavigateTo method to jump to a URL. For example, the following code presumes an ActiveX document named "axdMyDoc" exists:

UserDocument.Hyperlink.NavigateTo _
"c:\mydocs\axdmydoc.vbd"

If your ActiveX document is contained by a hyperlink-aware container (such as Internet Explorer), and if the container maintains a history of documents, use the GoBack or GoForward methods to go backwards or forwards through the list. However, be sure to use error-checking, as shown in the example below:

Private Sub cmdGoForward_Click()
   On Error GoTo noDocInHistory
   UserDocument.Hyperlink.GoForward
   Exit Sub
noDocInHistory:
   Resume Next
End Sub


LicenseInfo Object

Represents the license key and programmatic ID (progID) of a control.

Syntax

LicenseInfo

Remarks

When adding a control that requires a license key to the Controls collection, you must first add the control's license to the Licenses collection. Using the Add method, each pair of license key and progID become properties of the LicenseInfo object.

To determine the license key and progId of each control, use the For Each statement with the LicenseInfo object, as shown below:

Dim li As LicenseInfo
For Each li in Licenses
   Debug.Print li.ProgID, li.LicenseKey
Next


MDIForm Object

An MDI (multiple-document interface) form is a window that acts as the background of an application and is the container for forms that have their MDIChild property set to True.

Syntax

MDIForm

Remarks

You create an MDIForm object by choosing MDI Form from the Insert menu.

An application can have only one MDIForm object but many MDI child forms. If an MDI child form has menus, the child form's menu bar automatically replaces the MDIForm object's menu bar when the MDI child form is active. A minimized MDI child form is displayed as an icon within the MDIForm.

An MDIForm object can contain only Menu and PictureBox controls and custom controls that have an Align property. To place other controls on an MDIForm, you can draw a picture box on the form, and then draw other controls inside the picture box. You can use the Print method to display text in a picture box on an MDIForm, but you can't use this method to display text on the MDIForm itself.

An MDIForm object can't be modal.

MDI child forms are designed independently of the MDIForm, but are always contained within the MDIForm at run time.

You can access the collection of controls on an MDIForm using the Controls collection. For example, to hide all the controls on an MDIForm you can use code similar to the following:

For Each Control in MDIForm1.Controls
   Control.Visible = False
Next Control

The Count property of the MDIForm tells you the number of controls in the Controls collection.


OLE Container Control

The OLE container control enables you to add insertable objects to the forms in your Visual Basic applications. With the OLE container control, you can:

  • Create a placeholder in your application for an insertable object. At run time you can create the object that is displayed within the OLE container control or change an object you placed within the OLE container control at design time.

  • Create a linked object in your application.

  • Bind the OLE container control to a database using the Data control.

You either create the object at design time using the Insert Object dialog box (which contains the commands Insert Object, Paste Special, and so on), or at run time by setting the appropriate properties.

When you move an OLE container control on a form using the ObjectMove method, the Height and Width property values of the object may be slightly different after the move. This is because the parameters to the ObjectMove method are pixel values converted to the current form's scaling mode. The conversion from pixels to twips and back doesn't always result in identical values.

Using the OLE Container Control's Pop-up Menus

Each time you draw an OLE container control on a form, the Insert Object dialog box is displayed. Use this dialog box to create a linked or embedded object. If you choose Cancel, no object is created.

At design time, click the OLE container control with the right mouse button to display a pop-up menu. The commands displayed on this pop-up menu depend on the state of the OLE container control as shown in the following table:

Command | Enabled in pop-up menu when
Insert Object | Always enabled.
Paste Special | Clipboard object contains a valid object.
Delete Embedded Object | OLE container control contains an embedded object.
Delete Linked Object | OLE container control contains a linked object.
Create Link | SourceDoc property is set.
Create Embedded Object | Class or SourceDoc property is set.

An OLE container control can contain only one object at a time. You can create a linked or embedded object in several ways:

  • Use the Insert Object or Paste Special dialog boxes (run time or design time).

  • Set the Class property in the Properties window, click the OLE container control with the right mouse button, and then select the appropriate command (design time only).

  • Use the appropriate method of the OLE container control.

Finding Class Names

You can get a list of the class names available to your application by selecting the Class property in the Properties window and clicking the Properties button.

Note The Insert Object dialog box doesn't display a list of class names. This dialog box displays user-friendly names for each class of object, which are generally longer and more easily understood.


EventParameter Object

Represents a control event parameter.

Syntax

EventParameter

Remarks

The EventParameter object is used to evaluate and return the values contained by an event of a control that has been dynamically added to the Controls collection.

The EventParameters collection is part of the EventInfo object.

The EventParameter object has two properties: Name and Value. The Name property returns the name of a parameter. You can then evaluate and set the Value property as appropriate.


Picture Object

The Picture object enables you to manipulate bitmaps, icons, metafiles enhanced metafiles, GIF, and JPEG images assigned to objects having a Picture property.

Syntax

Picture

Remarks

You frequently identify a Picture object using the Picture property of an object that displays graphics (such as a Form object or a PictureBox control). If you have a PictureBox control named Picture1, you can set one Picture object equal to another using the Set statement, as in the following example:

Dim X As Picture
Set X = LoadPicture("PARTY.BMP")
Set Picture1.Picture = X

You can use an array of Picture objects to keep a series of graphics in memory without needing a form that contains multiple PictureBox or Image controls.

You can not create a Picture object using code like Dim X As New Picture. If you want to create a Picture object, you must use the StdPicture object like this:

Dim X As New StdPicture


Printer Object, Printers Collection

The Printer object enables you to communicate with a system printer (initially the default system printer).

The Printers collection enables you to gather information about all the available printers on the system.

Syntax

Printer

Printers(index)

The index placeholder represents an integer with a range from 0 to Printers.Count-1.

Remarks

Use graphics methods to draw text and graphics on the Printer object. Once the Printer object contains the output you want to print, you can use the EndDoc method to send the output directly to the default printer for the application.

You should check and possibly revise the layout of your forms if you print them. If you use the PrintForm method to print a form, for example, graphical images may be clipped at the bottom of the page and text carried over to the next page.

The Printers collection enables you to query the available printers so you can specify a default printer for your application. For example, you may want to find out which of the available printers uses a specific printer driver. The following code searches all available printers to locate the first printer with its page orientation set to Portrait, then sets it as the default printer:

Dim X As Printer
For Each X In Printers
   If X.Orientation = vbPRORPortrait Then
      ' Set printer as system default.
      Set Printer = X
      ' Stop looking for a printer.
      Exit For
   End If
Next

You designate one of the printers in the Printers collection as the default printer by using the Set statement. The preceding example designates the printer identified by the object variable X, the default printer for the application.

Note If you use the Printers collection to specify a particular printer, as in Printers(3), you can only access properties on a read-only basis. To both read and write the properties of an individual printer, you must first make that printer the default printer for the application.


PropertyBag Object

A PropertyBag object holds information that is to be saved and restored across invocations of an object.

Remarks

A PropertyBag object is passed into an object through the ReadProperties event and the WriteProperties event in order to save and restore the state of the object. Using the methods of the PropertyBag object, the object can read or write properties of itself. The ReadProperty method of the PropertyBag object is used to read a value for a property, while the WriteProperty method of the PropertyBag object is used to write a value of a property. The value of a property can itself be an object; in that case the PropertyBag object will attempt to save it.


PropertyPage Object

The base object used to create an ActiveX Property Page.

Remarks

Property pages provide an alternative to the Properties window for viewing properties. You can group several related properties on a page, or use a page to provide a dialog-like interface for a property that’s too complex for the Properties window. A PropertyPage object represents one page, which is to say one tab in the Property Pages dialog box.


Error Object (Data Report Designer)

An Error object contains details about run time errors.

Syntax

RptError


Section Object (Data Report Designer)

The Section object represents a section of the Data Report designer.

Syntax

Section

Remarks

You must use standard collection syntax to retrieve a reference to a Section object and any controls on the Data Report designer. The example below retrieves the name of the third control on the second section of the Section object:

Debug.Print DataReport1.Sections(2).Controls(3).Name


Screen Object

Manipulates forms according to their placement on the screen and controls the mouse pointer outside your application's forms at run time. The Screen object is accessed with the keyword Screen.

Syntax

Screen

Remarks

The Screen object is the entire Windows desktop. Using the Screen object, you can set the MousePointer property of the Screen object to the hourglass pointer while a modal form is displayed.


StdDataFormat Object

The StdDataFormat object allows formatting to be applied to data as it is read from and written to a database.

Syntax

StdDataFormat

Remarks

The StdDataFormat object is an integral part of data binding. It is created for any bound control, regardless of whether you create one in code.


StdDataFormats Collection

The StdDataFormats collection contains one or more StdDataFormat objects.

Remarks

Complex bound controls can be bound to multiple StdDataFormat objects. The DataGrid, for example, has one binding per column. The StdDataFormats collection provides a top-level object through which you can access multiple format objects.


WebItem Object

Represents an HTML template or custom WebItem attached to a WebClass object. A WebItem processes and/or responds to an HTTP request.

Syntax

WebItem

Remarks

You can access a WebItem object directly from the WebClass object using:

Me.WebItem1

Or, more simply:

WebItem1

An HTML template is a WebItem that references an HTML file. This is returned as the HTTP response. A custom WebItem contains user-written code in its Response method that creates the HTTP response.


WebItemProperties Object

Contains a collection of user-defined properties associated with a WebItem object.

Syntax

WebItemProperties

Remarks

You define the properties in this collection. The WebItemProperties object is a property of a WebItem. It is a collection of Variants which can be used to organize state within a wcRetainInstance WebClass, on a per-WebItem basis.

Example

Dim UserName As String
WebItem1.Properties("User Name") = "Someone"


UserControl Object

The UserControl object is the base object used to create an ActiveX control.

Remarks

An ActiveX control created with Visual Basic is always composed of a UserControl object, plus any controls — referred to as constituent controls — that you choose to place on the UserControl.

Like Visual Basic forms, UserControl objects have code modules and visual designers. Place constituent controls on the UserControl object’s designer, just as you would place controls on a form.


UserDocument Object

The base object of an ActiveX document, the UserDocument object resembles a standard Visual Basic Form object with some exceptions.

Remarks

The UserDocument object has most, but not all, of the events that are found on a Form object. The events present on a Form that are not found on the UserDocument include: Activate, Deactivate, LinkClose, LinkError, LinkExecute, LinkOpen, Load, QueryUnload, and Unload events.

Events present on the UserDocument, but not found on a Form object include: AsyncReadComplete, EnterFocus, ExitFocus, Hide, InitProperties, ReadProperties, Scroll, Show, and WriteProperties events.

You cannot place embedded objects (such as an Excel or Word document) or an OLE Container control on a UserDocument.


WebClass

WebClass Object

Contains WebItems (typically HTML documents) that are sent to a Web browser in response to HTTP requests.

Syntax

WebClass

Remarks

A WebClass object resides on a Web server. You use it to intercept HTTP requests in order to process associated Visual Basic code and return an HTML document or other WebItems to the browser.


WebClassError Object

When processing a FatalErrorResponse event, this object indicates what error occurred.

Syntax

WebClassError

You can access this object directly from the WebClass object as:

Me.Error

Or more simply:

Error


AccessKeys Property

Returns or sets a string that contains the keys that will act as the access keys (or hot keys) for the control.

Syntax

object.AccessKeys [= AccessKeyString]

The AccessKeys property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
AccessKeyString | A string containing the keys that will act as the access keys.

Remarks

The AccessKeys property is a string that contains all the access keys for the control. As an example, to set the letters S and Y as the access keys, the AccessKeys property would be set to "sy".

When a user presses one of the access keys in conjunction with the ALT key, the control will get the focus (depending on the setting of the ForwardFocus property).

Access keys for constituent controls are implicitly included as AccessKeys, although they will not appear in the AccessKeys property.


Action Property (OLE Container)

Sets a value that determines an action. Not available at design time.

Note The Action property is included for compatibility with earlier versions. For current functionality, use the methods listed in Settings.

Syntax

object.Action = value

The Action property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A constant or integer specifying the type of action, as described in Settings.

Settings

The settings for value are:

Value | Description | Current method
0 | Creates an embedded object. | CreateEmbed
1 | Creates a linked object from the contents of a file. | CreateLink
4 | Copies the object to the system Clipboard. | Copy
5 | Copies data from the system Clipboard to an OLE container control. | Paste
6 | Retrieves the current data from the application that supplied the object and displays that data as a picture in the OLE container control. | Update
7 | Opens an object for an operation, such as editing. | DoVerb
9 | Closes an object and terminates the connection to the application that provided the object. | Close
10 | Deletes the specified object and frees the memory associated with it. | Delete
11 | Saves an object to a data file. | SaveToFile
12 | Loads an object that was saved to a data file. | ReadFromFile
14 | Displays the Insert Object dialog box. | InsertObjDlg
15 | Displays the Paste Special dialog box. | PasteSpecialDlg
17 | Updates the list of verbs an object supports. | FetchVerbs

18 Saves an object to the OLE version 1.0 file format. SaveToOle1File


ActiveControl Property

Returns the control that has the focus. When a form is referenced, as in ChildForm.ActiveControl, ActiveControl specifies the control that would have the focus if the referenced form were active. Not available at design time; read-only at run time.

Syntax

object.ActiveControl

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You can use ActiveControl to access a control's properties or to invoke its methods: For example, Screen.ActiveControl.Tag = "0". A run-time error occurs if all controls on the form are invisible or disabled.

Each form can have an active control (Form.ActiveControl), regardless of whether or not the form is active. You can write code that manipulates the active control on each form in your application even when the form isn't the active form.

This property is especially useful in a multiple-document interface (MDI) application where a button on a toolbar must initiate an action on a control in an MDI child form. When a user clicks the Copy button on the toolbar, your code can reference the text in the active control on the MDI child form, as in ActiveForm.ActiveControl.SelText.

Note If you plan to pass Screen.ActiveControl to a procedure, you must declare the argument in that procedure with the clause As Control rather than specifying a control type (As TextBox or As ListBox) even if ActiveControl always refers to the same type of control.


ActiveControl Property Example

This example displays the text of the active control. To try this example, paste the code into the Declarations section of a form that contains TextBox, Label, and CommandButton controls, and then press F5 and click the form.

Private Sub Form_Click ()
   If TypeOf Screen.ActiveControl Is TextBox Then
      Label1.Caption = Screen.ActiveControl.Text
   Else
      Label1.Caption = "Button: " + Screen.ActiveControl.Caption
   End If
End Sub

This example shows how you can use the Clipboard object in cut, copy, paste, and delete operations using buttons on a toolbar. To try this example, put TextBox and CheckBox controls on Form1, and then create a new MDI form. On the MDI form, insert a PictureBox control, and then insert a CommandButton in the PictureBox. Set the Index property of the CommandButton to 0 (creating a control array). Set the MDIChild property of Form1 to True.

To run the example, copy the code into the Declarations section of the MDIForm, and then press F5. Notice that when the CheckBox has the focus, the buttons don't work, since the CheckBox is now the active control instead of the TextBox.

Private Sub MDIForm_Load ()
   Dim I   ' Declare variable.
   Command1(0).Move 0, 0, 700, 300   ' Position button on toolbar.
   For I = 1 To 3   ' Create other buttons.
      Load Command1(I)   ' Create button.
      Command1(I).Move I * 700, 0, 700, 300  ' Place and size button.
      Command1(I).Visible = True   ' Display button.
   Next I
   Command1(0).Caption = "Cut"   ' Set button captions.
   Command1(1).Caption = "Copy"
   Command1(2).Caption = "Paste"
   Command1(3).Caption = "Del"
End Sub

Private Sub Command1_Click (Index As Integer)
   ' ActiveForm refers to the active form in the MDI form.
   If TypeOf ActiveForm.ActiveControl Is TextBox Then
      Select Case Index
         Case 0   ' Cut.
            ' Copy selected text onto Clipboard.
            Clipboard.SetText ActiveForm.ActiveControl.SelText
            ' Delete selected text.
            ActiveForm.ActiveControl.SelText = ""
         Case 1   ' Copy.
            ' Copy selected text onto Clipboard.
            Clipboard.SetText ActiveForm.ActiveControl.SelText
         Case 2   ' Paste.
            ' Put Clipboard text in text box.
            ActiveForm.ActiveControl.SelText = Clipboard.GetText()
         Case 3   ' Delete.
            ' Delete selected text.
            ActiveForm.ActiveControl.SelText = ""
      End Select
   End If
End Sub


ActiveForm Property

Returns the form that is the active window. If an MDIForm object is active or is referenced, it specifies the active MDI child form.

Syntax

object.ActiveForm

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use the ActiveForm property to access a form's properties or to invoke its methods — for example, Screen.ActiveForm.MousePointer = 4.

This property is especially useful in a multiple-document interface (MDI) application where a button on a toolbar must initiate an action on a control in an MDI child form. When a user clicks the Copy button on the toolbar, your code can reference the text in the active control on the MDI child form — for example, ActiveForm.ActiveControl.SelText.

When a control on a form has the focus, that form is the active form on the screen (Screen.ActiveForm). In addition, an MDIForm object can contain one child form that is the active form within the context of the MDI parent form (MDIForm.ActiveForm). The ActiveForm on the screen isn't necessarily the same as the ActiveForm in the MDI form, such as when a dialog box is active. For this reason, specify the MDIForm with ActiveForm when there is a chance of a dialog box being the ActiveForm property setting.

Note When an active MDI child form isn't maximized, the title bars of both the parent form and the child form appear active.

If you plan to pass Screen.ActiveForm or MDIForm.ActiveForm to a procedure, you must declare the argument in that procedure with the generic type (As Form) rather than a specific form type (As MyForm) even if ActiveForm always refers to the same type of form.

The ActiveForm property determines the default value for the ProjectTemplate object.


ActiveForm Property Example

This example prints the time on the active child form in an MDIForm object. To try this example, create an MDIForm, draw a PictureBox control on it and a CommandButton control in the PictureBox. In Form1, set the MDIChild property to True. (You can also set AutoRedraw to True to keep text on the form even after covering it with another form.) Paste the appropriate code into the Declarations section of each form, and then press F5.

' Copy all code into the MDI form.
Private Sub MDIForm_Load ()
   Dim NewForm As New Form1   ' Create new instance of Form1.
   NewForm.Show
End Sub

Private Sub Command1_Click ()
   ' Print the time on the active form.
   ActiveForm.Print "The time is " & Format(Now, "Long Time")
End Sub

This example shows how you can use the Clipboard object in cut, copy, paste, and delete operations using buttons on a toolbar. To try this example, create a new project, then put TextBox and CheckBox controls on Form1, and then create a new MDI form. On the MDI form, place a PictureBox control, and then insert a CommandButton control in the PictureBox. Set the Index property of the CommandButton to 0 (creating a control array). Set the MDIChild property of Form1 to True.

To run the example, copy the code into the Declarations section of the MDIForm, and then press F5. Notice that when the CheckBox has the focus, the buttons don't work, since the CheckBox is now the active control instead of the TextBox.

Private Sub MDIForm_Load ()
   Dim I         ' Declare variable.
   Command1(0).Move 0, 0, 700, 300   ' Position button on toolbar.
   For I = 1 To 3   ' Create other buttons.
      Load Command1(I)   ' Create button.
      Command1(I).Move I * 700, 0, 700, 300 ' Place and size button.
      Command1(I).Visible = True   ' Display button.
   Next I
   Command1(0).Caption = "Cut"   ' Set button captions.
   Command1(1).Caption = "Copy"
   Command1(2).Caption = "Paste"
   Command1(3).Caption = "Del"
End Sub

Private Sub Command1_Click (Index As Integer)
   ' ActiveForm refers to the active form in the MDI form.
   If TypeOf ActiveForm.ActiveControl Is TextBox Then
      Select Case Index
         Case 0   ' Cut.
            ' Copy selected text to Clipboard.
            Clipboard.SetText ActiveForm.ActiveControl.SelText
            ' Delete selected text.
            ActiveForm.ActiveControl.SelText = ""
         Case 1   ' Copy.
            ' Copy selected text to Clipboard.
            Clipboard.SetText ActiveForm.ActiveControl.SelText
         Case 2   ' Paste.
            ' Put Clipboard text in text box.
            ActiveForm.ActiveControl.SelText = Clipboard.GetText()
         Case 3   ' Delete.
            ' Delete selected text.
            ActiveForm.ActiveControl.SelText = ""
      End Select
   End If
End Sub


ActXDoc (ActXDoc.vbp)

The ActXDoc is a simple ActiveX document-based application. Two ActiveX documents (FirstDoc.vbd, and SecndDoc.vbd) incorporate features such as passing data from one document to another, as well as use of the HyperLink object. See , "Creating an ActiveX Document," in "Creating ActiveX Components" of the Component Tools Guide.

File | Description
FrmAbout.frx | Binary data for the frmAbout.frm.
FrmAbout.frm | An About Box for the ActiveX document.
FrmAux.frm | An auxiliary form shown from the FirstDoc ActiveX document.
mGlobal.bas | Code module that contains global constants.
Actxdoc.vbp | The project file for the application.
FirstDoc.dob | The UserDocument object for the FirstDoc ActiveX document.
Secnddoc.dob | The UserDocument for the SecndDoc ActiveX document.

To Run

From the Visual Basic File menu, click Open Project and select the ActXDoc.Vbp file, which is listed in the Samples directory. Press F5 to run the application.

Run Internet Explorer 3.0 or later, click Address, and type the path of the FirstDoc.vbd file.


AggregateOn Property

Returns or sets the name of the child DECommand object on which the aggregation is based. To use this property, the AggregateType must be set to deRelation.

Note You must use a child DECommand object when creating aggregates in the Data Environment.

Syntax

object.AggregateOn [=string]

The AggregateOn property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that defines the name of the DECommand object on which the aggregation is based.


AggregateType Property

Returns or sets the type of aggregation.

Syntax

object.AggregateType [=value]

The AggregateType property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies the type of aggregate, as described in Settings.

Settings

The settings for value are:

Constant | Description
deGrouping | Grouping. This is only available if the DECommand object is grouped. The FieldToAggregate item can be any field in the current DECommand object. This is because grouping a DECommand object creates two Recordsets: one contains the grouped fields and the other contains the non-grouped fields.
deRelation | Relation. The FieldToAggregate item can be any field of the DECommand object that is specified in the AggregateOn property.
deGrandTotal | Grand Total. This is only available if the DECommand object is the top-most Command in a hierarchy. If the DECommand object is grouped, only the grouping fields are available. If ungrouped, all fields are available.


Align Property

Returns or sets a value that determines whether an object is displayed in any size anywhere on a form or whether it's displayed at the top, bottom, left, or right of the form and is automatically sized to fit the form's width.

Syntax

object.Align [= number]

The Align property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | An integer that specifies how an object is displayed, as described in Settings.

Settings

The settings for number are:

Constant | Setting | Description
VbAlignNone | 0 | (Default in a non-MDI form) None — size and location can be set at design time or in code. This setting is ignored if the object is on an MDI form.
VbAlignTop | 1 | (Default in an MDI form) Top — object is at the top of the form, and its width is equal to the form's ScaleWidth property setting.
VbAlignBottom | 2 | Bottom — object is at the bottom of the form, and its width is equal to the form's ScaleWidth property setting.
VbAlignLeft | 3 | Left — object is at the left of the form, and its width is equal to the form's ScaleWidth property setting.
VbAlignRight | 4 | Right — object is at the right of the form, and its width is equal to the form's ScaleWidth property setting.

Remarks

You can use the Align property to quickly create a toolbar or status bar at the top or bottom of a form. As a user changes the size of the form, an object with Align set to 1 or 2 automatically resizes to fit the width of the form.

PictureBox and Data controls are the only standard controls that can be placed on an MDI form. The internal area of an MDI form is defined by the space not covered by controls. When an MDI child form is maximized within the parent MDI form, it won't cover any controls.

Use number settings 3 and 4 to align toolbars at the left and right sides of a form or MDI form. If there are two toolbars in a corner of an MDI form, the top- or bottom-aligned one extends to the corner, taking precedence over the left- or right-aligned one. Left- and right-aligned objects occupy the internal area on an MDI form, just like top- and bottom-aligned objects.


Alignable Property

Returns or sets a value determining if a control is alignable, and can use the extender Align property. The Alignable property is read/write at the control’s authoring time, and not available at run time.

Settings

The settings for Alignable are:

Setting | Description
True | The control is alignable; the container will add the Align property to the extender object.
False | (Default) The control is not alignable.

Remarks

The alignment of the control itself will be handled by the container; the author of the control can use the Align extender property to decide how to redraw the control and arrange the constituent controls in response to an alignment.

Note Not all containers support alignable controls. Error trapping should be used if you access the Align extender property to determine how your control has been aligned.


Alignment Property

Returns or sets a value that determines the alignment of a CheckBox or OptionButton control, text in a control, or values in a column of a DataGrid control. Read-only at run time for CheckBox, OptionButton, and TextBox controls.

Syntax

object.Alignment [= number]

The Alignment property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | An integer that specifies the type of alignment, as described in Settings.

Settings

For CheckBox and OptionButton controls, the settings for number are:

Constant | Setting | Description
VbLeftJustify | 0 | (Default) Text is left-aligned; control is right-aligned.
VbRightJustify | 1 | Text is right-aligned; control is left-aligned.

For Label and TextBox controls, the settings for number are:

Constant | Setting | Description
VbLeftJustify | 0 | (Default) Text is left-aligned.
VbRightJustify | 1 | Text is right-aligned.
VbCenter | 2 | Text is centered.

For a DataGrid column, the settings for number are:

Constant | Setting | Description
DbgLeft | 0 | Text is left-aligned.
DbgRight | 1 | Text is right-aligned.
DbgCenter | 2 | Text is centered.
DbgGeneral | 3 | (Default) General — Text is left-aligned; numbers are right-aligned.

Remarks

You can display text to the right or left of OptionButton and CheckBox controls. By default, text is left-aligned.

The MultiLine property in a Textbox control must be set to True for the Alignment property to work correctly. If the MultiLine property setting of a TextBox control is False, the Alignment property is ignored.


Align Property Example

This example uses a PictureBox control as a toolbar on an MDIForm object, with a CommandButton control to move the PictureBox from the top to the bottom of the form. To try this example, create a new MDIForm and set the MDIChild property of Form1 to True. Draw a PictureBox on the MDIForm, and put a CommandButton on the PictureBox. Paste the code into the Declarations section of the MDIForm, and then press F5. Click the CommandButton to move the PictureBox.

Private Sub Command1_Click ()
   If Picture1.Align = vbAlignTop Then
      Picture1.Align = vbAlignBottom
  ' Align to bottom of form.
   Else
      Picture1.Align = vbAlignTop
  ' Align to top of form.
   End If
End Sub


Ambient Property

Returns an AmbientProperties object holding the ambient properties of the container. The Ambient property is not available at the control’s authoring time, and read-only at the control’s run time.

Syntax

object.Ambient

The Ambient property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.


URLData Property

Sets or returns a parameter that is appended to the end of any URL generated using the URLFor method or discovered during WriteTemplate processing.

Syntax

object.URLData[=string]

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | Information that is appended to the end of URLs generated by a WebClass.

Remarks

This information is appended automatically to each URL discovered during HTML template processing using the WriteTemplate method and by calls to the URLFor method. You can store state information in the appended parameter. The state can be retrieved in subsequent calls using the Request.QueryString collection.


AppIsRunning Property

Returns or sets a value that indicates whether the application that created the object in the OLE container control is running. Not available at design time.

Syntax

object.AppIsRunning [= boolean]

The AppIsRunning property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying whether or not the application that produced the object in the OLE container control is running, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | The application that produced the object in the OLE container control is running.
False | The application that produced the object in the OLE container control isn't running.

Remarks

You can set the value of the AppIsRunning property to start the application that produces the object in the OLE container control. Doing this causes objects to activate more rapidly. You can also set this property to False to close the application when the object loses the focus.


Application Property (WebClass)

Returns the Active Server Pages Application object.

Syntax

object.Application

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

A WebClass uses the Application object to manage state that is shared across multiple WebClass object instances.

See the Active Server Pages documentation for details of the properties, methods, and events for the Application object.


App Property

Returns the App object, a global object accessed with the App keyword. It determines or specifies information about the application's title, version information, the path and name of its executable file and Help files, and whether or not a previous instance of the application is running.

Syntax

App

Remarks

The App object has no events or methods.


Archive, Hidden, Normal, System Properties

Return or set a value that determines whether a FileListBox control displays files with Archive, Hidden, Normal, or System attributes.

Syntax

object.Archive [= boolean]

object.Hidden [= boolean]

object.Normal [= boolean]

object.System [= boolean]

The Archive, Hidden, Normal, and System property syntaxes have these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression that specifies the type of files displayed, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default for Archive and Normal) Displays files with the property's attribute in the FileListBox control.
False | (Default for Hidden and System) Displays files without the property's attribute in the FileListBox control.

Remarks

Use these properties to specify the type of files to display in a FileListBox control, based on standard file attributes used in the operating environment. Setting any of these properties with code at run time resets the FileListBox control to display only those files with the specified attributes.

For example, in a find-and-replace operation you could display only system files by setting the System property to True and the other properties to False. Or, as part of a file backup procedure, you could set the Archive property to True to list only those files modified since the previous backup.


AsyncCount Property

Returns the number of asynchronous operations still executing.

Syntax

object.AsyncCount

The object placeholder is an object expression that evaluates to an object in the Applies To list.

Return Type

Integer

Remarks

Query the AsyncCount property before closing the Data Report designer to determine the number of operations still executing. You may want to cancel closing the designer until all operations have finished.


AsyncCount Property Example

The example invokes the ExportReport method and queries the AsyncCount property in a While loop to determine if any asynchronous operations are still executing. When all are done, the DataReport object is unloaded.

DataReport1.ExportReport rptKeyText, "c:\MyDocuments\Report", True
While DataReport1.AsyncCount > 0
   DoEvents
Wend
Unload DataReport1


AsyncType Property

Returns or sets the type of the data returned by the Value property. This property is available only as an argument of the AsyncRead method.

Syntax

object.AsyncType = dataType

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
dataType | An integer specifying the data type, as shown in Settings below.

Settings

The settings for dataType are:

Constant | Value | Description
vbAsyncTypePicture | 0 | Default. Picture object.
VbAsyncTypeFile | 1 | The data is provided in a file created by Visual Basic.
VbAsyncTypeByteArray | 2 | The data is provided as a byte array that contains the retrieved data.


ATM (ATM.vbp)

The ATM.vbp sample application demonstrates how to use a resource file. This application produces the screen for an automated teller machine (ATM) that lets the user perform a bank transaction in one of several languages, such as English, French, or German.

Background

The ATM.vbp sample prompts the user to specify the language to conduct the transaction in. Depending on the user's choice, the sample loads the appropriate group of resources from the ATM.res file to continue the transaction. For more information, see , "Managing Projects," in the Programmer's Guide.

File | Description
Atm.bas | Module containing procedures for the sample.
Atm.rc | Resource source file containing all localized strings and references to ICO and WAV files, which are built into ATM.RES.
Atm.res | Resource file containing text, icons, and sound (.WAV) data. Results from running a resource compiler on the ATM.RC file.
ATM.vbp | The project file for this sample.
ATM32.res | File containing resources for 32-bit systems.
FrmAmoun.frm | Form showing conversion of currencies into dollars.
FrmInput.frm | Form for input of user information
Openbank.frm | Form for selecting a language.
Openbank.frx | Binary data for the OPENBANK.FRM.

To Run

From the Visual Basic File menu, choose Open Project and select the ATM.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


Attributes Property (DEDesigner Extensibility)

When associated with a DEConnection object, returns or sets any extra attributes needed for the connection string associated with a DEConnection object.

Syntax

object.Attributes [=string]

The Attributes property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that provides any extra attributes needed.


Appearance Property

Returns or sets the paint style of controls on an MDIForm or Form object at design time. Read-only at run time.

Syntax

object.Appearance

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The Appearance property settings are:

Setting | Description
0 | Flat. Paints controls and forms without visual effects.
1 | (Default) 3D. Paints controls with three-dimensional effects.

Remarks

If set to 1at design time, the Appearance property draws controls with three-dimensional effects. If the form's BorderStyle property is set to Fixed Double (vbFixedDouble, or 3), the caption and border of the form are also painted with three-dimensional effects. Setting the Appearance property to 1 also causes the form and its controls to have their BackColor property set to the color selected for 3D Objects in the Appearance tab of the operating system's Display Properties dialog box.

Setting the Appearance property to 1 for an MDIForm object affects only the MDI parent form. To have three-dimensional effects on MDI child forms, you must set each child form's Appearance property to 1.


AutoActivate Property

Returns or sets a value that enables the user to activate an object by double-clicking the OLE container control or by moving the focus to the OLE container control.

Syntax

object.AutoActivate [= value]

The AutoActivate property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | An integer or constant specifying the technique used to activate the object within the OLE container control, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
vbOLEActivateManual | 0 | Manual. The object isn't automatically activated. You can activate an object programmatically using the DoVerb method.
vbOLEActivateGetFocus | 1 | Focus. If the OLE container control contains an object that supports single click activation, the application that provides the object is activated when the OLE container control receives the focus.
vbOLEActivateDoubleclick | 2 | (Default) Double-Click. If the OLE container control contains an object, the application that provides the object is activated when the user double-clicks the OLE container control or presses ENTER when the control has the focus.
vbOLEActivateAuto | 3 | Automatic. If the OLE container control contains an object, the application that provides the object is activated based on the object's normal method of activation — either when the control receives the focus or when the user double-clicks the control.

Remarks

You can determine if the OLE container control contains an object by checking the OLEType property.

Note When AutoActivate is set to 2 (Double-Click), the DblClick event doesn't occur when the user double-clicks an OLE container control.


AutoRedraw Property

Returns or sets the output from a graphics method to a persistent graphic.

Syntax

object.AutoRedraw [= boolean]

The AutoRedraw property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression that specifies how the object is repainted, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | Enables automatic repainting of a Form object or PictureBox control. Graphics and text are written to the screen and to an image stored in memory. The object doesn't receive Paint events; it's repainted when necessary, using the image stored in memory.
False | (Default) Disables automatic repainting of an object and writes graphics or text only to the screen. Visual Basic invokes the object's Paint event when necessary to repaint the object.

Remarks

This property is central to working with the following graphics methods: Circle, Cls, Line, Point, Print, and PSet. Setting AutoRedraw to True automatically redraws the output from these methods in a Form object or PictureBox control when, for example, the object is resized or redisplayed after being hidden by another object.

You can set AutoRedraw in code at run time to alternate between drawing persistent graphics (such as a background or grid) and temporary graphics. If you set AutoRedraw to False, previous output becomes part of the background screen. When AutoRedraw is set to False, background graphics aren't deleted if you clear the drawing area with the Cls method. Setting AutoRedraw back to True and then using Cls clears the background graphics.

Note If you set the BackColor property, all graphics and text, including the persistent graphic, are erased. In general, all graphics should be displayed using the Paint event unless AutoRedraw is set to True.

To retrieve the persistent graphic created when AutoRedraw is set to True, use the Image property. To pass the persistent graphic to a Windows API when AutoRedraw is set to True, use the object's hDC property.

If you set a form's AutoRedraw property to False and then minimize the form, the ScaleHeight and ScaleWidth properties are set to icon size. When AutoRedraw is set to True, ScaleHeight and ScaleWidth remain the size of the restored window.

If AutoRedraw is set to False, the Print method will print on top of graphical controls such as the Image and Shape controls.


AutoRedraw Property Example

This example alternately displays two graphics on a PictureBox control: a persistent filled circle and temporary vertical lines. Click the PictureBox to draw or redraw the lines. Resizing the form requires the temporary graphic to be redrawn. To try this example, paste the code into the Declarations section of a form that has a PictureBox control named Picture1. Press F5 to run the program, and click the graphic each time you resize the form.

Private Sub Form_Load ()
   Picture1.ScaleHeight = 100   ' Set scale to 100.
   Picture1.ScaleWidth = 100
   Picture1.AutoRedraw = True   ' Turn on AutoRedraw.
   Picture1.ForeColor = 0   ' Set ForeColor.
   Picture1.FillColor = QBColor(9)   ' Set FillColor.
   Picture1.FillStyle = 0   ' Set FillStyle.
   Picture1.Circle (50, 50), 30   ' Draw a circle.
   Picture1.AutoRedraw = False   ' Turn off AutoRedraw.
End Sub

Private Sub Picture1_Click ()
   Dim I   ' Declare variable.
   Picture1.ForeColor = Rgb(Rnd * 255, 0, 0)   ' Select random color.
   For I = 5 To 95 Step 10   ' Draw lines.
      Picture1.Line (I, 0)-(I, 100)
   Next
End Sub


AutoShowChildren Property

Returns or sets a value that determines whether MDI child forms are displayed when loaded.

Syntax

object.AutoShowChildren [= boolean]

The AutoShowChildren property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression that specifies whether MDI child forms are automatically visible, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default) MDI child forms are automatically displayed when loaded.
False | MDI child forms aren't automatically displayed when loaded.

Remarks

You can use the AutoShowChildren property to load MDI child forms and leave them hidden until they're displayed using the Show method.


AutoShowChildren Property Example

This example presents an MDIForm object with an MDI child form, uses the AutoShowChildren property to create a hidden form as another instance of the MDI child form, and then creates a visible MDI child form. To try this example, set the MDIChild property to True on Form1, and then create an MDIForm with the Add MDI Form command on the Project menu. Copy the code into the Declarations section of the MDIForm, and then press F5 to run the program.

Private Sub MDIForm_Load()
   MDIForm1.AutoShowChildren = False   ' Set to hide child forms.
   Dim HideForm As New Form1   ' Declare new form.
   HideForm.Caption = "HideForm"   ' Set its caption.
   Load HideForm   ' Load it; it's hidden.
   MDIForm1.AutoShowChildren = True   ' Set to show child forms.
   Dim ShowForm As New Form1   ' Declare another new form.
   ShowForm.Caption = "ShowForm"   ' Set its caption.
   Load ShowForm   ' Load it; it's displayed.
End Sub


AutoSize Property

Returns or sets a value that determines whether a control is automatically resized to display its entire contents.

Syntax

object.AutoSize [= boolean]

The AutoSize property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression that specifies whether the control is resized, as described in Settings.

Settings

The settings for boolean are:

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


AutoVerbMenu Property

Returns or sets a value that determines if a pop-up menu containing the object's verbs is displayed when the user clicks the OLE container control with the right mouse button.

Syntax

object.AutoVerbMenu[ = boolean]

The AutoVerbMenu property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression specifying whether a pop-up menu is displayed, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default) When the user clicks the OLE container control with the right mouse button, a pop-up menu is displayed, showing the commands the object supports.
False | No pop-up menu is displayed.

Remarks

When this property is set to True, Click events and MouseDown events don't occur when the OLE container control is clicked with the right mouse button.

In order to display your own menus, the AutoVerbMenu property must be set to False.


BackColor, ForeColor Properties

  • BackColor — returns or sets the background color of an object.

  • ForeColor — returns or sets the foreground color used to display text and graphics in an object.

Syntax

object.BackColor [= color]

object.ForeColor [= color]

The BackColor and ForeColor property syntaxes have these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
color | A value or constant that determines the background or foreground colors of an object, as described in Settings.

Settings

Visual Basic uses the Microsoft Windows operating environment red-green-blue (RGB) color scheme. The settings for color are:

Setting | Description
Normal RGB colors | Colors specified by using the Color palette or by using the RGB or QBColor functions in code.
System default colors | Colors specified by system color constants listed in the Visual Basic (VB) object library in the Object Browser. The Windows operating environment substitutes the user's choices as specified in the Control Panel settings.

For all forms and controls, the default settings at design time are:

  • BackColor — set to the system default color specified by the constant vbWindowBackground.

  • ForeColor — set to the system default color specified by the constant vbWindowText.

Remarks

In the Label, and Shape, controls, the BackColor property is ignored if the BackStyle property setting is 0 (Transparent).

If you set the BackColor property on a Form object or a PictureBox control, all text and graphics, including the persistent graphics, are erased. Setting the ForeColor property doesn't affect graphics or print output already drawn. On all other controls, the screen color changes immediately.

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF). The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF). If the high byte isn't 0, Visual Basic uses the system colors, as defined in the user's Control Panel settings and by constants listed in the Visual Basic (VB) object library in the Object Browser.

To display text in the Windows operating environment, both the text and background colors must be solid. If the text or background colors you've selected aren't displayed, one of the selected colors may be dithered — that is, comprised of up to three different-colored pixels. If you choose a dithered color for either the text or background, the nearest solid color will be substituted.


BackColor, ForeColor Properties Example

This example resets foreground and background colors randomly twice each second for a form and PictureBox control. To try this example, paste the code into the Declarations section of a form that contains a PictureBox control and a Timer control, and then press F5.

Private Sub Form_Load ()
   Timer1.Interval = 500
End Sub

Private Sub Timer1_Timer ()
   BackColor = QBColor(Rnd * 15)
   ForeColor = QBColor(Rnd * 10)
   Picture1.BackColor = QBColor(Rnd * 15)
   Picture1.ForeColor = QBColor(Rnd * 10)
End Sub


BackStyle Property

Returns or sets a value indicating whether a Label control or the background of a Shape control is transparent or opaque.

Syntax

object.BackStyle [= number]

The BackStyle property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression specifying transparency, as described in Settings.

Settings

The settings for number are:

Setting | Description
0 | Transparent — background color and any graphics are visible behind the control.
1 | (Default) Opaque — the control's BackColor property setting fills the control and obscures any color or graphics behind it.

Remarks

You can use the BackStyle property to create transparent controls when you're using a background color on a Form object or PictureBox control or when you want to place a control over a graphic. Use an opaque control when you want it to stand out.

A control's BackColor property is ignored if BackStyle = 0.


BackStyle Property (UserControl Object)

Returns or sets a value indicating the type of the control’s background.

Syntax

object.BackStyle [= enum]

The BackStyle property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
enum | An enumerated value that determines how the background of the control will be displayed, as described in Settings.

Settings

The settings for enum are:

Setting | Description
1-Opaque | (Default) Opaque background. All mouse events are received by the control.
2-Invisible | Applies only when the Windowless property is set to True. Otherwise the behavior is the same as with a Transparent BackStyle.

Remarks

When enum is set to 2, the appearance and behavior of controls with the Windowless property set to True are based on the settings of the MaskPicture, MaskColor, HitBehavior, and ClipBehavior properties.


Biblio (Biblio.vbp)

This sample allows you to browse the Biblio.mdb database, which is located in the main Visual Basic directory (\VB). The sample demonstrates the Data control. For more information, see "Accessing Databases with the Data control," in the Programmer's Guide.

File | Description
Biblio.bas | Module containing Public Sub and Function procedures.
Biblio.frm | The main form for the sample application.
Biblio.hlp | Help file for the sample.
Biblio.vbp | Project file for the sample.
Frmabout.frm | Form for the About box.

To Run

From the Visual Basic File menu, choose Open Project and select the Biblio.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


Bindable Property

Returns or sets the Bindable property associated with a Member object.

Syntax

object.Bindable

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


Blanker (Blanker.vbp)

This sample demonstrates some of the graphics techniques found in , "Creating Graphics for Applications," of the Programmer's Guide. The sample uses the Image, Line, PictureBox, Shape, and Timer controls.

Background

The sample demonstrates several Visual Basic graphic methods, including: Circle, Line, Move, and PSet.

File | Description
Blanker.frm | The main form for the sample.
Blanker.frx | Binary data for the Blanker.frm file.
Blanker.vbp | The project file for the sample.

To Run

From the Visual Basic File menu, choose Open Project and select the Blanker.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


BOFAction, EOFAction Properties

Returns or sets a value indicating what action the Data control takes when the BOF or EOF properties are True.

Syntax

object.BOFAction [= integer]

object.EOFAction [= integer]

The BOFAction and EOFAction property syntax's have these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list
integer | An integer value that specifies an action, as described in Settings

Settings

For the BOFAction property, the settings for integer are:

Setting | Value | Description
vbBOFActionMoveFirst | 0 | MoveFirst (Default): Keeps the first record as the current record.
vbBOFActionBOF | 1 | BOF: Moving past the beginning of a Recordset triggers the Data control Validate event on the first record, followed by a Reposition event on the invalid (BOF) record. At this point, the Move Previous button on the Data control is disabled.

For the EOFAction property, the settings for integer are:

Setting | Value | Description
vbEOFActionMoveLast | 0 | MoveLast (Default): Keeps the last record as the current record.
vbEOFActionEOF | 1 | EOF: Moving past the end of a Recordset triggers the Data control's Validation event on the last record, followed by a Reposition event on the invalid (EOF) record. At this point, the MoveNext button on the Data control is disabled.
vbEOFActionAddNew | 2 | AddNew: Moving past the last record triggers the Data control's Validation event to occur on the current record, followed by an automatic AddNew, followed by a Reposition event on the new record.

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

If you set the EOFAction property to vbEOFActionAddNew, once the user moves the current record pointer to EOF using the Data control, the current record is positioned to a new record in the copy buffer. At this point you can edit the newly added record. If you make changes to the new record and the user subsequently moves the current record pointer using the Data control, the record is automatically appended to the Recordset. If you don't make changes to this new record, and reposition the current record to another record, the new record is discarded. If you use the Data control to position to another record while positioned over this new record, another new record is created.

When you use code to manipulate Recordsets created with the Data control, the EOFAction property has no effect — it only takes effect when manipulating the Data control with the mouse.

In situations where the Data control Recordset is returned with no records, or after the last record has been deleted, using the vbEOFActionAddNew option for the EOFAction property greatly simplifies your code because a new record is always editable as the current record. If this option is not enabled, you are likely to trigger a "No current record" error.

Data Type

Integer


Bold Property

Returns or sets the font style of the Font object to either bold or nonbold.

Syntax

object.Bold [= boolean]

The Bold property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying the font style, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | Turns on bold formatting.
False | (Default) Turns off bold formatting.

Remarks

The Font object isn't directly available at design time. Instead you set the Bold property by selecting a control's Font property in the Properties window and clicking the Properties button. In the Font Style box of the Font dialog box, select either Bold or Bold Italic. At run time, however, you set Bold directly by specifying its setting for the Font object.


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

This example prints text on a form with each mouse click. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form twice.

Private Sub Form_Click ()
   Font.Bold = Not Font.Bold   ' Toggle bold.
   Font.StrikeThrough = Not Font.StrikeThrough ' Toggle strikethrough.
   Font.Italic = Not Font.Italic   ' Toggle italic.
   Font.Underline = Not Font.Underline   ' Toggle underline.
   Font.Size = 16   ' Set Size property.
   If Font.Bold Then
      Print "Font weight is " & Font.Weight & " (bold)."
   Else
      Print "Font weight is " & Font.Weight & " (not bold)."
   End If
End Sub


BookSale (Booksale.vbg)

This project demonstrates the use of an Automation server to encapsulate the logic of business policies and rules and to provide black box services to an external User Interface component. The client project is dedicated to delivering a clear and intuitive user interface for the user to select control options and view processing results. The client project cares a lot about how the user works and how they use the applications results, but it knows nothing about the business or operational rules of the application. The server component is dedicated to encapsulating business and data access rules into "sanctioned" services that client components use to find the information they need. The server has no idea how the user options are selected or how the results are presented to the user. This lack of specific user knowledge helps keep the server's functionality general, and as a result should increase its reusability potential for other applications. The server also uses class modules to structure the logic of its business and data access rules in a manner that aids development, debugging, readability, maintainability, and source code reusability.

The component can be run on the same machine as the client component, (which can be a significant aid in the development and debugging phases of a project), or it can be run on a remote machine to benefit from the distributed processing power and multi-user access features of a shared network server. The component does not need to be recompiled or changed in any way to support this location independence.

The server in this project uses a visible form purely for demonstration purposes. There is no functional need for the server to have any UI, though state information presented through a UI can help with debugging or run-time monitoring needs. (State monitoring requirements can also be addressed by providing a status method on the server that can be queried by a monitor application.)

File | Description
Book_cli.vbp | Client component project file.
Book_cli.frm | Client main form.
Book_cli.frx | Client main dialog graphics file.
Frmchart.frm | Client result chart form.
Frmcogs.frm | Client cost of goods form.
Book_cli.bas | Client main/global utility module.
Book_svr.vbp | Server component project file.
Book_svr.frm | Server status indicator form.
Book_svr.frx | Server status indicator graphics file.
Book_svr.bas | Server main/global utility module.
Sales.cls | Server main/public class module.
Model.cls | Server private business model rule class module.
Taxes.cls | Server private tax rule class module.
Booksale.mdb | Sample Jet database file.
Booksale.ldb | Sample database file created at run time by Jet.
Booksale.txt | Text file containing overview information on this sample application.

To Run

From the Visual Basic File menu, choose Open Project and select the Book_svr.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the server project.

Once running, this project temporarily registers its classes in the system registry. You can then start a second instance of Visual Basic to run Book_cli.vbp, the user interface component that uses the class modules defined in Book_svr.vbp.

Note The component can be run on the same machine as the user interface component, or it can be run on a remote machine to benefit from distributed processing power and support multi-user access. The component server does not need to be recompiled or changed in any way to support this location independence.


BorderColor Property

Returns or sets the color of an object's border.

Syntax

object.BorderColor [= color]

The BorderColor property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
color | A value or constant that determines the border color, as described in Settings.

Settings

Visual Basic uses the Microsoft Windows operating environment red-green-blue (RGB) color scheme. The settings for color are:

Setting | Description
Normal RGB colors | Colors specified using the Color palette or by using the RGB or QBColor functions in code.
System default colors | Colors specified by system color constants listed in the Visual Basic (VB) object library in the Object Browser . The system default color is specified by the vbWindowText constant. The Windows operating environment substitutes the user's choices as specified in the Control Panel settings.

Remarks

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF). The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF). If the high byte isn't 0, Visual Basic uses the system colors, as defined in the user's Control Panel settings and by constants listed in the Visual Basic (VB) object library in the Object Browser.


BorderStyle Property

Returns or sets the border style for an object. For the Form object and the TextBox control, read-only at run time.

Syntax

object.BorderStyle = [value]

The BorderStyle property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A value or constant that determines the border style, as described in Settings.

Settings

The BorderStyle property settings for a Form object are:

Constant | Setting | Description
vbBSNone | 0 | None (no border or border-related elements).
vbFixedSingle | 1 | Fixed Single. Can include Control-menu box, title bar, Maximize button, and Minimize button. Resizable only using Maximize and Minimize buttons.
vbSizable | 2 | (Default) Sizable. Resizable using any of the optional border elements listed for setting 1.
vbFixedDouble | 3 | Fixed Dialog. Can include Control-menu box and title bar; can't include Maximize or Minimize buttons. Not resizable.
vbFixedToolWindow | 4 | Fixed ToolWindow. Displays a non-sizable window with a Close button and title bar text in a reduced font size. The form does not appear in the Windows 95 task bar.
vbSizableToolWindow | 5 | Sizable ToolWindow. Displays a sizable window with a Close button and title bar text in a reduced font size. The form does not appear in the Windows 95 task bar.

The BorderStyle property settings for MS Flex Grid, Image, Label, OLE container, PictureBox, Frame, and TextBox controls are:

Setting | Description
0 | (Default for Image and Label controls) None.
1 | (Default for MS Flex Grid, PictureBox, TextBox, and OLE container controls) Fixed Single.

The BorderStyle property settings for Line and Shape controls are:

Constant | Setting | Description
vbTransparent | 0 | Transparent
vbBSSolid | 1 | (Default) Solid. The border is centered on the edge of the shape.
vbBSDash | 2 | Dash
vbBSDot | 3 | Dot
vbBSDashDot | 4 | Dash-dot
vbBSDashDotDot | 5 | Dash-dot-dot
vbBSInsideSolid | 6 | Inside solid. The outer edge of the border is the outer edge of the shape.

Remarks

For a form, the BorderStyle property determines key characteristics that visually identify a form as either a general-purpose window or a dialog box. Setting 3 (Fixed Dialog) is useful for standard dialog boxes. Settings 4 (Fixed ToolWindow) and 5 (Sizable ToolWindow) are useful for creating toolbox-style windows.

MDI child forms set to 2 (Sizable) are displayed within the MDI form in a default size defined by the Windows operating environment at run time. For any other setting, the form is displayed in the size specified at design time.

Changing the setting of the BorderStyle property of a Form object may change the settings of the MinButton, MaxButton, and ShowInTaskbar properties. When BorderStyle is set to 1 (Fixed Single) or 2 (Sizable), the MinButton, MaxButton, and ShowInTaskbar properties are automatically set to True. When BorderStyle is set to 0 (None), 3 (Fixed Dialog), 4 (Fixed ToolWindow), or 5 (Sizable ToolWindow), the MinButton, MaxButton, and ShowInTaskbar properties are automatically set to False.

Note If a form with a menu is set to 3 (Fixed Dialog), it is displayed with a setting 1 (Fixed Single) border instead.

At run time, a form is either modal or modeless, which you specify using the Show method.


BorderWidth Property

Returns or sets the width of a control's border.

Syntax

object.BorderWidth [= number]

The BorderWidth property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression from 1 to 8192, inclusive.

Remarks

Use the BorderWidth and BorderStyle properties to specify the kind of border you want for a Line or Shape control. The following table shows the effect of BorderStyle settings on the BorderWidth property:

BorderStyle | Effect on BorderWidth
0 | BorderWidth setting is ignored.
1–5 | The border width expands from the center of the border; the height and width of the control are measured from the center of the border.
6 | The border width expands inward on the control from the outside of the border; the height and width of the control are measured from the outside of the border.

If the BorderWidth property setting is greater than 1, the only effective settings of BorderStyle are 1 (Solid) and 6 (Inside Solid).


BorderWidth Property Example

This example uses two ComboBox controls to select different widths and styles for the borders of a Shape control. To try this example, paste the code into the Declarations section of a form that contains a Shape control and one ComboBox control. For the ComboBox, set Style = 2 and Index = 0 (to create a control array), and then press F5 and click the form.

Private Sub Form_Load ()
   Combo1(0).Width = 1440 * 1.5
   Load Combo1(1)
   Combo1(1).Top = Combo1(0).Top + Combo1(0).Height * 1.5
   Combo1(1).Visible = True
   For I = 0 To 6
      Combo1(0).AddItem "BorderStyle = " & I
   Next I
   For I = 1 To 10
      Combo1(1).AddItem "BorderWidth = " & I
   Next I
   Combo1(0).ListIndex = 1
   Combo1(1).ListIndex = 0
End Sub

Private Sub Combo1_Click (Index As Integer)
   If Index = 0 Then
      Shape1.BorderStyle = Combo1(0).ListIndex
   Else
      Shape1.BorderWidth = Combo1(1).ListIndex + 1
   End If
End Sub


BottomMargin, TopMargin Properties

Returns or sets, in twips, the height of the bottom and top margins.

Syntax

object.BottomMargin [=number]

object.TopMargin [=number]

The BottomMargin and TopMargin properties syntax have these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
number | Optional. A numeric expression that specifies the height of the bottom margin or top margin.


Browsable Property

Returns or sets the Browsable attribute associated with a Member object.

Syntax

object.Browsable

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


BrowserType Property

Returns the Active Server Pages BrowserType object.

Syntax

object.BrowserType

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

A WebClass uses the BrowserType object to determine the attributes of the user’s browser and make processing decisions based on those attributes.

See the Active Server Pages documentation for details of the properties, methods, and events for the BrowserType object.


BytesMax Property

Returns the estimated maximum number of bytes to be read.

Syntax

object.BytesMax

The BytesMax property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

The BytesMax property returns a long integer. The value of BytesMax can change during the download if a more accurate estimate can be made. The value can be 0 for some downloads if the server can't determine the download size. For example, .ASP pages don't always provide this information.


BytesRead Property

Returns the total number of bytes that have been currently read or downloaded.

Syntax

object.BytesRead

The BytesRead property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

The BytesRead property returns a long integer.


CacheSize Property

Returns or sets the number of records that are cached in local memory for the current DECommand object.

Syntax

object.CacheSize [=value]

The CacheSize property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | Integer. A numeric expression that specifies the number of records that are cached in local memory for the current DECommand object. The default is 10 records.

Remarks

The value tells the provider how many records to keep in its fat buffer and how many records to fetch at one time to local memory. For example, when set to 10, after opening the first Recordset the provider fetches the first 10 records into local memory. Therefore, as you move forward from the current record, the provider returns the data values from the local memory buffer. As soon as you move past the last record, the next 10 records are fetched from the data source (or cursor library) into the cache.

While you can change value during the life of the cursor, the change only affects the number of records in the cache after the next fetch from the data source (or local cursor library).

This property corresponds to the ADO Recordset CacheSize property.


CallDlls (CallDlls.vbp)

This sample demonstrates calling procedures in Dynamic-link libraries (DLLs). For more information, see "Using a DLL Procedure in Your Application" in "Accessing DLLS and the Windows API" of the Component Tools Guide.

File | Description
Calldlls.frm | The main form for the application.
Calldlls.frx | Binary data for the Calldlls.frm file.
Calldlls.vbp | The project file for the application.
Declares.bas | Module containing declarations of DLLs used in the sample.
Frmmenus.frm | Form for showing system information.

To Run

From the Visual Basic File menu, choose Open Project and select the Calldlls.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


CallSyntax Property

Specifies the call syntax used to send the CommandText property to the ADO Command object.

Syntax

object.CallSyntax [=string]

The CallSyntax property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the call syntax of the DECommand object, including both source and parameter information.

Remarks

This property is generally used when the source of the DECommand object is either a stored procedure or a parameterized query.


Cancel Property

Returns or sets a value indicating whether a command button is the Cancel button on a form. This command button can be the CommandButton control or any object within an OLE container control that behaves as a command button.

Syntax

object.Cancel [= boolean]

The Cancel property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying whether the object is the Cancel button, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | The CommandButton control is the Cancel button.
False | (Default) The CommandButton control isn't the Cancel button.

Remarks

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

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

For OLE container controls, the Cancel property is provided only for those objects that specifically behave as command buttons.

Tip For a form that supports irreversible operations, such as deletions, it's a good idea to make the Cancel button the default button. To do this, set both the Cancel property and the Default property to True.


CanGetFocus Property

Returns or sets a value determining if a control can receive focus. The CanGetFocus property is read/write at the control’s authoring time, and not available at the control’s run time.

Settings

The settings for CanGetFocus are:

Setting | Description
True | (Default) The control can receive focus. If the control contains constituent controls, the control itself will be unable to receive the focus unless none of its constituent controls can receive the focus. It is up to the author of the control to write the code that draws a focus rectangle on the control when it does receive focus.
False | The control cannot receive focus.

Remarks

As long as the control contains at least one constituent control that has been set to receive the focus, CanGetFocus cannot be set to False. If CanGetFocus is False, then no constituent control can be set to receive the focus.


CanGrow Property

Returns or sets a value that determines if the control can grow vertically when the returned text exceeds the preset size of the control.

Syntax

object.CanGrow [= boolean]

The CanGrow property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
boolean | Optional. A Boolean expression that specifies if the control can grow, as shown in Settings.

Settings

The settings for boolean are:

Setting | Description
True | The control can grow.
False | (Default) The control cannot grow.


Caption Property

  • Form — determines the text displayed in the Form or MDIForm object's title bar . When the form is minimized, this text is displayed below the form's icon.

  • Control — determines the text displayed in or next to a control.

  • MenuLine object — determines the text displayed for a Menu control or an object in the MenuItems collection.

For a Menu control, Caption is normally read/write at run time. But Caption is read-only for menus that are exposed or supplied by Visual Basic to add-ins, such as the MenuLine object.

Syntax

object.Caption [= string]

The Caption property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list. If object is omitted, the form associated with the active form module is assumed to be object.
string | A string expression that evaluates to the text displayed as the caption.

Remarks

When you create a new object, its default caption is the default Name property setting. This default caption includes the object name and an integer, such as Command1 or Form1. For a more descriptive label, set the Caption property.

You can use the Caption property to assign an access key to a control. In the caption, include an ampersand (&) immediately preceding the character you want to designate as an access key. The character is underlined. Press the ALT key plus the underlined character to move the focus to that control. To include an ampersand in a caption without creating an access key, include two ampersands (&&). A single ampersand is displayed in the caption and no characters are underlined.

A Label control’s caption size is unlimited. For forms and all other controls that have captions, the limit is 255 characters.

To display the caption for a form, set the BorderStyle property to either Fixed Single (1 or vbFixedSingle), Sizable (2 or vbSizable), or Fixed Dialog (3 or vbFixedDialog). A caption too long for the form's title bar is clipped. When an MDI child form is maximized within an MDIForm object, the child form's caption is included in the parent form's caption.

Tip For a label, set the AutoSize property to True to automatically resize the control to fit its caption.


Caption Property (DEDesigner Extensibility)

Returns or sets the label, or caption control, that is set when a DEAggregate or DEField object is dragged from the Data Environment designer and dropped onto a Visual Basic form or report. To use the caption in a drag-and-drop operation, you must first specify that a caption will be created when the object is dropped.

  • Form — The text that displays in the title bar of the Form or MDIForm object. When the form is minimized, this text displays below the form's icon.

  • Control — The text that displays in or next to a control.

  • MenuLine object — The text that displays for a Menu control or an object in the MenuItems collection.

    Note For a Menu control, the Caption property is generally read/write at run time. However, the Caption property is read-only for menus that are exposed or supplied by Visual Basic to add-ins, such as the MenuLine object.

Syntax

object.Caption [=string]

The Caption property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list. If object is omitted, the form associated with the active form module is assumed to be object.
string | A string expression that defines the textual caption that drops onto the form.

Remarks

When you create a new object, its default caption is the default Name property setting. This default caption includes the object name and an integer, such as Command1 or Form1. For a more descriptive label, set the Caption property.

You can use the Caption property to assign an access key to a control. In the caption, include an ampersand (&) immediately preceding the character you want to designate as an access key. The character is underlined. Press the ALT key plus the underlined character to move the focus to that control. To include an ampersand in a caption without creating an access key, include two ampersands (&&). A single ampersand is displayed in the caption and no characters are underlined.

The caption size of the Label control is unlimited. For forms and all other controls that have captions, the limit is 255 characters.

To display the caption for a form, set the BorderStyle property to either Fixed Single (1 or vbFixedSingle), Sizable (2 or vbSizable), or Fixed Double (3 or vbFixedDouble). If a caption is too long for the form's title bar, the caption is clipped. When an MDI child form is maximized within an MDIForm object, the caption of the child form is included in the caption of the parent form.

Tip For a label, set the AutoSize property to True to automatically resize the control to fit its caption.


Caption Property Example

This example changes the Caption property of a CommandButton control each time the user clicks the button. To try this example, paste the code into the Declarations section of a form containing a CommandButton named Command1, and then press F5 and click the button.

Private Sub Command1_Click ()
   ' Check caption, then change it.
   If Command1.Caption = "Clicked" Then
      Command1.Caption = "OK"
   Else
      Command1.Caption = "Clicked"
   End If
End Sub


Category Property

Returns or sets the Category attribute associated with a Member object.

Syntax

object.Category

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


CausesValidation Property

Returns or sets a value that determines whether the Validate event will occur on a second control from which the focus is being shifted.

Syntax

object.CausesValidation [ = boolean]

The CausesValidation property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that specifies whether the control from which the focus is being shifted fires the Validate event.

Settings

The settings for boolean are:

Setting | Description
True | (Default) The control from which the focus has shifted fires its Validate event.
False | The control from which the focus has shifted does not fire its Validate event.

Remarks

The CausesValidation property works in tandem with the Validate event to limit when a control can lose focus.


Changed Property

Returns or sets a value indicating that a value of a property on a property page has changed. The Changed property is not available at the property page’s authoring time, and read/write at the property page’s run time.

Syntax

object.Changed [= boolean]

The Changed property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A boolean value that determines if a property on the property page has been changed, making the property page dirty.

Settings

The settings for boolean are:

Setting | Description
True | The property page is now dirty, since the value of a property on the page has been changed.
False | The property page is not dirty, and no properties on the page have had their value changed.

Remarks

When the user changes the value of properties on a property page, these changes should not take effect immediately; instead, the changes should be applied only if the user presses the Apply button, the OK button, or changes property pages by selecting tabs. This allows the user to easily back out of any changes that have been made to a property page.

The Changed property should be set to True, for example, when a user changes a property value on a property page. Setting the Changed property to True would notify the property page to make available the Apply button.


Charset Property

Sets or returns the character set used in the font.

Syntax

object.Charset [ = value ]

The Charset property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A integer value that specifies the character set used by the font, as described in Settings.

Settings

The following are some common settings for value:

Value | Description
0 | Standard Windows characters
2 | The symbol character set.
128 | Double-byte character set (DBCS) unique to the Japanese version of Windows
255 | Extended characters normally displayed by DOS applications.

Remarks

Setting the Charset property to one of its available values selects the character set only if it is available in the current font.


Checked Property

Returns or sets a value that determines whether a check mark is displayed next to a menu item.

Syntax

object.Checked [= boolean]

The Checked property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that specifies whether a check mark is displayed next to a menu item.

Settings

The settings for boolean are:

Setting | Description
True | Places a check mark next to a menu item.
False | (Default) Doesn't place a check mark next to a menu item.

Remarks

At design time, you can use the Menu Editor to set Checked to True. At run time, you can toggle Checked on and off as part of a Click event procedure attached to a Menu control. You can also set the value of Checked in a startup procedure or in a form's Load event procedure.

For a Menu control, Checked is normally read/write at run time. But Checked is read-only for menu items that are exposed or supplied by Visual Basic to add-ins, such as the Add-In Manager command on the Add-Ins menu.


Checked Property Example

This example displays and removes a check mark next to a menu item. To try this example, create a form with a Menu control that has one menu item (set both the Caption and Name properties to MyMenuItem), and then press F5 and choose the menu item.

Private Sub MyMenuItem_Click ()
   ' Turn check mark on menu item on and off.
   MyMenuItem.Checked = Not MyMenuItem.Checked
End Sub


ChildComparison Property

Specifies whether the relation condition is against a field or parameter in the child DECommand object.

Note When you create a relation hierarchy, a DERelationCondition object is created for each relation condition that you define. Thus, each DERelationCondition object is equivalent to one relation condition.

Syntax

object.ChildComparison [=value]

The ChildComparison property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies the type of comparison, as described in Settings.

Settings

The settings for value are:

Constant | Description
deField | Field. (Default) The relation condition is against a Field object.
deParameter | Parameter. The relation condition is against a Parameter object.


ChildCondition Property

Returns or sets the item in the child Command object that is used in the comparison condition.

Syntax

object.ChildCondition [=string]

The ChildCondition property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the name of a field or parameter in the child Command object.


Class Property

Returns or sets the class name of an embedded object.

Syntax

object.Class [ = string]

The Class property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | A string expression specifying the class name.

Remarks

A class name defines the type of an object. Applications that support ActiveX components fully qualify the class names of their objects using either of the following syntaxes:

application.objecttype.version

objecttype.version

The syntax for ActiveX component class names has the following parts:

Part | Description
application | The name of the application that supplies the object.
objecttype | The object's name as defined in the object library.
version | The version number of the object or application that supplies the object.

For example, Microsoft Excel version 5.0 supports a number of objects, including worksheets and charts. Their class names are Excel.Sheet.5 and Excel.Chart.5. Microsoft WordArt version 2.0 supports a single object with the class name MSWordArt.2.

Note Some ActiveX component programming documentation refers to the class name syntax as a programmatic ID.

To view a list of class names available on your system, select the OLE container control, select the Class property in the Properties window, and then click the builder button.

Copying an object from the system Clipboard updates the control’s Class property. For example, if you paste a Microsoft Excel chart from the system Clipboard into an OLE container control that previously contained a Microsoft Excel worksheet, its Class property setting changes from Excel.Sheet.5 to Excel.Chart.5. You can paste an object from the system Clipboard at run time with the Paste method or the PasteSpecialDlg method.


ClipBehavior Property

Returns or sets a value that defines the clipping behavior of the HitTest event on a Windowless UserControl object.

Syntax

object.ClipBehavior [= number]

The ClipBehavior property syntax has these parts:

Part | Description
object | A UserControl object.
number | An integer that specifies clipping behavior, as described in Settings.

Settings

The settings for number are:

Constant | Setting | Description
None | 0 | The output of graphics methods will appear anywhere within the rectangular bounds of the control.
UseRegion | 1 | (Default) The output of graphics methods will be clipped to the MaskRegion of your control.

Remarks

You can use the ClipBehavior property to determine where the output of graphics methods will appear on your UserControl. By default, any drawing done using graphics methods will only be visible over the MaskRegion of the control. The MaskRegion consists of any subcontrols plus any mask defined by the MaskPicture and MaskColor properties. Any drawing done outside of the MaskRegion will be invisible.

By setting ClipBehavior to None, drawing will be visible over both the MaskRegion and the TransparentRegion of the control.

When used in combination with the HitBehavior property, this property helps to determine the HitResult argument of the HitTest event.

Note This property is ignored if the Windowless property of the UserControl object is set to False or if the BackStyle property is set to Opaque.

Important Not all control containers support the Windowless property. The HitBehavior property should only be changed if you know it will be used in containers that support Windowless activation.


Clipboard Property

Returns a Clipboard object, which provides access to the system Clipboard.

Syntax

Clipboard

Remarks

The Clipboard object is used to manipulate text and graphics on the Clipboard. You can use this object to enable a user to copy, cut, and paste text or graphics in your application. Before copying any material to the Clipboard object, you should clear its contents by performing a Clear method, such as Clipboard.Clear.

Note that the Clipboard object is shared by all Windows applications, and thus, the contents are subject to change whenever you switch to another application.

The Clipboard object can contain several pieces of data as long as each piece is in a different format. For example, you can use the SetData method to put a bitmap on the Clipboard with the vbCFDIB format, and then use the SetText method with the vbCFText format to put text on the Clipboard. You can then use the GetText method to retrieve the text or the GetData method to retrieve the graphic. Data on the Clipboard is lost when another set of data of the same format is placed on the Clipboard either through code or a menu command.


ClipControls Property

Returns or sets a value that determines whether graphics methods in Paint events repaint the entire object or only newly exposed areas. Also determines whether the Microsoft Windows operating environment creates a clipping region that excludes nongraphical controls contained by the object. Read-only at run time.

Syntax

object.ClipControls

The ClipControls property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression that specifies how objects are repainted, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default) Graphics methods in Paint events repaint the entire object. A clipping region is created around nongraphical controls on the form before a Paint event.
False | Graphics methods in Paint events repaint only newly exposed areas. A clipping region isn’t created around nongraphical controls before a Paint event. Complex forms usually load and repaint faster when ClipControls is set to False.

Remarks

Clipping is the process of determining which parts of a form or container, such as a Frame or PictureBox control, are painted when the form is displayed. An outline of the form and controls is created in memory. The Windows operating environment uses this outline to paint some parts, such as the background, without affecting other parts, such as the contents of a TextBox control. Because the clipping region is created in memory, setting this property to False can reduce the time needed to paint or repaint a form.

The clipping region includes most controls, but doesn't clip around the Image, Label, Line, or Shape controls.

Avoid nesting intrinsic controls with ClipControls set to True inside a control with ClipControls set to False (for instance, a command button inside a picture box). This kind of control nesting causes the controls to repaint incorrectly. To fix this problem, set the ClipControls property for both the container control and the nested controls to True.


ClipControls Property Example

This example shows how the ClipControls property affects the repainting of a form. To try this example, paste the code into the Declarations section of a form, and then press F5. Notice that the color of the entire form changes each time you resize it or cover part of it with another form or application. End the program and set ClipControls to False, and then run the program again. Notice that only newly exposed parts of the form are repainted.

Private Sub Form_Paint ()
   ' Select a random color for the background.
   BackColor = &HFFFFFF * Rnd
End Sub


Col, Row Properties

Return or set the active cell in a DataGrid control. Not available at design time.

Syntax

object.Col [= number]

object.Row [= number]

The Col and Row property syntaxes have these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | The number of the column or row containing the active cell.

Remarks

Use these properties to specify a cell in a DataGrid control or to find out which column or row contains the active cell in a selected region. Columns and rows are numbered from zero, beginning at the top for rows and at the left for columns. Setting these properties at run time doesn't change which cells are selected. Use the SelEndCol, SelStartCol, SelEndRow, and SelStartRow properties to specify a selected region.

Note The Col and Row properties aren't the same as the Cols and Rows properties.


ColorMode Property

Returns or sets a value that determines whether a color printer prints output in color or monochrome. Not available at design time.

Syntax

object.ColorMode [= value]

The ColorMode property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A constant or integer that specifies the print mode, as described in Settings.

Settings

The settings for value are:

Setting | Value | Description
VbPRCMMonochrome | 1 | Print output in monochrome (usually shades of black and white).
VbPRCMColor | 2 | Print output in color.

Remarks

The default value depends on the printer driver and the current printer settings. Monochrome printers ignore this property.

Note The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. If you set the ColorMode property for a printer which doesn’t support color, the setting is ignored. If you attempt to reference the ColorMode property, however, you will get an error message. Settings outside the accepted range may also produce an error. For more information, see the manufacturer's documentation for the specific driver.


Columns Property (ListBox)

Returns or sets a value that determines whether a ListBox control scrolls vertically or horizontally and how the items in the columns are displayed. If it scrolls horizontally, the Columns property determines how many columns are displayed.

Syntax

object.Columns [= number]

The Columns property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | An integer that specifies how a control scrolls and how items are arranged in columns, as described in Settings.

Settings

The settings for number are:

Setting | Description
0 | (Default) Items are arranged in a single column and the ListBox scrolls vertically.
1 to n | Items are arranged in snaking columns, filling the first column, then the second column, and so on. The ListBox scrolls horizontally and displays the specified number of columns.

Remarks

For horizontal-scrolling ListBox controls, the column width is equal to the width of the ListBox divided by the number of columns.

This property can't be set to 0 or changed from 0 at run time — that is, you can't change a multiple-column ListBox to a single-column ListBox or a single-column ListBox to a multiple-column ListBox at run time. However, you can change the number of columns in a multiple-column ListBox at run time.


Columns Property Example

This example illustrates how the two different kinds of ListBox controls work when they contain the same data. To try this example, paste the code into the Declarations section of a form that contains two ListBox controls. Set the Columns property to 2 for List2, and then press F5 and click the form.

Private Sub Form_Load ()
   Dim I   ' Declare variable.
   List1.Move 50, 50, 2000, 1750   ' Arrange list boxes.
   List2.Move 2500, 50, 3000, 1750
   For I = 0 To Screen.FontCount -1   ' Fill both boxes with
      List1.AddItem Screen.Fonts(I)   ' names of screen fonts.
      List2.AddItem Screen.Fonts(I)
   Next I
End Sub


Col, Row Properties Example

This example puts "Here" into the current cell and then changes the active cell to the third cell in the third row and puts "There" into that cell. To try this example, use the Components dialog box to add an MS Flex Grid control to the toolbox (from the Project menu, choose Components, and then check Microsoft Flex Grid Control), and then draw a grid on a new form. To run the program, press F5, and then click the grid.

Private Sub Form_Load ()
   MSFlexGrid1.Rows = 8   ' Set rows and columns.
   MSFlexGrid1.Cols = 5
End Sub

Private Sub MSFlexGrid1_Click ()
   ' Put text in current cell.
   MSFlexGrid1.Text = "Here"
   ' Put text in third row, third column.
   MSFlexGrid1.Col = 2
   MSFlexGrid1.Row = 2
   MSFlexGrid1.Text = "There"
End Sub

The next example displays the location of the active cell and the range of the selection as a user selects a cell or range of cells. Notice that when selecting a range, the active cell doesn't change. Select a range, and then click the form to move the active cell around the perimeter of the selection. Notice that the selected range doesn't change.

To try this example, create a new project, add an MS Flex Grid control using the Components dialog box (from the Project menu, choose Components, and then check Microsoft Flex Grid Control), and then draw an MS Flex Grid and two labels. Copy the code into the Declarations section, and then press F5 to run the program.

Private Sub Form_Load ()
   MSFlexGrid1.Cols = 6   ' Set columns and rows.
   MSFlexGrid1.Rows = 7
End Sub

Private Sub MSFlexGrid1_RowColChange ()
   Msg = "Active Cell: " & Chr(64 + MSFlexGrid1.Col)
   Mst = Msg & MSFlexGrid1.Row
   Label1.Caption = Msg
End Sub

Private Sub MSFlexGrid1_SelChange ()
   Msg = "Selection: " & Chr(64 + MSFlexGrid1.SelStartCol)
   Msg = Msg & MSFlexGrid1.SelStartRow
   Msg = Msg & ":" & Chr(64 + MSFlexGrid1.SelEndCol)
   Msg = Msg & MSFlexGrid1.SelEndRow
   Label2.Caption = Msg
End Sub

Private Sub Form_Click ()
   ' This procedure moves the active cell around
   ' the perimeter of the selected range
   ' of cells with each click on the form.
   Dim GR, GC As Integer
   If MSFlexGrid1.Row = MSFlexGrid1.SelStartRow Then
      If MSFlexGrid1.Col = MSFlexGrid1.SelEndCol Then
         GR = 1: GC = 0
      Else
         GR = 0: GC = 1
      End If
   ElseIf MSFlexGrid1.Row = MSFlexGrid1.SelEndRow Then
      If MSFlexGrid1.Col = MSFlexGrid1.SelStartCol Then
         GR = -1: GC = 0
      Else
         GR = 0: GC = -1
      End If
   Else
      If MSFlexGrid1.Col = MSFlexGrid1.SelStartCol Then
         GR = -1: GC = 0
      Else
         GR = 1: GC = 0
      End If
   End If
   MSFlexGrid1.Row = MSFlexGrid1.Row + GR
   MSFlexGrid1.Col = MSFlexGrid1.Col + GC
End Sub


CommandText Property

Returns or sets the source of the Command object.

Syntax

object.CommandText [=string]

Parameters

The CommandText event syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that represents a Command object.

Remarks

This property corresponds to the ADO Command CommandText property.


CommandTimeout Property

Returns or sets the duration, in seconds, that the provider waits for a command to return from the server.

Syntax

object.CommandTimeout [=number]

Parameters

The CommandTimeout property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
number | Integer. A numeric expression that specifies the number of seconds to wait when establishing a connection. The default is 30 seconds.

Remarks

Once this period of time has elapsed without completing the command, the provider raises an exception to the calling application and cancels the command.

This property corresponds to the ADO Command and Connection CommandTimeout property.


CommandType Property

Informs the provider what the CommandText property holds, which may include the source type of the Command object. Setting this property optimizes the execution of the command.

Syntax

object.CommandType [=value]

The CommandType property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies what the CommandText holds, which may include the source type of the Command object.

Remarks

The CommandText property can be anything the provider recognizes, hence, you can pass a variety of command types. For example, some providers may allow the CommandText property to be set to a base-table name or to the name of an existing stored procedure in the data source. In these cases, the provider must know whether the CommandText property contains text or a data source item. Rather than having an order of preference, you can set the type using the CommandType property.

When set to adCmdUnknown, the command type is not explicitly known, and the provider attempts to execute the command text first as plain text, then as a stored procedure, and finally as a base table name. An error only occurs if all three of these attempts fail.

This property corresponds to the ADO CommandType property.


Comments Property

Returns or sets a string containing comments about the running application. Read only at run time.

Syntax

object.Comments

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You can set this property at design time in the Type box in the Make tab of the Project Properties dialog box.


CompanyName Property

Returns or sets a string value containing the name of the company or creator of the running application. Read only at run time.

Syntax

object.CompanyName

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You can set this property at design time in the Type box in the Make tab of the Project Properties dialog box.


ConnectionName Property

Specifies the name of the DEConnection object associated with the Command object. This property can be set to the name of any Connection object in the current DataEnvironment object.

Syntax

object.ConnectionName [=string]

The Connection Name property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the name of the associated DEConnection object in the current DataEnvironment object.


ConnectionSource Property

Returns or sets the source of the DEConnection object.

Syntax

object.ConnectionSource [=string]

Parameters

The ConnectionSource property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that defines the source of the DEConnection object, which may be a connection string, a Data Link file, or a data source name (DSN).

Remarks

The type of source contained in this property is defined by the setting of the SourceOfData property.


ConnectionTimeout Property

Returns or sets the duration of time, in seconds, for which the provider attempts to connect to the server specified in the DEConnection object.

Syntax

object.ConnectionTimeout [=integer]

Parameters

The ConnectionTimeout property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
integer | A numeric expression that specifies the number of seconds to wait when establishing a connection. The default is 15 seconds.

Remarks

This property corresponds to the ADO ConnectionTimeout property.


Connect Property

Returns or sets the connected state of an add-in.

Syntax

object.Connect

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Returns True if the add-in is registered and currently connected (active).

Returns False if the add-in is registered, but not connected (inactive).


ContainedControls Property

Returns a collection of the controls that were added to the control by the developer or the end user at the control’s run-time. The ContainedControls property is not available at the control’s authoring time, and read-only at the control’s run time.

Syntax

object.ContainedControls

The ContainedControls property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

The ContainedControls collection is filled with all the controls that were added to the control by the developer or the end-user. The control can use the ContainedControls collection to perform operations on any of these contained controls.

This collection functions in a similar manner to the Controls collection on a form.

In order to allow contained controls to be placed on the control, the ControlContainer property must be True.

Contained controls cannot be added or removed through this ContainedControls collection; the contained controls must be changed in whatever manner the container allows.

The ContainedControls property may not be supported by all containers, even though the container may support the control having contained controls; Visual Basic forms do support this property. If this property is not supported, then calls to the ContainedControls collection will cause errors; use error handling when accessing the collection. Note, however, that if error handling is done while in an event procedure such as the InitProperties event procedure or the ReadProperties event procedure, the error handler should not raise an error event; doing this may be fatal to the container.

The ContainedControls collection is not available when the Initialize event is raised; but is available when the InitProperties event or ReadProperties event is raised.

Once the ContainedControls collection is present, it may not immediately contain references to the controls a developer has placed on the control. For example, if the control is on a Visual Basic form, the Count property of the ContainedControls collection will be zero until after the ReadProperties event procedure has executed.


ContainerHWnd Property

Returns the window handle (hWnd) of a UserControl’s container.

Syntax

object.ContainerHWnd

The object placeholder represents an object expression that evaluates to a UserControl object.

Remarks

The ContainerHWnd property returns the handle of the container on which a UserControl object is sited. The ContainerHWnd can be passed as a parameter to Windows API calls that require an hWnd parameter.

When the Windowless property of a UserControl is set to True, the UserControl doesn’t have a handle of its own. In some cases, the ContainerHWnd property can be used in place of the hWnd property for UserControls to get information about a window. The ContainerHWnd should not be used for Windows API calls that modify the hWnd value.


Contents Property

Returns or sets a byte array representing the contents of a PropertyBag object.

Remarks

The Contents property is used to store or retrieve the contents of a PropertyBag object to or from an external storage such as a text file, a cell in a spreadsheet, a message field, or a structured storage. An object stored in this manner can be retrieved and reused without using the New keyword. The Contents property must be passed as a byte array; attempting to assign to or from any other data type will result in a run time error.

This property only applies to a PropertyBag declared As PropertyBag; it does not apply to a PropertyBag object contained in a UserControl or UserDocument.


ContinuousScroll Property

Returns or sets a value that determines if scrolling is continuous, or if the UserDocument only redraws when the scroll thumb is released.

Syntax

object.ContinuousScroll = boolean

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that specifies whether scrolling is continuous or not.

Settings

The settings for boolean are:

Setting | Description
True | Default. Scrolling is continuous.
False | The UserDocument redraws only when the thumb is released.


Control Property

Returns or sets which control to use when a DEAggregate or DEField object is dragged from a Data Environment designer and dropped onto a Visual Basic form or report.

Syntax

object.Control [=string]

The Control property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the ClassID of the control.

Remarks

The string is a globally unique identifier (GUID) for the control. For example, the value "{0ECD9B64-23AA-11D0-B351-00A0C9055D8E}" is the string for the MSHFlexGrid control.


ControlBox Property

Returns or sets a value indicating whether a Control-menu box is displayed on a form at run time. Read-only at run time.

Syntax

object.ControlBox

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The ControlBox property settings are:

Setting | Description
True | (Default) Displays the Control-menu box.
False | Removes the Control-menu box.

Remarks

To display a Control-menu box, you must also set the form's BorderStyle property to 1 (Fixed Single), 2 (Sizable), or 3 (Fixed Dialog).

Both modal and modeless windows can include a Control-menu box.

The commands available at run time depend on the settings for related properties — for example, setting MaxButton and MinButton to False disables the Maximize and Minimize commands on the Control menu, but the Move and Close commands remain available.

Note Settings you specify for the ControlBox, BorderStyle, MaxButton, and MinButton properties aren't reflected in the form's appearance until run time.


ControlContainer Property

Returns or sets a value determining if a control can contain controls placed on it by the developer or the end user at the control’s run time; in the same way the PictureBox control can contain other controls. The ControlContainer property is read/write at the control’s authoring time, and not available at the control’s run time.

Settings

The settings for ControlContainer are:

Setting | Description
True | The control can contain controls placed on it. If an instance of this control is placed on a container that is not aware of ISimpleFrame, support of contained controls will be disabled. The control will continue to work correctly in all other ways, but developers or end users will be unable to place controls on an instance of this control.
False | (Default) The control cannot contain controls placed on it.

Remarks

Contained control support does work on a Visual Basic form.

Contained controls placed on a control with a transparent background are only visible where their location overlaps any constituent controls. Mouse events will be passed to the contained control only if they occur where the contained control is visible.


Controls (Controls.vbp)

This sample application demonstrates the use of Visual Basic controls such as the TextBox, CommandButton, Image and others. The sample illustrates the usage of many standard properties.

Background

The sample is comprised of several forms, each with a control or set of controls on it. Controls demonstrated include the following: TextBox, HScrollbar, ListBox, PictureBox, OptionButton, CommandButton and Label control. For more information, see "Creating and Using Controls," in the Programmer's Guide.

File | Description
Button.frm | Form demonstrating the usage of CommandButton controls.
Button.frx | Binary data file for the Button.frm file.
Check.frm | Form demonstrating usage of a CheckButton control.
Controls.vbp | The project file for the sample application.
Images.frm | Form demonstrating usage of the Image and Shape controls.
Images.frx | Binary data file for the Image.frm file.
Main.frm | The main form for the sample application.
Multi.frm | Form demonstrating usage of the ListBox control.
Options.frm | Form demonstrating usage of the OptionButton and Frame controls.
Text.frm | Form demonstrating usage of the TextBox control.
Text.frx | Binary data file for the Text.frm file.
Wordwrap.frm | Form demonstrating usage of the Label control.

To Run

From the Visual Basic File menu, choose Open Project and select the Controls.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


Controls Property

Returns a reference to a collection of Control objects.

Syntax

object.Controls

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You can manipulate Control objects using the reference returned by the Controls property.


Copies Property

Returns or sets a value that determines the number of copies to be printed. For the Printer object, not available at design time.

Syntax

object.Copies [= number]

The Copies property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | A numeric expression that specifies the number of copies to print. This value must be an integer.

Remarks

For the Print dialog box, this property returns the number of copies entered by the user in the Copies box. If the cdlPDUseDevModeCopies flag is set for the CommonDialog control, this property always returns 1.

For the Printer object, multiple copies may or may not be collated, depending on the printer driver. Multiple copies of the entire document or multiple copies of each page may be printed. For printers that don't support collating, set Copies = 1, and then use a loop in code to print multiple copies of the entire document.

Note The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may produce an error. For more information, see the manufacturer's documentation for the specific driver.


Count Property (VB Collections)

Returns the number of objects in a collection.

Syntax

object.Count

The object placeholder is an object expression that evaluates to an object in the Applies To list.

Remarks

You can use this property with a For...Next statement to carry out an operation on the forms or controls in a collection. For example, the following code moves all controls on a form 0.5 inches to the right (ScaleMode property setting is 1 or vbTwips):

For I = 0 To Form1.Controls.Count - 1
   Form1.Controls(I).Left = Form1.Controls(I).Left + 720
Next I

You can also use this kind of structure to quickly enable or disable all controls on a form.

When used with the If TypeOf statement, you can cycle through all controls and change, for example, the Enabled property setting of only the text boxes or the BackColor property setting of only the option buttons.


Count Property (DEDesigner Extensibility)

Returns the number, or count, of members contained in a collection. A member can be any DECommand, DEConnection, DEParameter, DEField, DEAggregates, or DERelationCondition object contained in the DataEnvironment object.

Syntax

object.Count [=value]

The Count property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | Long. A numeric expression that specifies the number of members contained in the collection.

Remarks

For additional information, see Visual Basic's Count property.


Instancing Property

Sets a value that specifies whether you can create instances of a public class outside a project, and if so, how it will behave. Not available at run time.

Settings

The Instancing property has these settings:

Setting | Description
1 (Default) Private. Other applications aren’t allowed access to type library information about the class, and cannot create instances of it. Private objects are only for use within your component.

The Instancing property default varies depending on the project type. Private is the default only for class modules in Standard Exe projects.

When you insert a new class module into an ActiveX Exe project or an ActiveX DLL project, the default value of the Instancing property is MultiUse. When you insert a new class module into an ActiveX Control project, the default value of the Instancing property is PublicNotCreatable.
2 | PublicNotCreatable. Other applications can use objects of this class only if your component creates the objects first. Other applications cannot use the CreateObject function or the New operator to create objects from the class.
3 | SingleUse. Allows other applications to create objects from the class, but every object of this class that a client creates starts a new instance of your component. Not allowed in ActiveX DLL projects.
4 | GlobalSingleUse. Similar to SingleUse, except that properties and methods of the class can be invoked as if they were simply global functions. Not allowed in ActiveX DLL projects.
5 | MultiUse. Allows other applications to create objects from the class. One instance of your component can provide any number of objects created in this fashion.
6 | GlobalMultiUse. Similar to MultiUse, with one addition: properties and methods of the class can be invoked as if they were simply global functions. It’s not necessary to explicitly create an instance of the class first, because one will automatically be created.

Setting | Applies to Project Type
 | ActiveX Exe | ActiveX DLL | ActiveX Control | Std. Exe
Private | X | X | X | X
PublicNotCreatable | X | X | X |
SingleUse | X |  |  |
GlobalSingleUse | X |  |  |
MultiUse | X | X |  |
GlobalMultiUse | X | X |  |

Remarks

The Instancing property applies to Class modules and was expanded in Visual Basic 5.0 to incorporate the functionality of the Visual Basic 4.0 Public property.

When a class is creatable, you can use any of the following techniques to create instances of the class from other applications:

  • Use the CreateObject function, as in:
    Set MyInstance = CreateObject("MyProject.MyClass")
  • Use the Dim statement within the same project (or outside the project if the Public property is also set to True), as in:
    Dim MyInstance As New MyClass

    The New keyword indicates that MyInstance is to be declared as a new instance of MyClass.

If the Public property is False, the setting of the Instancing property is ignored. You can always create instances of the class within the project that defines the class. If the Public property is True, the class is visible and therefore can be controlled by other applications once an instance of the class exists.

Note The properties and methods of a GlobalMultiUse object are not part of the global name space of the component that provides the object. For example, within the project that contains the GlobalUtility class module, you must explicitly create an instance of GlobalUtility in order to use the object's properties and methods. Other limitations of global objects are listed in "Global Objects and Code Libraries," in "Building Code Components" in the Component Tools Guide.


CurrentX, CurrentY Properties

Return or set the horizontal (CurrentX) or vertical (CurrentY) coordinates for the next printing or drawing method. Not available at design time.

Syntax

object.CurrentX [= x]
object.CurrentY [= y]

The CurrentX and CurrentY properties syntax have these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
X | A number that specifies the horizontal coordinate.
Y | A number that specifies the vertical coordinate.

Remarks

Coordinates are measured from the upper-left corner of an object. The CurrentX property setting is 0 at an object's left edge, and the CurrentY property setting is 0 at its top edge. Coordinates are expressed in twips, or the current unit of measurement defined by the ScaleHeight, ScaleWidth, ScaleLeft, ScaleTop, and ScaleMode properties.

When you use the following graphics methods, the CurrentX and CurrentY settings are changed as indicated:

This method | Sets CurrentX, CurrentY to
Circle | The center of the object.
Cls | 0, 0.
EndDoc | 0, 0.
Line | The end point of the line.
NewPage | 0, 0.
Print | The next print position.
Pset | The point drawn.


CursorLocation Property

Returns or sets the location of the cursor library for the DEConnection or DECommand object.

Syntax

object.CursorLocation [=value]

The CursorLocation property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or numeric expression that specifies the cursor library location.

Remarks

Any DECommand object that is associated with a DEConnection object that has this property set automatically obtains the same setting. However, the setting can be overwritten while the Recordset is closed. When the Recordset is open, this property is read-only.

This property corresponds to the ADO Command and Connection CursorLocation property.


CursorType Property (DEDesigner Extensibility)

Returns or sets the type of cursor used when opening the DECommand object. You can only set this property when the cursor is closed.

Syntax

object.CursorType [=value]

The CursorType property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A value or constant that specifies the type of cursor used.

Remarks

If a provider cannot support the requested cursor type, the closest cursor type is used. If the CursorLocation property is adUseClient, the only cursor type supported is adOpenStatic. If the CursorLocation property is adUseServer, the available cursor types depend on the OLE DB provider or ODBC driver being used.

This property corresponds to the ADO Recordset CursorType property.


Data Property

Returns or sets a handle to a memory object or graphical device interface (GDI) object containing data in a specified format. Not available at design time.

Syntax

object.Data [ = number]

The Data property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | A Long integer specifying the handle.

Remarks

Set this property to send data to an application that created an object. Before using the Data property, set the Format property to specify the type of data contained in the memory object or GDI object.

You can get a list of acceptable formats for an object using the ObjectAcceptFormats and ObjectGetFormats properties.

Setting this property to 0 frees the memory associated with the handle.

Tip Automation provides an easier and more reliable solution for sending data and commands to and from an object. If an object supports Automation, you can access the object through the Object property or using the CreateObject and GetObject functions


DatabaseName Property

Returns or sets the name and location of the source of data for a Data control.

Syntax

object.DatabaseName [ = pathname ]

The DatabaseName property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
pathname | A string expression that indicates the location of the database file(s) or the Data Source name for ODBC data sources.

Remarks

If your network system supports it, the pathname argument can be a fully qualified network path name such as \\Myserver\Myshare\Database.mdb.

The database type is indicated by the file or directory that pathname points to, as follows:

pathname Points To... | Database Type
.mdb file | Microsoft Access database
Directory containing .dbf file(s) | dBASE database
Directory containing .xls file | Microsoft Excel database
Directory containing .dbf files(s) | FoxPro database
Directory containing .wk1, .wk3, .wk4, or .wks file(s) | Lotus Database
Directory containing .pdx file(s) | Paradox database
Directory containing text format database files | Text format database

For ODBC databases, such as SQL Server and Oracle, this property can be left blank if the control's Connect property identifies a data source name (DSN) that identifies an ODBC data source entry in the registry.

If you change the DatabaseName property after the control's Database object is open, you must use the Refresh method to open the new database.

Note For better performance when accessing external databases, it's recommended that you attach external database tables to a Microsoft Jet engine database (.mdb) and use the name of the Jet .mdb database in the DatabaseName property.

Data Type

String


DataBindingBehavior Property

Sets a value that determines if an object can be bound to a data source. Only available at design time.

Syntax

object.DataBindingBehavior [= number]

The DataBindingBehavior property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | An integer that specifies data binding behavior, as described in Settings.

Settings

The settings for number are:

Constant | Setting | Description
vbNone | 0 | (Default) The object can't be bound to a data source.
vbSimpleBound | 1 | The object can be bound to a data source using simple binding.
vbComplexBound | 2 | The object can be bound to a data source using complex binding.

Remarks

Use the DataBindingBehavior property when you want an object to act as a consumer of data provided by objects. A data consumer may be either simple bound (binding to single fields) or complex bound (binding to a rowset).

When DataBindingBehavior is set to 1 (vbSimpleBound), the PropertyChanged event and the CanPropertyChange method are added to the object's procedures.


DataBindings Property

Returns the DataBindings collection object containing the bindable properties available to the developer.

Syntax

object.DataBindings

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


DataChanged Property

Returns or sets a value indicating that the data in the bound control has been changed by some process other than that of retrieving data from the current record. Not available at design time.

Syntax

object.DataChanged [= value]

The DataChanged property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A Boolean expression that indicates whether data has changed, as described in Settings.

Settings

The settings for value are:

Setting | Description
True | The data currently in the control isn't the same as in the current record.
False | (Default) The data currently in the control, if any, is the same as the data in the current record.

Remarks

When a data control moves from record to record, it passes data from fields in the current record to controls bound to the specific field or the entire record. As data is displayed in the bound controls, the DataChanged property is set to False. If the user or any other operation changes the value in the bound control, the DataChanged property is set to True. Simply moving to another record doesn't affect the DataChanged property.

When the data control starts to move to a different record, the Validate event occurs. If DataChanged is True for any bound control, the data control automatically invokes the Edit and Update methods to post the changes to the database.

If you don't wish to save changes from a bound control to the database, you can set the DataChanged property to False in the Validate event.

Inspect the value of the DataChanged property in your code for a control's Change event to avoid a cascading event. This applies to both bound and unbound controls.

Data Type

Integer (Boolean)


DataFormat Property

Sets or returns the StdDataFormat object to which a bound object is attached. Read/write both at design time and run time.

Syntax

object.DataFormat = formatobject

The DataFormat property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
formatobject | Required. A StdDataFormat object.

Remarks

The DataFormat property can also be set through a property page from the Properties window. If the setting in code differs from the property page, the property page setting is used for the first record fetched, and from then on the values in code will be used.

The DataFormat property of the DataCombo control is an Extender property. Therefore it's always visible on the property sheet and can be set in code. However the DataCombo control only formats the top item in its list. This can be disconcerting to the end user who sees a formatted top item, but is only given a list of unformatted items to select from. The formatted item may also mislead end users who assume the item will be entered in the database as formatted. For these reasons, it's advisable to not set the DataFormat property when using the DataCombo control.


DataFormats Property

Sets or returns the StdDataFormat objects to which a bound object is attached. Read/write both at design time and run time.

Syntax

object.DataFormats

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Complex bound objects can be bound to multiple StdDataFormat objects. The DataGrid, for example, has one binding per column. The DataFormats property allows access to multiple StdDataFormat objects bound to a single control.

The DataFormats property can also be set through a property page from the Properties window. If the setting in code differs from the the property page, the property page setting is used for the first record fetched, and from then on the values in code will be used.


DataMember Property

Returns or sets a specified data member from among several offered by the data provider.

Syntax

object.DataMember [= string]

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
string | The name of a data member.

Remarks

A data provider can have multiple sets of data that that a data consumer can choose to bind to. Each set of data is called a "data member," and is identified by a unique string.

For example, when using a Data Environment that contains several Command objects as a DataSource, the DataMember specifies which Command object to use.

When using a class module or a user control as a data source, program the GetDataMember to return an appropriate data member. The event's DataMember argument contains the value of the DataMember property. By querying the argument, you can determine what data member is requested, and pass back the appropriate data through the Data argument.


BindingCollection Object, DataMembers Collection Example

The example uses a class module as a data source. When code to set the DataSource and DataMember properties of two Binding objects executes, the class module's Initialize event occurs; two ADO recordsets are created in that event, and the names of the recordsets are added to the DataMembers collection. The GetDataMember event and its arguments are used to return data to the data consumer.

To try the example, on the Project menu, click References, and set a reference to Microsoft Data Binding Collection and Microsoft ActiveX Data Objects. On the Project menu, click Add Class Module. Change the name of the class to MyDataClass, and set the DataSourceBehavior property to vbDataSource. Then draw two TextBox controls on a form. Paste the code into the Form object's code module.

Option Explicit
' Declare the object variables, one for a Class module named MyDataClass,
' and two more for each BindingCollection object one for each
' recordset).

Private clsData As New MyDataClass               ' Class module
Private bndColProducts As New BindingCollection  ' Bindings Collection
Private bndColSuppliers As New BindingCollection ' Bindings Collection

Private Sub Form_Load()
   ' Set DataSource and DataMember properties for each Bindings
   ' collection object.
   With bndColProducts
      .DataMember = "Products"
      Set .DataSource = clsData
      .Add Text1, "Text", "ProductName" ' Bind to a TextBox.
   End With

   With bndColSuppliers
      .DataMember = "Suppliers"
      Set .DataSource = clsData
      .Add Text2, "Text", "CompanyName" ' Bind to a TextBox.
   End With

   ' Change the Caption of Command1
   Command1.Caption = "MoveNext"

End Sub

Private Sub Command1_Click()
   clsData.MoveNext
End Sub

Paste the code below into the MyDataClass module. The DataSourceBehavior property must be set to vbDataSource in order to see the GetDataMember event. Run the project.

Option Explicit
' Declare object variables for ADO Recordset and Connection objects.
Private WithEvents rsProducts As ADODB.Recordset
Private WithEvents rsSuppliers As ADODB.Recordset
Private cnNwind As ADODB.Connection

Private Sub Class_Initialize()
   ' Add strings to the DataMembers collection.
   With DataMembers
      .Add "Products"
      .Add "Suppliers"
   End With

   ' Set Recordset objects.
   Set rsProducts = New ADODB.Recordset
   Set rsSuppliers = New ADODB.Recordset
   Set cnNwind = New ADODB.Connection

   ' Set the Connection object parameters.
   With cnNwind
      ' The Nwind.mdb that comes with Visual Basic must be installed on
      ' the computer or the code will fail. Otherwise alter the path to
      ' find the file on the computer.
      .Provider = "Microsoft.Jet.OLEDB.3.51"
      .Open "C:\Program Files\DevStudio\VB\Nwind.mdb"
   End With

   ' Open the recordset objects.
   rsSuppliers.Open "SELECT * FROM Suppliers", cnNwind, _
   adOpenStatic, adLockOptimistic
   rsProducts.Open "SELECT * FROM Products", cnNwind, _
   adOpenStatic, adLockOptimistic

End Sub

' The GetDataMember occurs when the DataSource property of a data
' consumer is set. In this case, the Bindings collection object is
' the consumer.
Private Sub Class_GetDataMember(DataMember As String, Data As Object)
   Select Case DataMember
   Case "Products"
      Set Data = rsProducts
   Case "Suppliers"
      Set Data = rsSuppliers
   Case ""
      ' Provide a default record source when no Data Member is specified.
      Set Data = rsProducts
   End Select

End Sub

Public Function MoveNext()
   If rsProducts.EOF Then
      rsProducts.MoveFirst
   Else
      rsProducts.MoveNext
   End If
End Function

Private Sub rsProducts_MoveComplete(ByVal adReason As _
ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As _
ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
   ' Keep the two recordsets in sync. The first textbox displays
   ' the supplier of the product. If the SupplierID for both
   ' recordsets are equivalent, no change needed. Otherwise,
   ' move to first record and test for SupplierID. This example
   ' is for demonstration only as the method is not the most
   ' efficient.

   If rsSuppliers("SupplierID").Value = _
   pRecordset("SupplierID").Value Then Exit Sub

   rsSuppliers.MoveFirst
   Do While Not rsSuppliers.EOF
      If rsSuppliers("SupplierID").Value = _
      pRecordset("SupplierID").Value Then
         Exit Sub
      Else
         rsSuppliers.MoveNext
      End If
   Loop
End Sub


DataMembers Property

Returns a reference to the DataMembers Collection.

Syntax

object.DataMembers

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

A data provider can have multiple sets of data that a data consumer can choose to bind to. Each set of data is called a "data member," and is identified by a unique string.

The DataMembers collection contains the names of all data members accessible to the data consumer.


DataSource Property

Returns or sets a data source through which a data consumer is bound to a database.

Syntax

object.DataSource [=datasource]

The DataSource property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
datasource | An object reference that qualifies as a data source, including ADO Recordset objects, and classes or user controls defined as data sources (DataSourceBehavior property = vbDataSource).

Remarks

Use the Set statement to set the DataSource property, as shown below:

Set Text1.DataSource = ADODC1

Note Two older controls, the Data control and RemoteData control, can be used as data sources, however you cannot set the DataSource property of another control or object to either of these controls at run time. For example, the following code will fail:

Set Text1.DataSource = Data1    ' Will fail! You can't set DataSource at
                              ' run time to an intrinsic Data control.

To use either the Data control or RemoteData control as a data source, you can set the DataSource property of bound controls at design time only.


DataSourceBehavior Property

Sets a value that determines if an object can act as a source of data for other objects. May only be set at design time.

Syntax

object.DataSourceBehavior [= number]

The DataSourceBehavior property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | An integer that specifies data source behavior, as described in Settings.

Settings

The settings for number are:

Constant | Setting | Description
vbNone | 0 | (Default) The object can't act as a data source.
vbDataSource | 1 | The object can act as a data source.
vbOLEDBProvider | 2 | The object can act as a data source and an OLEDB Provider. Available for Public Classes only.

Remarks

Use the DataSourceBehavior property when you want an object to act as a source of data for other objects. When DataSourceBehavior is set to 1 (vbDataSource) or 2 (vbOLEDBProvider), the GetDataMember event is added to the object’s procedures.

DataSourceBehavior may only be set to 2 (vbOLEDBProvider) when the object is a public class. In this case, the OnDataConnection event is also added to the object's procedures.


DataText Property

Returns a string from or sets a string for the specified object.

Syntax

object.DataText [ = string]

The DataText property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
String | A string expression specifying the string.

Remarks

To send a string to an object, first set the Format property to a format the object supports. Use the ObjectGetFormats and ObjectAcceptFormats properties to get a list of formats supported by an object.

When getting data from an object, the DataText property returns the string sent from the object, ending at the first null character.

The DataText string can be as large as available memory permits.

Tip Automation provides an easier and more reliable solution for sending data and commands to and from an object. If an object supports Automation, you can access the object through the Object property or using the CreateObject and GetObject functions.


DataText Property Example

This example sends data to the Microsoft Graph application, so you must have MS Graph installed on your system to run the example. (This is installed by most Microsoft Office components.) Create a form about one-half the size of the screen with a CommandButton control (Command1) in the upper-left corner of the form and an OLE container control (OLE1) placed below the CommandButton.

When you place the OLE container control on the form, the Insert Object dialog box is displayed. Choose Cancel and press F5 to run the example.

Private Sub Command1_Click ()
Dim Msg, NL, TB   ' Declare variables.
   TB = Chr(9)   ' Tab character.
   NL = Chr(10)   ' Newline character.
   ' Create data to replace default Graph data.
   Msg = TB + "Drew" & TB & "Teresa" & TB & "Bob"
   Msg = Msg + NL & "Eric" & TB & "1" & TB & "2" & TB & "3"
   Msg = Msg + NL & "Ted" & TB & "11" & TB & "22" & TB & "33"
   Msg = Msg + NL & "Arthur" & TB & "21" & TB & "32" & TB & "23"
   ' Send the data using the DataText property.
   ' Activate MSGRAPH as hidden.
Ole1.DoVerb - 3
   If Ole1.AppIsRunning Then
      Ole1.DataText = Msg
      ' Update the object.
      Ole1.Update
   Else
      MsgBox "Graph isn't active."
   End If
End Sub
Sub Form_Load ()
   Ole1.Format = "CF_TEXT"   ' Set the file format to text.
   Ole1.SizeMode = 2   ' Autosize.
   Ole1.CreateEmbed "", "MSGRAPH"
End Sub


DataTree (Datatree.vbp)

The DataTree sample application demonstrates how to use the TreeView control and the ListView control to view the contents of a small database (Biblio.mdb). The ProgressBar control is also used to give the user a visual indication of how long a process is taking.

File | Description
TreeView.frx | Binary data for the TreeView.frm
TreeView.frx | Form containing the TreeView, ListView, and Progressbar controls.
Datatree.vbp | Main project for the sample application.

To Run

From the Visual Basic File menu, choose Open Project and select the DataTree.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


DEAggregates Property

Returns a reference to the DEAggregates collection. Read-only.


DECommands Property

Returns a reference to the DECommands collection. Read-only.


DEConnections Property

Returns a reference to the DEConnections collection. Read-only.


Default Property

Returns or sets a value that determines which CommandButton control is the default command button on a form.

Syntax

object.Default [= boolean]

The Default property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression that specifies whether the command button is the default, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | The CommandButton is the default command button.
False | (Default) The CommandButton isn't the default command button.

Remarks

Only one command button on a form can be the default command button. When Default is set to True for one command button, it's automatically set to False for all other command buttons on the form. When the command button's Default property setting is True and its parent form is active, the user can choose the command button (invoking its Click event) by pressing ENTER. Any other control with the focus doesn't receive a keyboard event (KeyDown, KeyPress, or KeyUp) for the ENTER key unless the user has moved the focus to another command button on the same form. In this case, pressing ENTER chooses the command button that has the focus instead of the default command button.

For a form or dialog box that supports an irreversible action such as a delete operation, make the Cancel button the default command button by setting its Default property to True.

For OLE container controls, the Default property is provided only for those objects that specifically behave like CommandButton controls.


DefaultBind Property

Returns or sets the DefaultBind attribute of a Member object.

Syntax

object.DefaultBind

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


DefaultCancel Property

Returns or sets a value determining if a control can act as a standard command button. The DefaultCancel property is read/write at the control’s authoring time, and not available at the control’s run time.

Settings

The settings for DefaultCancel are:

Setting | Description
True | The control can act as a default or cancel command button. The container will add the Default and Cancel properties to the extender object. The presence of the Default and Cancel properties allow the control to act as a standard command button. The control can then set these added extender properties.
False | (Default) The control cannot act as a default or cancel command button. No constituent control can have its Default or Cancel property set to True.

Remarks

Setting the Default property to True and also having a constituent control with its Default property set to True will cause the constituent control to be pressed when the ENTER key is pressed, otherwise the control’s AccessKeyPress event will be raised when the ENTER key is pressed.

Setting the Cancel property to True and also having a constituent control with its Cancel property set to True will cause the constituent control to be pressed when the ESCAPE key is pressed, otherwise the control’s AccessKeyPress event will be raised when the ESCAPE key is pressed.

Important The status of a default or cancel button can change at any time. Code must be placed in the control’s AmbientChanged event procedure to detect changes in the DisplayAsDefault property, and the control’s appearance adjusted accordingly.


DefaultCursorType Property (Data Control)

Controls what type of cursor driver is used on the connection (ODBCDirect only) created by the Data control.

Syntax

object.DefaultCursorType [ = value ]

The DefaultCursorType property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | An integer constant or value that specifies a type of cursor driver, as described in Settings.

Settings

The settings for value are:

Setting | Value | Description
vbUseDefaultCursor | 0 | Let the ODBC driver determine which type of cursors to use.
vbUseODBCCursor | 1 | Use the ODBC cursor library. This option gives better performance for small result sets, but degrades quickly for larger result sets.
vbUseServerSideCursor | 2 | Use server side cursors. For most large operations this gives better performance, but might cause more network traffic.

Remarks

Use this property when the DefaultType property of the Data control is set to dbUseODBC. Refer to the DefaultCursorDriver property of the Workspace object for more information.

Data Type

Integer


DefaultType Property (Data Control)

Returns or sets a value which determines the type of data source (Jet or ODBCDirect) that is used by the Data control.

Syntax

object.DefaultType [= value ]

The DefaultType property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | An integer constant or value that specifies the type of data source, as described in Settings.

Settings

The settings for value are:

Setting | Value | Description
dbUseODBC | 1 | Use ODBCDirect to access your data.
dbUseJet | 2 | (Default) Use the Microsoft Jet database engine to access your data.

Remarks

Setting the DefaultType property tells the Data control what type of data source (Jet or ODBCDirect) to use when creating a Recordset. The DefaultType property also determines the type of the underlying Workspace object used with the Data control. The Jet database engine will not be loaded unless this property is set to dbUseJet.

When setting the DefaultType property to dbUseODBC, Visual Basic creates a new Workspace object and adds it to the Workspaces collection. The DefaultType property of the Data control is similar to the type parameter of the CreateWorkspace method. When using dbUseJet, the default Workspace object is used.

Note When you select dbUseODBC for the DefaultType property, DAO routes all data access operations through a Remote Data Objects (RDO) DLL. Also, if you select "1 - UseODBC" in the DefaultType property in the property sheet, you must also specify an ODBC connect string in the Connect property box. To do this, select Text, then enter the ODBC connect string. For more information on ODBC connect strings, see the Visual Basic Data Access Guide.

Choosing a Data Source

Data Access Objects (DAO) can be programmed to connect to remote ODBC data sources in one of two ways: through the Jet database engine or through Remote Data Objects (RDO) which bypasses Jet completely. Depending on the features and performance you need, either approach might make sense for your particular application.

Using ODBCDirect: This approach permits you to use the Data control against remote ODBC data sources by routing all DAO operations through the RDO interface. That is, when you establish a connection and create a Recordset object using the Data control, the Jet database engine is not loaded or used in any way. This also means that many of the DAO features provided by the Jet engine are not available on this Workspace. For example, you cannot perform heterogeneous joins, or access ISAM on .mdb databases without use of additional ODBC drivers. However, when you choose ODBCDirect, many RDO features not ordinarily supported by Jet are enabled.

Using The Jet Database Engine: Unless you enable ODBCDirect, the Jet database engine is loaded and performs all local and remote database operations. Once a Jet Workspace is created, it cannot be used to pass data to an ODBCDirect Workspace.

Data Type

Integer


DEFields Property

Returns a reference to the DEFields collection. Read-only.


DefinedSize Property

Returns the size of the DEField object value, as defined by the structure of the database. This property is read-only.

Note This property is different from the ADO ActualSize property, which returns the actual size of a given field within a given row.

Syntax

object.DefinedSize [=value]

The DefinedSize property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A Long value that specifies the defined size of the DEField object.

Remarks

This property corresponds to the ADO Field DefinedSize property.


DEGroupingFields Property

Returns a reference to the DEGroupingFields collection. Read-only.


DEParameters Property

Returns a reference to the DEParameters collection. Read-only.


DERelationConditions Property

Returns a reference to the DERelationConditions collection. Read-only.


DesignPassword Property

Returns or sets the password for the user name at design time.

Note This property is only saved when the DesignSaveAuthentication property is True.

Syntax

object.DesignPassword [=string]

The DesignPassword property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that defines the password that is used at design time.

Remarks

This property is passed to ADO by appending "Password=" and a value onto the connection string which is passed to ADO at design time.


DesignPromptBehavior Property

Specifies the prompting behavior by the DEConnection object, such as when to request logon information, at design time.

Syntax

object.DesignPromptBehavior [=value]

The DesignPromptBehavior property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies the prompt behavior of the DEConnection object.

Remarks

This property corresponds to the ADO Connection Prompt property.


DesignSaveAuthentication Property

Specifies whether the authentication information is saved with the design-time class.

Syntax

object.DesignSaveAuthentication [=Boolean]

The DesignSaveAuthentication property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that specifies whether to save the authentication information with the design-time class. The default is False.

Remarks

When set to True, the user identification and password are saved with the project.

Note Since the password is not encrypted, for maximum security you should not specify your password to persist for design time.


DesignUserName Property

Returns or sets the user name that is used when the connecting to the data source at design time.

Note This property is only saved if the DesignSaveAuthentication property is True.

Syntax

object.DesignUserName [=string]

The DesignUserName property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the user name to use when connecting to the data source at design time.

Remarks

This property is passed to ADO by appending "User ID=" and a value onto the connection string that is passed to ADO at design time.


DeviceName Property

Returns the name of the device a driver supports.

Syntax

object.DeviceName

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Each printer driver supports one or more devices — for example, HP LaserJet IIISi is a device name.

Note The effect of properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may produce an error. For more information, see the manufacturer's documentation for the specific driver.


Direction Property (DEDesigner Extensibility)

Returns or sets the direction in which a DEParameter object is passed to or from a procedure.

Syntax

object.Direction [=value]

The Direction property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies the direction.

Remarks

This property corresponds to the ADO Parameter Direction property.


DisabledPicture Property

Returns or sets a reference to a picture to display in a control when it is disabled. (That is, when its Enabled property is set to False.)

Syntax

object.DisabledPicture [= picture]

The DisabledPicture property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
picture | A Picture object containing a graphic, as described in Settings.

Settings

The settings for picture are:

Setting | Description
(None) | (Default) No picture.
(Bitmap, icon, metafile) | Specifies a graphic. You can load the graphic from the Properties window at design time. At run time, you can also set this property by using the LoadPicture function on a bitmap, icon, or metafile, or by setting it to the Picture property of another control.

Remarks

The DisabledPicture property specifies a picture object to display when the control (such as a CommandButton) is disabled. The DisabledPicture property is ignored unless the Style property of the control is set to 1 (graphical).

The picture is centered horizontally and vertically on the control. If there is a caption as well as a picture, the picture is centered above the caption. If the picture object is too large to fit on the control, then it is clipped.

If no picture is assigned to the DisabledPicture property, but one is assigned to the Picture property, then a grayed version of that picture is displayed when the control is disabled.


DisableWarnings Property

Returns or sets whether warning messages display when using the Data Environment designer.

Note When you change this property for one DataEnvironment object, all DataEnvironment objects on your system automatically incur the change.

Syntax

object.DisableWarnings [=Boolean]

Parameters

The DisableWarnings property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that specifies whether warning messages are disabled or enabled.

Remarks

This property corresponds to the Disable Warnings check box in the Options dialog box and is specific to your system. When adding and removing objects using the extensibility object, you may want to programmatically set this property so no user interfaces appear.


DisplayAsDefault Property

Returns a boolean value to determine if the control is the default button for the container, and therefore should display itself as the default control.

Syntax

object.DisplayAsDefault

The DisplayAsDefault property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Settings

The possible boolean return values from the DisplayAsDefault property are:

Setting | Description
True | The control is the default button.
False | The control is not the default button. If the container does not implement this ambient property, this will be the default value.

Remarks

Only one control in a container may be the default control; the container of the control will determine which control is currently the default control and notify that control through the DisplayAsDefault ambient property. The notified control should draw itself to show it is the default control. All other controls will have their DisplayAsDefault ambient property value be False.

Only button type controls may be default controls.


DisplayBind Property

Returns or sets the DisplayBind attribute of a Member object.

Syntax

object.DisplayBind

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


DisplayName Property (DEDesigner Extensibility)

Returns a description of the connection, which includes the database and user name, that is displayed in the Data View.

Syntax

object.DisplayName [=string]

Parameters

The DisplayName property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the database and user name that is used by Data View.


DisplayName Property

Returns a string value that contains the name the control should display to identify itself in error messages.

Syntax

object.DisplayName

The DisplayName property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

This ambient property is the way the control finds out what the container (such as Visual Basic) is calling this instance of the control. This string should be used in error messages as the name for the instance of the control.

If the container does not implement this ambient property, the default value will be an empty string.


DisplayType Property

Returns or sets a value indicating whether an object displays its contents or an icon.

Syntax

object.DisplayType [ = value]

The DisplayType property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | An integer or constant specifying whether an object displays its contents or an icon, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
vbOLEDisplayContent | 0 | (Default) Content. When the OLE container control contains an object, the object's data is displayed in the control.
vbOLEDisplayIcon | 1 | Icon. When the OLE container control contains an object, the object's icon is displayed in the control.

Remarks

This property determines the default setting of the Display As Icon check box in the Insert Object and Paste Special dialog boxes. When you display these dialog boxes either at run time (with the InsertObjDlg or PasteSpecialDlg methods) or design time, the Display As Icon check box is automatically selected if this property is set to 1 (Icon).

When creating an object at run time using the CreateEmbed or CreateLink methods, use the DisplayType property to determine if the object is displayed as an icon (set DisplayType = 1) or if the object's data is displayed in the control (set DisplayType = 0).

Once you create an object, you can't change its display type.


DownPicture Property

Returns or sets a reference to a picture to display in a control when it is clicked and in the down (depressed) position.

Syntax

object.DownPicture [= picture]

The DownPicture property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
picture | A Picture object containing a graphic, as described in Settings.

Settings

The settings for picture are:

Setting | Description
(None) | (Default) No picture.
(Bitmap, icon, metafile) | Specifies a graphic. You can load the graphic from the Properties window at design time. At run time, you can also set this property by using the LoadPicture function on a bitmap, icon, or metafile, or by setting it to the Picture property of another control.

Remarks

The DownPicture property refers to a picture object that displays when the button is in the down state. The DownPicture property is ignored unless the Style property is set to 1 (graphical). Note that when an OptionButton or CheckBox control’s Style property is set to graphical and its button depressed, the background of the button is dithered, but the picture on the button is not.

The picture is centered both horizontally and vertically on the button. If there is a caption included with the picture, the picture will be centered above the caption. If no picture is assigned to this property when the button is depressed, then the picture currently assigned to the Picture property is used. If no picture is assigned to either the Picture or DownPicture properties, then only the caption is displayed. If the picture object is too large to fit on the button, then it is clipped.


DragIcon Property

Returns or sets the icon to be displayed as the pointer in a drag-and-drop operation.

Syntax

object.DragIcon [= icon]

The DragIcon property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Icon | Any code reference that returns a valid icon, such as a reference to a form's icon (Form1.Icon), a reference to another control's DragIcon property (Text1.DragIcon), or the LoadPicture function.

Settings

The settings for icon are:

Setting | Description
(none) | (Default) An arrow pointer inside a rectangle.
Icon | A custom mouse pointer. You specify the icon by setting it using the Properties window at design time. You can also use the LoadPicture function at run time. The file you load must have the .ico filename extension and format.

Remarks

You can use the DragIcon property to provide visual feedback during a drag-and-drop operation — for example, to indicate that the source control is over an appropriate target. DragIcon takes effect when the user initiates a drag-and-drop operation. Typically, you set DragIcon as part of a MouseDown or DragOver event procedure.

Note At run time, the DragIcon property can be set to any object's DragIcon or Icon property, or you can assign it an icon returned by the LoadPicture function.

When you set the DragIcon property at run time by assigning the Picture property of one control to the DragIcon property of another control, the Picture property must contain an .ico file, not a .bmp file.


DragIcon Property Example

This example changes the DragIcon property setting each time you drag a PictureBox control. To try this example, paste the code into the Declarations section of a form that contains a PictureBox control. Set the DragMode property = 1, and then press F5 and click and drag the PictureBox control.

Private Sub Form_DragDrop (Source As Control, X As Single, Y As Single)
   Dim Pic   ' Declare variable.
   Source.Move X, Y   ' Set position of control.
   Pic = "ICONS\OFFICE\CRDFLE01.ICO"   ' Get name of icon file.
   If Source.DragIcon = False Then   ' If no picture loaded,
      Source.DragIcon = LoadPicture(Pic)   ' load picture.
   Else
      Source.DragIcon = LoadPicture()   ' Unload picture.
   End If
End Sub


DragMode Property

Returns or sets a value that determines whether manual or automatic drag mode is used for a drag-and-drop operation.

Syntax

object.DragMode [= number]

The DragMode property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | An integer that specifies the drag mode, as described in Settings.

Settings

The settings for number are:

Constant | Setting | Description
VbManual | 0 | (Default) Manual — requires using the Drag method to initiate a drag-and-drop operation on the source control.
VbAutomatic | 1 | Automatic — clicking the source control automatically initiates a drag-and-drop operation. OLE container controls are automatically dragged only when they don't have the focus.

Remarks

When DragMode is set to 1 (Automatic), the control doesn't respond as usual to mouse events. Use the 0 (Manual) setting to determine when a drag-and-drop operation begins or ends; you can use this setting to initiate a drag-and-drop operation in response to a keyboard or menu command or to enable a source control to recognize a MouseDown event prior to a drag-and-drop operation.

Clicking while the mouse pointer is over a target object or form during a drag-and-drop operation generates a DragDrop event for the target object. This ends the drag-and-drop operation. A drag-and-drop operation may also generate a DragOver event.

Note While a control is being dragged, it can't recognize other user-initiated mouse or keyboard events (KeyDown, KeyPress or KeyUp, MouseDown, MouseMove, or MouseUp). However, the control can receive events initiated by code or by a DDE link.


DragMode Property Example

This example enables and disables the ability to drag a CommandButton control each time a form is clicked. To try this example, paste the code into the Declarations section of a form that contains a CommandButton, and then press F5 and click the form.

Private Sub Form_Click ()
 ' Check DragMode.
   If Command1.DragMode = vbManual Then
      ' Turn it on.
  Command1.DragMode = vbAutomatic
   Else
      ' Or turn it off.
     Command1.DragMode = vbManual
   End If
End Sub


DrawMode Property

Returns or sets a value that determines the appearance of output from graphics method or the appearance of a Shape or Line control.

Syntax

object.DrawMode [= number]

The DrawMode property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | An integer that specifies appearance, as described in Settings.

Settings

The settings for number are:

Constant | Setting | Description
VbBlackness | 1 | Blackness.
VbNotMergePen | 2 | Not Merge Pen — Inverse of setting 15 (Merge Pen).
VbMaskNotPen | 3 | Mask Not Pen — Combination of the colors common to the background color and the inverse of the pen.
VbNotCopyPen | 4 | Not Copy Pen — Inverse of setting 13 (Copy Pen).
VbMaskPenNot | 5 | Mask Pen Not — Combination of the colors common to both the pen and the inverse of the display.
VbInvert | 6 | Invert — Inverse of the display color.
VbXorPen | 7 | Xor Pen — Combination of the colors in the pen and in the display color, but not in both.
VbNotMaskPen | 8 | Not Mask Pen — Inverse of setting 9 (Mask Pen).
VbMaskPen | 9 | Mask Pen — Combination of the colors common to both the pen and the display.
VbNotXorPen | 10 | Not Xor Pen — Inverse of setting 7 (Xor Pen).
VbNop | 11 | Nop — No operation — output remains unchanged. In effect, this setting turns drawing off.
VbMergeNotPen | 12 | Merge Not Pen — Combination of the display color and the inverse of the pen color.
VbCopyPen | 13 | Copy Pen (Default) — Color specified by the ForeColor property.
VbMergePenNot | 14 | Merge Pen Not — Combination of the pen color and the inverse of the display color.
VbMergePen | 15 | Merge Pen — Combination of the pen color and the display color.
VbWhiteness | 16 | Whiteness.

Remarks

Use this property to produce visual effects with Shape or Line controls or when drawing with the graphics methods. Visual Basic compares each pixel in the draw pattern to the corresponding pixel in the existing background and then applies bit-wise operations. For example, setting 7 (Xor Pen) uses the Xor operator to combine a draw pattern pixel with a background pixel.

The exact effect of a DrawMode setting depends on the way the color of a line drawn at run time combines with colors already on the screen. Settings 1, 6, 7, 11, 13, and 16 yield the most predictable results.


DrawMode Property Example

This example enables drawing on a form by dragging the mouse pointer. Each mouse click sets a different value for the DrawMode property. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Load
   DrawWidth = 10   ' Set DrawWidth.
End Sub
Private Sub Form_Click ()
   Static M As Integer   ' Current DrawMode setting.
   ForeColor = QBColor(Int(Rnd * 15))   ' Choose a color.
   M = ((M + 1) Mod 16) + 1   ' Keep DrawMode 16 or less.
   DrawMode = M   ' Set DrawMode.
End Sub
Private Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
   If Button Then   ' While button is pressed,
      PSet (X, Y)   ' draw a big point.
   End If
End Sub


DrawStyle Property

Returns or sets a value that determines the line style for output from graphics methods.

Syntax

object.DrawStyle [= number]

The DrawStyle property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | An integer that specifies line style, as described in Settings.

Settings

The settings for number are:

Constant | Setting | Description
VbSolid | 0 | (Default) Solid
VbDash | 1 | Dash
VbDot | 2 | Dot
VbDashDot | 3 | Dash-Dot
VbDashDotDot | 4 | Dash-Dot-Dot
VbInvisible | 5 | Transparent
VbInsideSolid | 6 | Inside Solid

Remarks

If DrawWidth is set to a value greater than 1, DrawStyle settings 1 through 4 produce a solid line (the DrawStyle property value isn't changed). If DrawWidth is set to 1, DrawStyle produces the effect described in the preceding table for each setting.


DrawStyle Property Example

This example draws seven lines across a form, with each line displaying a different DrawStyle property. (If you set AutoRedraw = True, the form accumulates a new set of lines each time you resize it and then click it.) To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim I   ' Declare variable.
   ScaleHeight = 8   ' Divide height by 8.
   For I = 0 To 6
      DrawStyle = I   ' Change style.
      Line (0, I + 1) - (ScaleWidth, I + 1)   ' Draw new line.
   Next I
End Sub


DrawWidth Property

Returns or sets the line width for output from graphics methods.

Syntax

object.DrawWidth [= size]

The DrawWidth property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
size | A numeric expression from 1 through 32,767. This value represents the width of the line in pixels. The default is 1; that is, 1 pixel wide.

Remarks

Increase the value of this property to increase the width of the line. If the DrawWidth property setting is greater than 1, DrawStyle property settings 1 through 4 produce a solid line (the DrawStyle property value isn't changed). Setting DrawWidth to 1 allows DrawStyle to produce the results shown in the DrawStyle property table.


DrawWidth Property Example

This example draws a gradually thickening line across a form. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim I   ' Declare variable.
   DrawWidth = 1   ' Set starting pen width.
   PSet (0, ScaleHeight / 2)   ' Set starting point.
   ForeColor = QBColor(5)   ' Set pen color.
   For I = 1 To 100 Step 10   ' Set up loop.
      DrawWidth = I   ' Reset pen width.
      Line - Step(ScaleWidth / 10, 0)   ' Draw a line.
   Next I
End Sub


Drive Property

Returns or sets the selected drive at run time. Not available at design time.

Syntax

object.Drive [= drive]

The Drive property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Drive | A string expression that specifies the selected drive.

Remarks

The valid drives for the Drive property include all drives present in or connected to the system when the control is created or refreshed at run time. The default setting of the Drive property is the current drive.

When reading this property setting, the selected drive is returned in one of the following formats:

  • Floppy disks — "a:" or "b:", and so on

  • Fixed media — "c: [volume id]"

  • Network connections — "x: \\server\share"

When setting this property:

  • Only the first character of the string is significant (the string isn't case-sensitive).

  • Changing the setting for the Drive property invokes a Change event.

  • Selecting a drive that isn't present causes an error.

  • Setting this property also regenerates the drive list, providing a way in code to track network connections added since the control was created.

If the FileName property is set to a qualified network path without a drive designation, the value of the Drive property is a zero-length string (""), no drive is selected, and the ListIndex property setting is –1.

Note The Drive property returns a different value from the ListIndex property, which returns the list box selection.


DriverName Property

Returns the name of the driver for a Printer object.

Syntax

object.DriverName

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Each driver has a unique name. For example, the DriverName for several of the Hewlett-Packard printers is HPPCL5MS. The DriverName is typically the driver's filename without an extension.

Note The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may produce an error. For more information, see the manufacturer's documentation for the specific driver.


Drive Property Example

This example displays a list of files for the current drive and directory. To try this example, paste the code into the Declarations section of a form that contains a DriveListBox control, a DirListBox control, and a FileListBox control, and then press F5. Use the mouse to change the drive or directory.

Private Sub Drive1_Change ()
   Dir1.Path = Drive1.Drive   ' When drive changes, set directory path.
End Sub
Private Sub Dir1_Change ()
   File1.Path = Dir1.Path   ' When directory changes, set file path.
End Sub


Duplex Property

Returns or sets a value that determines whether a page is printed on both sides (if the printer supports this feature). Not available at design time.

Syntax

object.Duplex [= value]

The Duplex property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A value or constant that specifies the type of printing, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
VbPRDPSimplex | 1 | Single-sided printing with the current orientation setting.
VbPRDPHorizontal | 2 | Double-sided printing using a horizontal page turn.
VbPRDPVertical | 3 | Double-sided printing using a vertical page turn.

Remarks

With horizontal duplex printing, the top of both sides of the page are at the same end of the sheet. With vertical duplex printing, the bottom of one page is at the same end of the sheet as the top of the next page. The following diagram illustrates horizontal and vertical duplex printing:

Note The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may produce an error. For more information, see the manufacturer's documentation for the specific driver.


EventsFrozen Property

EditAtDesignTime Property

Returns or sets a value determining if a control can become active during the developer design time. The EditAtDesignTime property is read/write at the control’s authoring time, and not available at the control’s run time.

Settings

The settings for EditAtDesignTime are:

Setting | Description
True | Allows the control to become active at the developer design time. An Edit verb will appear on the control’s context menu. When the developer who uses the control chooses Edit, the control will become active and behave as it does at end user run time.
False | (Default) The control cannot become active at developer design time.

Remarks

The control will only remain active while it is selected. When the developer selects another control, this control will no longer be active, even if the developer clicks back on this control. The developer must select Edit again from the context menu to make the control active.

Note When the control is activated in this fashion, the events of the UserControl object will occur, so that the control can operate normally, but the control will be unable to raise any events. The RaiseEvent method will simply be ignored; it will not cause an error.


Enabled Property

Returns or sets a value that determines whether a form or control can respond to user-generated events.

Syntax

object.Enabled [= boolean]

The Enabled property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list. If object is omitted, the form associated with the active form module is assumed to be object.
boolean | A Boolean expression that specifies whether object can respond to user-generated events.

Settings

The settings for boolean are:

Setting | Description
True | (Default) Allows object to respond to events.
False | Prevents object from responding to events.

Remarks

The Enabled property allows forms and controls to be enabled or disabled at run time. For example, you can disable objects that don't apply to the current state of the application. You can also disable a control used purely for display purposes, such as a text box that provides read-only information.

Disabling a Timer control by setting Enabled to False cancels the countdown set up by the control's Interval property.

For a Menu control, Enabled is normally read/write at run time. But Enabled is read-only for menu items that are exposed or supplied by Visual Basic to add-ins, such as the Add-In Manager command on the Add-Ins menu.


Enabled Property Example

This example enables a CommandButton control whenever a TextBox control contains text. To try this example, paste the code into the Declarations section of a form with CommandButton and TextBox controls, and then press F5 and enter something into the text box.

Private Sub Form_Load ()
   Text1.Text = ""   ' Clear the text box.
   Command1.Caption = "Save"   ' Put caption on button.
End Sub

Private Sub Text1_Change ()
   If Text1.Text = "" Then   ' See if text box is empty.
      Command1.Enabled = False   ' Disable button.
   Else
      Command1.Enabled = True   ' Enable button.
   End If
End Sub


ErrorNumber Property

Returns a numeric value specifying an error.

Syntax

object.ErrorNumber

The object placeholder is an object expression that evaluates to an object in the Applies To list.

Return Type

Long


Error Property (WebClass Object)

Returns a reference to the Active Server Pages’ Error object.

Syntax

object.Error

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The Error property value is null during normal execution, but valid during execution of the FatalError event.


Errors (Errors.vbp)

This sample application demonstrates various Visual Basic error handling techniques, including examples of inline and centralized error handling.

Background

The sample is comprised of a single form with a set of command buttons to invoke error handling procedures, plus a basic module containing a central error handling routine. By stepping through the code in the procedures you can see the effects of different error handling methods. For more information, see "Debugging Your Code and Handling Errors," in the Programmer's Guide.

File | Description
Errors.bas | Module containing centralized error handling code.
Errors.frm | Form demonstrating error handling techniques.
Errors.vbp | The project file for the sample application.

To Run

From the Visual Basic File menu, choose Open Project and select the Errors.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


EventsFrozen Property

Returns a value indicating if the container is currently ignoring events being raised by the control. The EventsFrozen property is not available at the control’s authoring time, and read-only at the control’s run time.

Syntax

object.EventsFrozen

The EventsFrozen property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

When the EventsFrozen property is True, the container is ignoring any events that are being raised by the control. If the control wants to raise an event that cannot be lost, it must queue them up until EventsFrozen is False.


Exclusive Property

Returns or sets a value that indicates whether the underlying database for a Data control is opened for single-user or multi-user access.

Syntax

object.Exclusive [ = value]

The Exclusive property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A Boolean expression that determines user access, as described in Settings.

Settings

The settings for value are:

Setting | Description
True | The database is open for single-user access. No one else can open the database until it's closed.
False | (Default) The database is open for multi-user access. Other users can open the database and have access to the data while it's open.

Remarks

The value of this property, along with the DatabaseName, ReadOnly, and Connect properties, is used to open a database. In the Professional and Enterprise Editions, this property corresponds to the exclusive argument in the OpenDatabase method.

The Exclusive property is used only when opening the Database. If you change the value of this property at run time, you must use the Refresh method for the change to take effect. If someone else already has the database open, you can't open it for exclusive use and a trappable error results.

Database operations are faster if the database is opened for exclusive use.

After you open a database for exclusive use, your application can have as many instances open as necessary. However, other applications running on your system are not permitted to open the database.

The Exclusive property is ignored for databases accessed through ODBC.

Data Type

Boolean


EXEName Property

Returns the root name of the executable file (without the extension) that is currently running. If running in the development environment, returns the name of the project.

Syntax

object.EXEName

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


ExportFormats Property

Returns a reference to the ExportFormats collection.

Syntax

object.ExportFormats

object.ExportFormats(index)

The ExportFormats property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
index | Optional. The Index or Key of a member of the collection.

Remarks

The property uses collection syntax to specify either the collection or a member of the collection to return.

The ExportFormat object's FileFormatString property determines what text will be displayed in the Save As Type box of the Export dialog box.


Extender Property

Returns the Extender object for this control that holds the properties of the control that are kept track of by the container. The Extender property is not available at the control’s authoring time, and read-only at the control’s run time.

Syntax

object.Extender

The Extender property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.


FalseValue Property

Sets or returns a value used to format and unformat Boolean False values. Read/write both at design time and run time.

Syntax

object.FalseValue [= value]

The FalseValue property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | Optional Variant. In the Format event, if the data is a Boolean False, value is returned. If value is empty, then the integer value 1 is returned. In the Unformat event, if the data matches value, a Boolean False is written to the database. Defaults to False.

Remarks

Ignored unless the Type property is set to fmtBoolean. The FalseValue property is read each time data is fetched.


FieldToAggregate Property

Returns or sets the name of the DEField object on which the aggregate is based.

Syntax

object.FieldToAggregate [=string]

The FieldToAggregate property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the name of the DEField object on which the aggregate is based.

Remarks

The valid fields that can be specified depend on whether the Command object is grouped or used in a relation hierarchy. If the AggregateType property is deGrouping, all the fields in the current DECommand object are available. If deGrandTotal and the Command object is grouped, only grouping fields are available; if not grouped all fields are available. If deRelation and the child DECommand object is grouped, only grouping fields are available; if the child is not grouped, all child fields are available.


FileCtls (FileCtls.vbp)

This sample application allows the user to search a directory for specific files, or files with a particular extension. The sample uses file-system controls such as the File ListBox, Drive ListBox, and Directory ListBox controls.

File | Description
Seek.frm | The main form for the sample.
Winseek.vbp | The project file for the sample.

To Run

From the Visual Basic File menu, choose Open Project and select the Winseek.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


FileDescription Property

Returns or sets a string value containing file description information about the running application. Read only at run time.

Syntax

object.FileDescription

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You can set this property at design time in the Type box in the Make tab of the Project Properties dialog box.


FileFilter Property

Returns or sets the file filter (extension) to use when exporting a report.

Syntax

object.FileFilter [=string]

The FileFilter property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
string | Optional. The extension to use for creating a file in the ".xxx" format.

Remarks

The FileFilter property determines what filter will be displayed in the Export dialog box.

The property can be assigned multiple filters by separating each filter with a semicolon (but no spaces), as shown below:

DataReport1.ExportFormats(5).FileFilter = "*.htm;*.html"

Note, however, that the FileFilter should match the FormatType type assigned to the ExportFormat object. For example, setting FileFilter to "*.htm" and FormatType to rptFmtText is an invalid pair of settings. Also note that no error will be raised for this state.


FileFormatString Property

Returns or sets the string to be displayed in the Save As combo box of the Export dialog box.

Syntax

object.FileFormatString [= string]

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
string | Optional. The string associated with the ExportFormat object and displayed in the Export dialog box

Remarks

The FileFormatString property commonly includes a name to identify the ExportFormat object and the value of the FileFilter property, as shown in the example below:

DataReport1.ExportFormats(5).FileFormatString = "Daily Report (*.HTM)"


FileName Property

Returns or sets the path and filename of a selected file. Not available at design time for the FileListBox control.

Syntax

object.FileName [= pathname]

The FileName property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Pathname | A string expression that specifies the path and filename.

Remarks

When you create the control at run time, the FileName property is set to a zero-length string (""), meaning no file is currently selected.

In the CommonDialog control, you can set the FileName property before opening a dialog box to set an initial filename.

Reading this property returns the currently selected filename from the list. The path is retrieved separately, using the Path property. The value is functionally equivalent to List(ListIndex). If no file is selected, FileName returns a zero-length string.

When setting this property:

  • Including a drive, path, or pattern in the string changes the settings of the Drive, Path, and Pattern properties accordingly.

  • Including the name of an existing file (without wildcard characters) in the string selects the file.

  • Changing the value of this property may also cause one or more of these events: PathChange (if you change the path), PatternChange (if you change the pattern), or DblClick (if you assign an existing filename).

  • This property setting can be a qualified network path and filename using the following syntax:
    \\servername\sharename\pathname


FileName Property Example

This example displays a message in a Label control when a filename in a FileListBox control is double-clicked. To try this example, paste the code into the Declarations section of a form that contains a Label control, a DirListBox control, and a FileListBox control, and then press F5 and double-click any filename in the FileListBox control.

Private Sub Dir1_Change ()
   File1.Path = Dir1.Path   ' Set File1 path.
End Sub
Private Sub File1_PathChange ()
   Dir1.Path = File1.Path   ' Set Dir1 path.
End Sub
Private Sub File1_DblClick ()
   ' Display the selected filename when double-clicked.
   Label1.Caption = "Your selection: " +_ File1.FileName
End Sub


FileNumber Property

Returns or sets the file number to be used when saving or loading an object, or returns the last file number used. Not available at design time.

Note The FileNumber property is included for compatibility with the Action property in earlier versions. For current functionality, use the SaveToFile and ReadFromFile methods.

Syntax

object.FileNumber [ = number]

The FileNumber property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression specifying the file number.

Remarks

The file number must correspond to an open, binary file.

You can use this property to specify the number of the file to be opened with the ReadFromFile method or saved with the SaveToFile or SaveToOle1File methods.


Files Property

Returns a DataObjectFiles collection, which in turn contains a list of all filenames used by a DataObject object (such as the names of files that a user drags to or from the Windows File Explorer.)

Syntax

object.Files(index)

The Files collection syntax has these parts:

Part | Description
object | An object expression that evaluates to a DataObject object.
index | An integer which is an index to an array of filenames.

Remarks

The Files collection is filled with filenames only when the DataObject object contains data of type vbCFFiles. (The DataObject object can contain several different types of data.) You can iterate through the collection to retrieve the list of file names.

The Files collection can be filled to allow Visual Basic applications to act as a drag source for a list of files.


FillColor Property

Returns or sets the color used to fill in shapes; FillColor is also used to fill in circles and boxes created with the Circle and Line graphics methods.

Syntax

object.FillColor [ = value]

The FillColor property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A value or constant that determines the fill color, as described in Settings.

Settings

The settings for value are:

Setting | Description
Normal RGB colors | Colors set with the RGB or QBColor functions in code.
System default colors | Colors specified with the system color constants in the Visual Basic (VB) object library in the Object Browser. The Microsoft Windows operating environment substitutes the user's choices, as specified by the user's Control Panel settings.

By default, FillColor is set to 0 (Black).

Remarks

Except for the Form object, when the FillStyle property is set to its default, 1 (Transparent), the FillColor setting is ignored.


FillColor Property Example

This example constructs a circle on your form with random FillColor and FillStyle property settings as you click the mouse. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
   FillColor = QBColor(Int(Rnd * 15))   ' Choose random FillColor.
   FillStyle = Int(Rnd * 8)   ' Choose random FillStyle.
   Circle (X, Y), 250   ' Draw a circle.
End Sub


FillStyle Property

Returns or sets the pattern used to fill Shape controls as well as circles and boxes created with the Circle and Line graphics methods.

Syntax

object.FillStyle [= number]

The FillStyle property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | An integer that specifies the fill style, as described in Settings.

Settings

The number settings are:

Constant | Setting | Description
VbFSSolid | 0 | Solid
VbFSTransparent | 1 | (Default) Transparent
VbHorizontalLine | 2 | Horizontal Line
VbVerticalLine | 3 | Vertical Line
VbUpwardDiagonal | 4 | Upward Diagonal
VbDownwardDiagonal | 5 | Downward Diagonal
VbCross | 6 | Cross
VbDiagonalCross | 7 | Diagonal Cross

Remarks

When FillStyle is set to 1 (Transparent), the FillColor property is ignored, except for the Form object.


FillStyle Property Example

This example displays a circle on a form with random FillColor and FillStyle property settings as you click the mouse. To try this example, paste the code into the Declarations section, and then press F5 to run the program.

Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
   FillColor = QBColor(Rnd * 15)   ' Choose random FillColor.
   FillStyle = Int(Rnd * 8)   ' Choose random FillStyle.
   Circle (X, Y), 250   ' Draw a circle.
End Sub


FirstApp (FirstApp.vbp)

This sample application demonstrates the usage of the Data Control with other data aware controls. It provides a simple introduction to assigning properties at run-time.

Background

The sample is comprised of a single form with a DataGrid control connected to a Data control. For more information, see "Developing an Application in Visual Basic," in the Programmer's Guide.

File | Description
Form1.frx | Binary data for Form1.frm
Form1.frm | Form for the application
Firstapp.vbp | The project file for the application.

To Run

From the Visual Basic File menu, choose Open Project and select the Firstapp.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


FirstDayOfWeek Property

Sets or returns the day considered the first day of the week. Read/write both at design time and run time.

Syntax

object.FirstDayOfWeek [= value]

The FirstDayOfWeek property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | Optional enumerated Integer. A value that determines the day considered the first day of the week, as described in Settings.

Settings

The settings for value are:

Constant | Setting | Description
fmtDayUseSystem | 0 | Use NLS API setting.
fmtSunday | 1 | Sunday. This is the default value.
fmtMonday | 2 | Monday
fmtTuesday | 3 | Tuesday
fmtWednesday | 4 | Wednesday
fmtThursday | 5 | Thursday
fmtFriday | 6 | Friday
fmtSaturday | 7 | Saturday

Remarks

This property is only used when formatting dates. For faster performance set this property before binding.


FirstWeekOfYear Property

Sets or returns the week considered the first week of the year. Read/write both at design time and run time.

Syntax

object.FirstWeekOfYear [= value]

The FirstWeekOfYear property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | Optional enumerated Integer. A value that determines the week considered the first week of the year, as described in Settings.

Settings

The settings for value are:

Constant | Setting | Description
fmtWeekUseSystem | 0 | Use NLS API setting.
fmtFirstJan1 | 1 | The week containing January 1. This is the default value.
fmtFirstFourDays | 2 | The first week of the year containing at least four days.
fmtFirstFullWeek | 3 | The first full week of the year.

Remarks

This property is only used when formatting dates.


Font Property

Returns a Font object.

Syntax

object.Font

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use the Font property of an object to identify a specific Font object whose properties you want to use. For example, the following code changes the Bold property setting of a Font object identified by the Font property of a TextBox object:

txtFirstName.Font.Bold = True


FontBold, FontItalic, FontStrikethru, FontUnderline Properties

Return or set font styles in the following formats: Bold, Italic, Strikethru, and Underline.

Note The FontBold, FontItalic, FontStrikethru, and FontUnderline properties are included for use with the CommonDialog control and for compatibility with earlier versions of Visual Basic. For additional functionality, use the new Font object properties (not available for the CommonDialog control).

Syntax

object.FontBold [= boolean]

object.FontItalic [= boolean]

object.FontStrikethru [= boolean]

object.FontUnderline [= boolean]

The FontBold, FontItalic, FontStrikethru, and FontUnderline property syntaxes have these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying the font style as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default for FontBold, except with the CommonDialog control) Turns on the formatting in that style.
False | (Default for FontItalic, FontStrikethru, and FontUnderline, and FontBold with the CommonDialog control) Turns off the formatting in that style.

Remarks

Use these font properties to format text, either at design time using the Properties window or at run time using code. For PictureBox controls and Form and Printer objects, setting these properties doesn't affect graphics or text already drawn on the control or object. For all other controls, font changes take effect on screen immediately.

To use these properties with the CommonDialog control, the Effects flag must be set.

Note Fonts available in Visual Basic vary depending on your system configuration, display devices, and printing devices. Font-related properties can be set only to values for which actual fonts exist.

In general, you should change the FontName property before you set size and style attributes with the FontSize, FontBold, FontItalic, FontStrikethru, and FontUnderline properties. However, when you set TrueType fonts to smaller than 8 points, you should set the point size with the FontSize property, then set the FontName property, and then set the size again with the FontSize property. The Microsoft Windows operating environment uses a different font for TrueType fonts that are smaller than 8 points.


FontBold, FontItalic, FontStrikethru, FontUnderline Properties Example

This example puts text on a form in one of two combinations of styles with each mouse click. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   FontStrikethru = Not FontStrikethru   ' Toggle strikethrough.
   FontItalic = Not FontItalic   ' Toggle font style.
   Print "Now is the time!"   ' Print some text.
End Sub


FontCount Property

Returns the number of fonts available for the current display device or active printer.

Syntax

object.FontCount

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use this property with the Fonts property to see a list of available screen or printer fonts. Fonts available in Visual Basic vary according to your system configuration, display devices, and printing devices.


FontCount Property Example

This example prints a list of the printer fonts in a ListBox control. To try this example, paste the code into the Declarations section of a form that has a ListBox control named List1, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim I   ' Declare variable.
   For I = 0 To Printer.FontCount -1   ' Determine number of fonts.
      List1.AddItem Printer.Fonts (I)   ' Put each font into list box.
   Next I
End Sub


FontName Property

Returns or sets the font used to display text in a control or in a run-time drawing or printing operation.

Note The FontName property is included for use with the CommonDialog control and for compatibility with earlier versions of Visual Basic. For additional functionality, use the new Font object properties (not available for the CommonDialog control).

Syntax

object.FontName [= font]

The FontName property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
font | A string expression specifying the font name to use.

Remarks

The default for this property is determined by the system. Fonts available with Visual Basic vary depending on your system configuration, display devices, and printing devices. Font-related properties can be set only to values for which fonts exist.

In general, you should change FontName before setting size and style attributes with the FontSize, FontBold, FontItalic, FontStrikethru, and FontUnderline properties.

Note At run time, you can get information on fonts available to the system through the FontCount and Fonts properties.


FontName Property Example

This example prints the name of each font using the particular font. To try this example, paste the code into the Declarations section of a form. Press F5 to run the program, and then click the form. Each time you click the form, the font name is printed.

Private Sub Form_Click ()
   Static I   ' Declare variables.
   Dim OldFont
   OldFont = FontName   ' Preserve original font.
   FontName = Screen.Fonts(I)   ' Change to new font.
   Print Screen.Fonts(I)   ' Print name of font.
   I = I + 1   ' Increment counter.
   If I = FontCount Then I = 0   ' Start over.
   FontName = OldFont   ' Restore original font.
End Sub


Fonts Property

Returns all font names available for the current display device or active printer.

Syntax

object.Fonts(index)

The Fonts property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Index | An integer from 0 to FontCount –1.

Remarks

The Fonts property works in conjunction with the FontCount property, which returns the number of font names available for the object. Fonts available in Visual Basic vary according to your system configuration, display devices, and printing devices. Use both the Fonts and the FontCount properties to get information about available screen or printer fonts.


FontSize Property

Returns or sets the size of the font to be used for text displayed in a control or in a run-time drawing or printing operation.

Note The FontSize property is included for use with the CommonDialog control and for compatibility with earlier versions of Visual Basic. For additional functionality, use the new Font object properties (not available for the CommonDialog control).

Syntax

object.FontSize [= points]

The FontSize property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
points | A numeric expression specifying the font size to use, in points.

Remarks

Use this property to format text in the font size you want. The default is determined by the system. To change the default, specify the size of the font in points.

The maximum value for FontSize is 2160 points.

Note Fonts available with Visual Basic vary depending on your system configuration, display devices, and printing devices. Font-related properties can be set only to values for which fonts exist.

In general, you should change the FontName property before you set size and style attributes with the FontSize, FontBold, FontItalic, FontStrikethru, and FontUnderline properties. However, when you set TrueType fonts to smaller than 8 points, you should set the point size with the FontSize property, then set the FontName property, and then set the size again with the FontSize property. The Microsoft Windows operating environment uses a different font for TrueType fonts that are smaller than 8 points.


FontSize Property Example

This example prints text on your form in two different point sizes with each click of the mouse. To try this example, paste the code into the Declarations section of a form. Press F5 to run the program, and then click the form.

Private Sub Form_Click ()
   FontSize = 24   ' Set FontSize.
   Print "This is 24-point type."   ' Print large type.
   FontSize = 8   ' Set FontSize.
   Print "This is 8-point type."   ' Print small type.
End Sub


Fonts Property Example

This example prints a list of the printer fonts in a ListBox control. To try this example, paste the code into the Declarations section of a form that has a ListBox control named List1. Press F5 to run the program, and then click the form.

Private Sub Form_Click ()
   Dim I   ' Declare variable.
   For I = 0 To Printer.FontCount -1   ' Determine number of fonts.
      List1.AddItem Printer.Fonts (I)   ' Put each font into list box.
   Next I
End Sub


FontTransparent Property

Returns or sets a value that determines whether background text and graphics on a Form or Printer object or a PictureBox control are displayed in the spaces around characters.

Syntax

object.FontTransparent [= boolean]

The FontTransparent property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying the state of background text and graphics, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default) Permits background graphics and text to show around the spaces of the characters in a font.
False | Masks existing background graphics and text around the characters of a font.

Remarks

Set FontTransparent at design time using the Properties window or at run time using code. Changing FontTransparent at run time doesn't affect graphics and text already drawn to Form, Printer, or PictureBox.


FontTransparent Property Example

This example prints text on top of a graphic in a PictureBox control. Put a PictureBox on a form, set its AutoSize property to True, and load its Picture property with a bitmap (.bmp) file. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form twice.

Private Sub Form_Click ()
   ' Toggle property.
   Picture1.FontTransparent = Not Picture1.FontTransparent
 Picture1.Print "Demo of FontTransparent property."
End Sub


ForcePageBreak Property

Returns or sets a value that determines how a page break will occur.

Syntax

object.ForcePageBreak [=integer]

The ForcePageBreak property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
integer | Optional. A numeric expression that specifies how the page break occurs, as shown in Settings.

Settings

The settings for integer are:

Constant | Value | Description
rptPageBreakNone | 0 | (Default) No page breaks occur.
rptPageBreakBefore | 1 | The page break occurs before the current section.
rptPageBreakAfter | 2 | The page break occurs after the current section.
rptPageBreakBeforeAndAfter | 3 | Page breaks occur both before and after the current section.

Remarks

Page breaks do not occur on every section consistently. The table below shows exceptions, according to sections.

Section | Ignores
Report Header | rptPageBreakBefore
Page Header | rptPageBreakBefore rptPageBreakAfter rptPageBreakBeforeAndAfter
Page Footer | rptPageBreakBefore rptPageBreakAfter rptPageBreakBeforeAndAfter


Format Property (OLE Container Control)

Returns or sets the format when sending data to and getting data from an application that created an object. Not available at design time.

Syntax

object.Format [ = format]

The Format property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Format | A string expression specifying the format used with the Data and DataText properties.

Remarks

Use the ObjectAcceptFormats, ObjectAcceptFormatsCount, ObjectGetFormats, and ObjectGetFormatsCount properties to get a list of the acceptable data formats for a specific class of object.

Many applications that provide objects support only one or two formats. For example, Microsoft Draw accepts only the CF_METAFILEPICT format. Although CF_METAFILEPICT resembles the intrinsic constant vbCFMetafile (numeric value 3) defined in the Visual Basic (VB) object library in the Object Browser, it's actually a string literal and is assigned as:

Ole1.Format = "CF_METAFILEPICT"

In many cases, the list of formats an object can accept (ObjectAcceptFormats) is different from the list of formats an object can provide (ObjectGetFormats).


Format Property (StdDataFormat Object)

Sets or returns a format string. Read/write both at design time and run time.

Syntax

object.Format = formatstring

The Format property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
formatstring | Required. A string specifying the desired format. The Format property supports the same set of format expressions as the Format function.

Remarks

If you use complex format strings you will need to unformat the data yourself.

The formatting process occurs before the Format event. The unformatting process is handled by the database and occurs after the Unformat event.


FormatType Property

Returns or sets the type of format to use when exporting a report.

Syntax

object.FormatType [= integer]

The FormatType property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
integer | Optional. A numeric expression that specifies the format type, as shown in Settings.

Settings

The settings for integer are:

Constant | Value | Description
rptFmtHTML | 0 | HTML
rptFmtText | 1 | Tex
rptFmtUnicodeText | 2 | Unicode
rptFmtUnicodeHTML_UTF8 | 3 | HTML encoded in Universal Character Set (UTF - 8)


Forms Property

Returns a Forms collection, which is a collection whose elements represent each loaded form in an application. The collection includes the application's MDI form, MDI child forms, and non-MDI forms. The Forms collection has a single property, Count, that specifies the number of elements in the collection.

Syntax

Forms(index)

The placeholder index represents an integer with a range from 0 to Forms.Count - 1.

Remarks

You can use the Forms collection to iterate through all loaded forms in an application. It identifies an intrinsic global variable named Forms. You can pass Forms(index) to a function whose argument is specified as a Forms class.


ForwardFocus Property

Returns or sets a value determining which control receives focus when one of the access keys for the control is pressed. The ForwardFocus property is read/write at the control’s authoring time, and not available at the control’s run time.

Settings

The settings for ForwardFocus are:

Setting | Description
True | The next control in tab order will receive focus when one of the access keys for the control is pressed.
False | (Default) If the CanGetFocus property is true, the control itself will receive focus when one of the access keys for the control is pressed.

Remarks

The ForwardFocus property allows the control to implement the behavior of a Label control that has an access key.

Access keys are set through the AccessKeys property. When an access key in conjunction with the ALT key is pressed, the control’s AccessKeyPress event is raised.


Function Property

Returns or sets the function to use for the DEAggregate object.

Syntax

object.Function [=value]

The Function property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies the function to use, as described in Settings.

Settings

The settings for value are:

Constant | Description
deAny | Any. Returns the default operation of the selection.
deAverage | Average. Obtains the average of the values in the selection.
deCnt | Count. Returns the count of the number of records in the selection.
deMax | Maximum. Returns the highest value of the selection.
deMin | Minimum. Returns the lowest value of the selection.
deSDev | Standard Deviation. Returns the standard deviation of the selection.
deSum | Sum. (Default) Returns the sum of all the values in the selection.


FunctionType Property

Returns or sets the function to be used in calculating the value displayed by the Function control.

Syntax

object.FunctionType [=integer]

The FunctionType property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
integer | Optional. A numeric expression that specifies the function, as shown in Settings.

Settings

The settings for integer are:

Constant | Value | Description
rptFuncSum | 0 | (Default) Sums the values of the DataField.
rptFuncAve | 1 | Averages the values of the DataField.
rptFuncMin | 2 | Returns the minimum value of the DataField.
rptFuncMax | 3 | Returns the maximum value of the DataField.
rptFuncRCnt | 4 | Counts the rows in the section.
rptFuncVCnt | 5 | Counts the fields with non-null values.
rptFuncSDEV | 6 | Calculates the standard deviation.
rptFuncSERR | 7 | Calculates the standard error.


GeoFacts (GeoFacts.vbp)

The GeoFacts sample application demonstrates how to work with objects provided by other applications. In this case, the objects are provided by Microsoft Excel using the GetObject function. Using the reference returned by the function, two ComboBox controls and a ListBox control are dynamically filled with data from an Excel spreadsheet.

File | Description
World.xls | Excel spreadsheet that supplies data for the application.
Geofacts.frm | Form for the application.
Geofacts.bas | Code module containing procedures for the application.
Geofacts.vbp | The project file for the application.

To Run

From the Visual Basic File menu, choose Open Project and select the GeoFacts.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


GrandTotalName Property

Specifies the name used for a grand total Recordset when the DECommand object has an associated grand total DEAggregate object defined.

Syntax

object.GrandTotalName [=string]

The GrandTotalName property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the name for the Grand Total Recordset.


GridLineWidth Property

Returns or sets the width in pixels of the gridlines for an MSFlexGrid control.

Syntax

object.GridLineWidth [= value]

The GridLineWidth property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | An integer specifying the gridline width. The minimum setting is 1 (default); the maximum setting is 10.


GridX, GridY Properties

Specifies the divisions of the alignment grid at design time (ignored at run time).

Syntax

object.GridX

object.GridY

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The GridX and GridY properties are used only at design time as an aid in aligning controls on the DataReport object.


GroupCommand Property

Specifies whether a DECommand object is grouped.

Syntax

object.GroupCommand [=Boolean]

The GroupCommand property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that defines whether the DECommand object is grouped. The default is False, or ungrouped.

Remarks

This property is used when you define a group-based hierarchy. If set to True, the DECommand object is grouped. Use the DEGroupingFields collection to define the Field objects by which the DECommand object is grouped.


Handle Property

Returns a handle to the graphic contained within a Picture object.

Syntax

object.Handle

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Value

The value returned by the Handle property depends on the current setting of the Type property as shown in the following table:

Type Property | Return Value
1 (Bitmap) | An HBITMAP handle.
2 (Metafile) | An HMETAFILE handle.
3 (Icon) | An HICON or an HCURSOR handle.
4 (Enhanced Metafile) | An HENHMETAFILE handle.

Remarks

The Handle property is useful when you need to pass a handle to a graphic as part of a call to a function in a dynamic-link library (DLL) or the Windows API.


hDC Property

Returns a handle provided by the Microsoft Windows operating environment to the device context of an object.

Syntax

object.hDC

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

This property is a Windows operating environment device context handle. The Windows operating environment manages the system display by assigning a device context for the Printer object and for each form and PictureBox control in your application. You can use the hDC property to refer to the handle for an object's device context. This provides a value to pass to Windows API calls.

With a CommonDialog control, this property returns a device context for the printer selected in the Print dialog box when the cdlReturnDC flag is set or an information context when the cdlReturnIC flag is set.

Note The value of the hDC property can change while a program is running, so don't store the value in a variable; instead, use the hDC property each time you need it.

The AutoRedraw property can cause the hDC property setting to change. If AutoRedraw is set to True for a form or PictureBox container, hDC acts as a handle to the device context of the persistent graphic (equivalent to the Image property). When AutoRedraw is False, hDC is the actual hDC value of the Form window or the PictureBox container. The hDC property setting may change while the program is running regardless of the AutoRedraw setting.

If the HasDC property is set to False, a new device context will be created by the system and the value of the hDC property will change each time it is called.


hDC Property Example

This example draws a triangle and then uses a Microsoft Windows function to fill it with color. To try this example, create a new module using the Add Module command on the Project menu. Paste the Declare statement into the Declarations section of the new module, being sure that the statement is on one line with no break or wordwrap. Then paste the Sub procedure into the Declarations section of a form. Press F5 and click the form.

' Declaration of a Windows routine. This statement is
' for the module.
Declare Sub FloodFill Lib "GDI32" Alias "FloodFill" _
 (ByVal hDC As Long, ByVal X As Long, ByVal Y As _
 Long, ByVal crColor As Long) As Long
' Place the following code in the form.
Private Sub Form_Click ()
   ScaleMode = vbPixels     ' Windows draws in pixels.
   ForeColor = vbBlack     ' Set draw line to black.
   Line (100, 50)-(300, 50) ' Draw a triangle.
   Line -(200, 200)
   Line -(100, 50)
   FillStyle = vbFSSolid  ' Set FillStyle to solid.
   FillColor = RGB(128, 128, 255)   ' Set FillColor.
 ' Call Windows API to fill.
   FloodFill hDC, 200, 100, ForeColor
End Sub


Height, Width Properties

Return or set the dimensions of an object or the width of the Columns object of a DataGrid control. For the Printer and Screen objects, not available at design time.

Syntax

object.Height [= number]

object.Width [= number]

The Height and Width property syntaxes have these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression specifying the dimensions of an object, as described in Settings.

Settings

Measurements are calculated as follows:

  • Form — the external height and width of the form, including the borders and title bar.

  • Control — measured from the center of the control's border so that controls with different border widths align correctly. These properties use the scale units of a control's container.

  • Printer object — the physical dimensions of the paper set up for the printing device; not available at design time. If set at run time, values in these properties are used instead of the setting of the PaperSize property.

  • Screen object — the height and width of the screen; not available at design time and read-only at run time.

  • Picture object — the height and width of the picture in HiMetric units.

Remarks

For Form, Printer, and Screen objects, these properties are always measured in twips. For a form or control, the values for these properties change as the object is sized by the user or by your code. Maximum limits of these properties for all objects are system-dependent.

If you set the Height and Width properties for a printer driver that doesn't allow these properties to be set, no error occurs and the size of the paper remains as it was. If you set Height and Width for a printer driver that allows only certain values to be specified, no error occurs and the property is set to whatever the driver allows. For example, you could set Height to 150 and the driver would set it to 144.

Use the Height, Width, Left, and Top properties for operations or calculations based on an object's total area, such as sizing or moving the object. Use the ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth properties for operations or calculations based on an object's internal area, such as drawing or moving objects within another object.

Note The Height property can't be changed for the DriveListBox control or for the ComboBox control, whose Style property setting is 0 (Dropdown Combo) or 2 (Dropdown List).

For the Columns object of the DataGrid control, Width is specified in the unit of measure of the object that contains the DataGrid. The default value for Width is the value of the DefColWidth property of DataGrid.

For the Picture object, use the ScaleX and ScaleY methods to convert HiMetric units into the scale you need.


Height, Width Properties Example

This example sets the size of a form to 75 percent of screen size and centers the form when it is loaded. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.

Private Sub Form_Click ()
   Width = Screen.Width * .75   ' Set width of form.
   Height = Screen.Height * .75   ' Set height of form.
   Left = (Screen.Width - Width) / 2   ' Center form horizontally.
   Top = (Screen.Height - Height) / 2   ' Center form vertically.
End Sub


HelpContextID Property

Returns or sets an associated context number for an object. Used to provide context-sensitive Help for your application.

Syntax

object.HelpContextID [= number]

The HelpContextID property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list. If object is omitted, the form associated with the active form module is assumed to be object.
number | A numeric expression that specifies the context number of the Help topic associated with object.

Settings

The settings for number are:

Setting | Description
0 | (Default) No context number specified.
> 0 | An integer specifying a valid context number.

Remarks

For context-sensitive Help on an object in your application, you must assign the same context number to both object and to the associated Help topic when you compile your Help file.

If you've created a Microsoft Windows operating environment Help file for your application and set the application's HelpFile property, when a user presses the F1 key, Visual Basic automatically calls Help and searches for the topic identified by the current context number.

The current context number is the value of HelpContextID for the object that has the focus. If HelpContextID is set to 0, then Visual Basic looks in the HelpContextID of the object's container, and then that object's container, and so on. If a nonzero current context number can't be found, the F1 key is ignored.

For a Menu control, HelpContextID is normally read/write at run time. But HelpContextID is read-only for menu items that are exposed or supplied by Visual Basic to add-ins, such as the Add-In Manager command on the Add-Ins menu.


HelpContextID Property Example

This example uses topics in the Visual Basic Help file to demonstrate how to specify context numbers for Help topics. To try this example, paste the code into the Declarations section of a form that contains a TextBox control and a Frame control with an OptionButton control inside of it. Press F5. Once the program is running, move the focus to one of the controls, and press F1.

' Actual context numbers from the Visual Basic Help file.
Const winColorPalette = 21004   ' Define constants.
Const winToolbox = 21001
Const winCodeWindow = 21005

Private Sub Form_Load ()
   App.HelpFile = "VB.HLP"
   Frame1.HelpContextID = winColorPalette
   Text1.HelpContextID = winToolbox
   Form1.HelpContextID = winCodeWindow
End Sub


HelpFile Property (App, CommonDialog, MenuLine)

Specifies the path and filename of a Help file used by your application to display Help or online documentation.

Syntax

object.HelpFile[ = filename]

The HelpFile property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
filename | A string expression specifying the path and filename of the help file for your application.

Remarks

If you've created a Help file for your application and set the application's HelpFile property, Visual Basic automatically calls Help when a user presses the F1 key. If there is a context number in the HelpContextID property for either the active control or the active form, Help displays a topic corresponding to the current Help context; otherwise it displays the main contents screen.

You can also use the HelpFile property to determine which Help file is displayed when a user requests Help from the Object Browser for an ActiveX component.


HelpFile Property Example

This example uses topics in the Visual Basic Help file and demonstrates how to specify context numbers for Help topics. To try this example, paste the code into the Declarations section of a Form object that contains a TextBox control and a Frame control with an OptionButton control inside of it. Run the example. Once the program is running, move the focus to one of the components, and press F1.

' Actual context numbers from the Visual Basic Help file.
' Define constants.
Const winPictureBox = 2016002
Const winCommandButton = 2007557

Private Sub Form_Load ()
   App.HelpFile = "VB98.CHM"
   Text1.HelpContextID = winPictureBox
   Form1.HelpContextID = winCommandButton
End Sub


Hidden Property

Returns or sets the Hidden attribute of a Member object.

Syntax

object.Hidden

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


HideSelection Property

Returns a value that determines whether selected text appears highlighted when a control loses the focus.

Syntax

object.HideSelection

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Values

The HideSelection property return values are:

Value | Description
True | (Default) Selected text doesn't appear highlighted when the control loses the focus.
False | Selected text appears highlighted when the control loses the focus.

Remarks

You can use this property to indicate which text is highlighted while another form or a dialog box has the focus — for example, in a spell-checking routine.


HideSelection Property Example

This example enables you to select text in each form and switch the focus between forms by clicking each form's title bar. The selection remains visible even when the form isn't active. To try the example, create two forms and draw a TextBox control on each. Set the MultiLine property to True for both TextBox controls, and set the HideSelection property to False for one of the TextBox controls. Paste the code into the Declarations section of both form modules, and then press F5.

Private Sub Form_Load ()
   Open "README.TXT" For Input As 1   ' Load file into text box.
   Text1.Text = Input$(LOF(1), 1)
   Close 1
   Form2.Visible = True   ' Load Form2, if not already loaded.
   ' Position forms side by side.
   Form1.Move 0, 1050, Screen.Width / 2, Screen.Height
   Form2.Move Screen.Width / 2, 1050, Screen.Width / 2, Screen.Height
   ' Enlarge text box to fill form.
   Text1.Move 0, 0, ScaleWidth, ScaleHeight
End Sub


hInstance Property

Returns a handle to the instance of the application.

Syntax

object.hInstance

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The hInstance property returns a Long data type.

When working with a project in the Visual Basic development environment, the hInstance property returns the instance handle of the Visual Basic instance.


HitBehavior Property

Returns or sets a value that defines the hit testing behavior of the HitTest event on a Windowless UserControl object.

Syntax

object.HitBehavior [= number]

The HitBehavior property syntax has these parts:

Part | Description
object | A UserControl object.
number | An integer that specifies hit testing behavior, as described in Settings.

Settings

The settings for number are:

Constant | Setting | Description
None | 0 | The HitTest event will always return a HitResult of 0 (vbHitResultOutside).
UseRegion | 1 | (Default) The HitTest event will return a HitResult of 3 (vbHitResultHit) when the cursor is over the MaskRegion of your control.
UsePaint | 2 | The HitTest event will return a HitResult of 3 (vbHitResultHit) when the cursor is over any painted area of the control.

Remarks

You can use the HitBehavior property to determine where hits will occur on your UserControl. By default, only the MaskRegion of the control will return a hit in the HitTest event. The MaskRegion consists of any subcontrols plus any mask defined by the MaskPicture and MaskColor properties. Any areas outside of the MaskRegion will return a HitResult of 0.

By setting HitBehavior to None, the HitTest event will never return a hit. When the HitBehavior is set to UsePaint, the mask region plus the areas painted by graphics methods will return a hit.

When used in combination with the ClipBehavior property, this property helps to determine the HitResult argument of the HitTest event.

Note This property is ignored if the Windowless property of the UserControl object is set to False or if the BackStyle property is set to Opaque.

Important Not all control containers support the Windowless property. The HitBehavior property should only be changed if you know it will be used in containers that support Windowless activation.


HostDataType Property

Returns or sets the data type to which the DEParameter object is converted.

Syntax

object.HostDataType [=value]

The HostDataType property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies the host data type. See Visual Basic's data types for information.


HostName Property

Returns or sets the user-readable host name of your Visual Basic application.

Syntax

object.HostName [ = name]

The HostName property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
name | A string expression specifying the host name.

Remarks

When editing an object, the HostName property setting may be displayed in the object's window title. However, some applications that provide objects don't display HostName.


hPal Property

Returns or sets a handle to the palette of a picture in a Picture object.

Syntax

object.hPal [= value]

The hPal property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | The handle to the palette for the picture (HPAL).

Remarks

The hPal property is useful when you need to pass a handle to a palette as part of a call to a function in a dynamic-link library (DLL) or the Windows API.


HScrollSmallChange, VScrollSmallChange Properties

Returns or sets the distance the UserDocument will scroll when the user clicks a scroll arrow.

Syntax

object.HScrollSmallChange = single

object.VScrollSmallChange = single

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
single | The distance in twips the UserDocument will scroll when the user clicks the scroll arrow.

Remarks

There is no “LargeChange” property counterpart to the HScrollSmallChange and VScrollSmallChange properties. The “LargeChange” is determined by the ViewPort object’s ViewPortHeight and ViewPortWidth properties.


hWnd Property

Returns a handle to a form or control.

Note This property is not supported for the OLE container control.

Syntax

object.hWnd

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The Microsoft Windows operating environment identifies each form and control in an application by assigning it a handle, or hWnd. The hWnd property is used with Windows API calls. Many Windows operating environment functions require the hWnd of the active window as an argument.

Note Because the value of this property can change while a program is running, never store the hWnd value in a variable.

If the Windowless property of a User Control is set to True, the hWnd property will return 0.


hWnd Property Example

This example forces a form to always remain on top. To try this example, create a form (not an MDI child form), and then create a menu for the form called Main. Insert a submenu in it called Always On Top, and set its Name to mnuTopmost. Create a new module using the Add Module command on the Project menu. Paste the Declare statement into the Declarations section of the new module, being sure that the statement is on one line with no break or wordwrap. Then paste the Sub procedure into the Declarations section of the form and press F5.

' Declaration of a Windows routine.
' This statement should be placed in the module.
Declare Function SetWindowPos Lib "user32" Alias_ "SetWindowPos" (ByVal hwnd As Long, ByVal_ hWndInsertAfter As Long, ByVal x As Long, ByVal y As_ Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags_ As Long) As Long

' Set some constant values (from WIN32API.TXT).
Const conHwndTopmost = -1
Const conHwndNoTopmost = -2
Const conSwpNoActivate = &H10
Const conSwpShowWindow = &H40

Private Sub mnuTopmost_Click ()
   ' Add or remove the check mark from the menu.
   mnuTopmost.Checked = Not mnuTopmost.Checked
   If mnuTopmost.Checked Then
      ' Turn on the TopMost attribute.
      SetWindowPos hWnd, conHwndTopmost, 0, 0, 0, 0,_ conSwpNoActivate Or conSwpShowWindow
   Else
      ' Turn off the TopMost attribute.
      SetWindowPos hWnd, conHwndNoTopmost, 0, 0, 0,_ 0, conSwpNoActivate Or conSwpShowWindow
   End If
End Sub

This example automatically drops down the list portion of a ComboBox control whenever the ComboBox receives the focus. To try this example, create a new form containing a ComboBox control and an OptionButton control (used only to receive the focus). Create a new module using the Add Module command on the Project menu. Paste the Declare statement into the Declarations section of the new module, being sure that the statement is on one line with no break or wordwrap. Then paste the Sub procedure into the Declarations section of the form, and press F5. Use the TAB key to move the focus to and from the ComboBox.

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long

Private Sub Combo1_GotFocus ()
   Const CB_SHOWDROPDOWN = &H14F
   Dim Tmp
   Tmp = SendMessage(Combo1.hWnd, CB_SHOWDROPDOWN, 1, ByVal 0&)
End Sub


Hyperlink Property

Returns a reference to the Hyperlink object.

Syntax

object.Hyperlink

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


Icon Property

Returns the icon displayed when a form is minimized at run time.

Syntax

object.Icon

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use this property to specify an icon for any form that the user can minimize at run time.

For example, you can assign a unique icon to a form to indicate the form's function. Specify the icon by loading it using the Properties window at design time. The file you load must have the .ico filename extension and format. If you don't specify an icon, the Visual Basic default icon for forms is used.

You can use the Visual Basic Icon Library (in the Icons subdirectory) as a source for icons. When you create an executable file, you can assign an icon to the application by using the Icon property of any form in that application.

Note You can see a form's icon in Windows 95 in the upper left corner of the form, or when the form is minimized in both Windows 95 and Windows NT. If the form is minimized, the BorderStyle property must be set to either 1 (Fixed Single) or 2 (Sizable) and the MinButton property must be set to True for the icon to be visible.

At run time, you can assign an object's Icon property to another object's DragIcon or Icon property. You can also assign an icon returned by the LoadPicture function. Using LoadPicture without an argument assigns an empty (null) icon to the form, which enables you to draw on the icon at run time.


Icon Property Example

This example creates a blank icon for a form and draws colored dots on the icon as long as the form is minimized. To try this example, paste the code into the Declarations section of a form, and then press F5 and minimize the form.

Note This example works only with Windows NT 3.5x.

Private Sub Form_Resize ()
   Dim X, Y   ' Declare variables.
   If Form1.WindowState = vbMinimized Then
      Form1.Icon = LoadPicture()   ' Load a blank icon.
      Do While Form1.WindowState = vbMinimized
  ' While form is minimized,
         Form1.DrawWidth = 10   ' set size of dot.
         ' Choose random color for dot.
         Form1.ForeColor = QBColor(Int(Rnd * 15))
         ' Set random location on icon.
         X = Form1.Width * Rnd
         Y = Form1.Height * Rnd
         PSet (X, Y)   ' Draw dot on icon.
         DoEvents   ' Allow other events.
      Loop
   End If
End Sub

This is the same example, except that it uses the LoadPicture method to set the Icon property. This example works with all versions of Windows:

Private Sub Form_Resize ()
   Dim X, Y   ' Declare variables.
   If Form1.WindowState = vbMinimized Then
      Form1.Icon = LoadPicture("c:\myicon.ico")
  ' An icon named "myicon.ico" must be in the
  ' c:\ directory for this example to work
  ' correctly.
   End If
End Sub


Image Property

Returns a handle to a persistent graphic; the handle is provided by the Microsoft Windows operating environment.

Syntax

object.Image

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

An object's AutoRedraw property determines whether the repainting of an object occurs with a persistent graphics or through Paint events. The Windows operating environment identifies an object's persistent graphic by assigning a handle to it; you can use the Image property to get this handle.

An Image value exists regardless of the setting for the AutoRedraw property. If AutoRedraw is True and nothing has been drawn, the image displays only the color set by the BackColor property and the picture.

You can assign the value of Image to the Picture property. The Image property also provides a value to pass to Windows API calls.

The Image, DragIcon, and Picture properties are normally used when assigning values to other properties, when saving with the SavePicture statement, or when placing something on the Clipboard. You can't assign these to a temporary variable, other than the Picture data type.

The AutoRedraw property can cause Image, which is a handle to a bitmap, to change. When AutoRedraw is True, an object's hDC property becomes a handle to a device context that contains the bitmap returned by Image.


Image Property Example

This example draws a circle in the first PictureBox control each time you click it. When you click the second PictureBox, the graphic from the first PictureBox is copied into it. To try this example, paste the code into the Declarations section of a form that has two large, equal-sized PictureBox controls. Press F5 to run the program, and then click the PictureBox controls.

Private Sub Form_Load ()
   ' Set AutoRedraw to True.
   Picture1.AutoReDraw = True
End Sub

Private Sub Picture1_Click ()
 ' Declare variables.
   Dim PW, PH
 ' Set FillStyle to Solid.
   Picture1.FillStyle = vbFSSolid
 ' Choose random color.
   Picture1.FillColor = QBColor(Int(Rnd * 15))
   PW = Picture1.ScaleWidth   ' Set ScaleWidth.
   PH = Picture1.ScaleHeight   ' Set ScaleHeight.
   ' Draw a circle in random location.
   Picture1.Circle (Int(Rnd * PW), Int(Rnd * PH)), 250
End Sub

Private Sub Picture2_Click ()
 ' Copy Image to Picture2.
   Picture2.Picture = Picture1.Image
End Sub


IMEMode Property

Returns or sets a value that determines the IME (Input Method Editor) status of the object when that object is selected.

Note This property applies only to Far East versions of Visual Basic.

object.IMEMode [= value]

The IMEMode property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | An Integer that specifies the IME mode to be used by the object.

Settings

The settings for value are:

Setting | Description
0 | None (Default). This value indicates "No control to IME". When the IMEMode property is set to 0, you can use the IMEStatus function to determine the current IME status.
1 | IME on. This value indicates that the IME is on and characters specific to Chinese or Japanese can be entered. This setting is valid for Japanese, Simplified Chinese, and Traditional Chinese IME only.
2 | IME off. This mode indicates that the IME is off, meaning that the object behaves the same as English entry mode. This setting is valid for Japanese, Simplified Chinese, and Traditional Chinese IME only.
3 | IME disabled. This mode is similar to IMEMode = 2, except the value 2 disables IME. With this setting, the users cannot turn the IME on from the keyboard, and the IME floating window is hidden. This setting is valid for Japanese IME only.
4 | Hiragana double-byte characters (DBC). These settings are valid for Japanese IME only.
5 | Katakana DBC. These settings are valid for Japanese IME only.
6 | Katakana single-byte characters (SBC). These settings are valid for Japanese IME only.
7 | Alphanumeric DBC. These settings are valid for Japanese IME only.
8 | Alphanumeric SBC. These settings are valid for Japanese IME only.
9 | Hangeul DBC. These settings are valid for Korean IME only.
10 | Hangeul SBC. These settings are valid for Korean IME only.

Remarks

At design time, you can set the IMEMode property of an object using the Properties window. At run time, you can return or set the IMEMode property through code. If you change the setting of the IMEMode property while the object has the focus, the IME status of the object changes accordingly. If you set the IMEMode property to 0 (None), it always returns 0 regardless of the object's current IME status. If you set this property to any valid setting other than 0, the IMEMode property returns the current IME status.

With Japanese IME, you can use the settings 0 to 8 only. The settings 9 and 10 are invalid on Japanese systems.

With Korean IME, you can use the settings 0 and 7 to 10 only. Settings 1 to 6 are invalid on Korean systems.

With Simplified Chinese and Traditional Chinese IME, you can use settings 0 to 2 only. Settings 3 to 10 are invalid on Chinese systems.


Index Property (Control Array)

Returns or sets the number that uniquely identifies a control in a control array. Available only if the control is part of a control array.

Syntax

object[(number)].Index

The Index property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression that evaluates to an integer that identifies an individual control within a control array.

Settings

The settings for number are:

Setting | Description
No value | (Default) Not part of a control array.
0 to 32,767 | Part of an array. Specifies an integer greater than or equal to 0 that identifies a control within a control array. All controls in a control array have the same Name property. Visual Basic automatically assigns the next integer available within the control array.

Remarks

Because control array elements share the same Name property setting, you must use the Index property in code to specify a particular control in the array. Index must appear as an integer (or a numeric expression evaluating to an integer) in parentheses next to the control array name — for example, MyButtons(3). You can also use the Tag property setting to distinguish one control from another within a control array.

When a control in the array recognizes that an event has occurred, Visual Basic calls the control array's event procedure and passes the applicable Index setting as an additional argument. This property is also used when you create controls dynamically at run time with the Load statement or remove them with the Unload statement.

Although Visual Basic assigns, by default, the next integer available as the value of Index for a new control in a control array, you can override this assigned value and skip integers. You can also set Index to an integer other than 0 for the first control in the array. If you reference an Index value in code that doesn't identify one of the controls in a control array, a Visual Basic run-time error occurs.

Note To remove a control from a control array, change the control's Name property setting, and delete the control's Index property setting.


Index Property Example

This example starts with two OptionButton controls and adds a new OptionButton to the form each time you click a CommandButton control. When you click an OptionButton, the FillStyle property is set and a new circle is drawn. To try this example, paste the code into the Declarations section of a form that has two OptionButton controls, a CommandButton, and a large PictureBox control. Set the Name property of both OptionButton controls to optButton to create a control array.

Private Sub OptButton_Click (Index As Integer)
   Dim H, W   ' Declare variables.
   Picture1.Cls   ' Clear picture.
   Picture1.FillStyle = Index   ' Set FillStyle.
   W = Picture1.ScaleWidth / 2   ' Get size of circle.
   H = Picture1.ScaleHeight / 2
   Picture1.Circle (W, H), W / 2   ' Draw circle.
End Sub

Private Sub Command1_Click ()
   Static MaxIdx   ' Largest index in array.
   If MaxIdx = 0 Then MaxIdx = 1   ' Preset MaxIdx.
   MaxIdx = MaxIdx + 1   ' Increment index.
   If MaxIdx > 7 Then Exit Sub   ' Put eight buttons on form.
   Load OptButton(MaxIdx)   ' Create new item in array.
   ' Set location of new option button under previous button.
   OptButton(MaxIdx).Top = OptButton(MaxIdx - 1).Top + 360
   OptButton(MaxIdx).Visible = True   ' Make new button visible.
End Sub


Interval Property

Returns or sets the number of milliseconds between calls to a Timer control's Timer event.

Syntax

object.Interval [= milliseconds]

The Interval property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
milliseconds | A numeric expression specifying the number of milliseconds, as described in Settings.

Settings

The settings for milliseconds are:

Setting | Description
0 | (Default) Disables a Timer control.
1 to 65,535 | Sets an interval (in milliseconds) that takes effect when a Timer control's Enabled property is set to True. For example, a value of 10,000 milliseconds equals 10 seconds. The maximum, 65,535 milliseconds, is equivalent to just over 1 minute.

Remarks

You can set a Timer control's Interval property at design time or run time. When using the Interval property, remember:

  • The Timer control's Enabled property determines whether the control responds to the passage of time. Set Enabled to False to turn a Timer control off, and to True to turn it on. When a Timer control is enabled, its countdown always starts from the value of its Interval property setting.

  • Create a Timer event procedure to tell Visual Basic what to do each time the Interval has passed.


Interval Property Example

This example enables you to adjust the speed at which a form switches colors. To try this example, paste the code into the Declarations section of a form that contains a Timer control, an HScrollBar control (horizontal scroll bar), and a PictureBox control, and then press F5 and click the scroll bar.

Private Sub Form_Load ()
   Timer1.Interval = 900   ' Set interval.
   HScroll1.Min = 100   ' Set minimum.
   HScroll1.Max = 900   ' Set maximum.
End Sub
Private Sub HScroll1_Change ()
   ' Set interval according to scroll bar value.
   Timer1.Interval = 1000 - HScroll1.Value
End Sub
Private Sub Timer1_Timer ()
   ' Switch BackColor between red and blue.
   If Picture1.BackColor = RGB(255, 0, 0) Then
      Picture1.BackColor = RGB(0, 0, 255)
   Else
      Picture1.BackColor = RGB(255, 0, 0)
   End If
End Sub


InvisibleAtRuntime Property

Returns or sets a value determining if a control should not have a visible window at run time. The InvisibleAtRuntime property is read/write at the control’s authoring time, and not available at the control’s run time.

Settings

The settings for InvisibleAtRuntime are:

Setting | Description
True | Allows the control to not have a visible window at run time. The container of the control may keep the control invisible during run time, like the Timer control. The control is still active, and therefore the developer who uses the control can still write programs that can interact with the control. There will be no Visible property in the extender object.
False | (Default) The control acts as a normal control at run time, where the state of the Visible extender property determines the visibility of the control.

Remarks

Important Don’t use the Visible extender property to make the control invisible at run time. If you do, the control will still have all the overhead of a visible control at run time. Furthermore, the extender properties are available to the developer and end user, who may make the control visible.

Some containers may not support the InvisibleAtRuntime property; in this case the control will be visible at run time.

Before creating a control that is invisible at run time, consider creating an ordinary object provided by an in-process code component (ActiveX DLL) instead. Objects provided by in-process code components require fewer resources than controls, even invisible controls. The only reason to implement an invisible control is to take advantage of a feature that is only available to ActiveX controls.


IsBindable Property

Returns a boolean value indicating whether the property is bindable. This property is read-only.

Syntax

object.IsBindable

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use this property to determine if the property is bindable.

Note This property is usually used in a Wizard to check whether a property is bindable.


IsDataSource Property

Returns a boolean value indicating whether the property is a data source. This property is read-only.

Syntax

object.IsDataSource

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use this property to determine if the property is a data source and can be attached to a data control.

Note This property is usually used in a Wizard to check whether a property is a data source.


IsDirty Property

Returns a value indicating whether this component was edited since the last time it was saved.

Syntax

object.IsDirty

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


Italic Property

Returns or sets the font style of the Font object to either italic or nonitalic.

Syntax

object.Italic [= boolean]

The Italic property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying the font style as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | Turns on italic formatting.
False | (Default) Turns off italic formatting.

Remarks

The Font object isn't directly available at design time. Instead you set the Italic property by selecting a control's Font property in the Properties window and clicking the Properties button. In the Font Style box of the Font dialog box, select either Italic or Bold Italic. At run time, however, you set Italic directly by specifying its setting for the Font object.


ItemData Property

Returns or sets a specific number for each item in a ComboBox or ListBox control.

Syntax

object.ItemData(index) [= number]

The ItemData property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Index | The number of a specific item in the object.
Number | The number to be associated with the specified item.

Remarks

The ItemData property is an array of long integer values with the same number of items as a control's List property. You can use the numbers associated with each item to identify the items. For example, you can use an employee's identification number to identify each employee name in a ListBox control. When you fill the ListBox, also fill the corresponding elements in the ItemData array with the employee numbers.

The ItemData property is often used as an index for an array of data structures associated with items in a ListBox control.

Note When you insert an item into a list with the AddItem method, an item is automatically inserted in the ItemData array as well. However, the value isn't reinitialized to zero; it retains the value that was in that position before you added the item to the list. When you use the ItemData property, be sure to set its value when adding new items to a list.


ItemData Property Example

This example fills a ListBox control with employee names and fills the ItemData property array with employee numbers using the NewIndex property to keep the numbers synchronized with the sorted list. A Label control displays the name and number of an item when the user makes a selection. To try this example, paste the code into the Declarations section of a form that contains a ListBox and a Label. Set the Sorted property for the ListBox to True, and then press F5 and click the ListBox.

Private Sub Form_Load ()
   ' Fill List1 and ItemData array with
   ' corresponding items in sorted order.
   List1.AddItem "Judy Phelps"
   List1.ItemData(List1.NewIndex) = 42310
   List1.AddItem "Chien Lieu"
   List1.ItemData(List1.NewIndex) = 52855
   List1.AddItem "Mauro Sorrento"
   List1.ItemData(List1.NewIndex) = 64932
   List1.AddItem "Cynthia Bennet"
   List1.ItemData(List1.NewIndex) = 39227
End Sub

Private Sub List1_Click ()
   ' Append the employee number and the employee name.
   Msg = List1.ItemData(List1.ListIndex) & " "
   Msg = Msg & List1.List(List1.ListIndex)
   Label1.Caption = Msg
End Sub


Item Property (DEDesigner Extensibility)

Returns a specific member of a collection object either by position or by key.

Syntax

object.Item(index)

The Item property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
index | Required. An expression that specifies the ordinal position, key, or the name of the returning collection object. For more information, see Visual Basic's Item property.

Remarks

If the value provided as index doesn’t match any existing member of the collection, an error occurs.

Item is the default property for a collection. Therefore, the following lines of code are equivalent.

Print MyCollection(1)
Print MyCollection.Item(1)


Item Property

Returns a specific member of a Collection object either by position or by key.

Syntax

object.Item( index )

The Item property syntax has the following object qualifier and part:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
index | Required. An expression that specifies the position of a member of the collection. If a numeric expression, index must be a number from 1 to the value of the collection's Count property. If a string expression, index must correspond to the key argument specified when the member referred to was added to the collection.

Remarks

If the value provided as index doesn’t match any existing member of the collection, an error occurs.

Item is the default property for a collection. Therefore, the following lines of code are equivalent:

Print MyCollection(1)
Print MyCollection.Item(1)


KeepTogether Property

Returns or sets a value that specifies if the text of a section will be kept together (not broken up over a page break).

Syntax

object.KeepTogether [= boolean]

The KeepTogether property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
boolean | Optional. A boolean expression that specifies if a new page is begun, as shown in Settings.

Settings

The settings for boolean are:

Setting | Description
True | A page break occurs.
False | (Default) A page break doesn't occur.


KeyPreview Property

Returns or sets a value that determines whether keyboard events for forms are invoked before keyboard events for controls. The keyboard events are KeyDown, KeyUp, and KeyPress.

Syntax

object.KeyPreview [= boolean]

The KeyPreview property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression that specifies how events are received, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | The form receives keyboard events first and then the active control.
False | (Default) The active control receives keyboard events; the form doesn't.

Remarks

You can use this property to create a keyboard-handling procedure for a form. For example, when an application uses function keys, you'll want to process the keystrokes at the form level rather than writing code for each control that might receive keystroke events.

If a form has no visible and enabled controls, it automatically receives all keyboard events.

To handle keyboard events only at the form level and not allow controls to receive keyboard events, set KeyAscii to 0 in the form's KeyPress event, and set KeyCode to 0 in the form's KeyDown event.

Note Some controls intercept keyboard events so that the form can't receive them. Examples include the ENTER key when focus is on a CommandButton control and arrow keys when focus is on a ListBox control.


{bmr copyprnt.mrb}KeyPreview Property Example

KeyPreview Property Example

This example creates a form keyboard handler in the KeyDown event. Each of the first four function keys displays a different message. To try this example, paste the code into the Declarations section of a form, and then press F5. Once the program is running, press any one of the first four (F1 – F4) function keys.

Private Sub Form_Load ()
   KeyPreview = True
End Sub

Private Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
   Select Case KeyCode
      Case vbKeyF1: MsgBox "F1 is your friend."
      Case vbKeyF2: MsgBox "F2 could copy text."
      Case vbKeyF3: MsgBox "F3 could paste text."
      Case vbKeyF4: MsgBox "F4 could format text."
   End Select
End Sub


Key Property

Returns or sets a string that uniquely identifies a member in a collection.

Syntax

object.Key [= string]

The Key property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
string | A unique string identifying a member in a collection.

Remarks

If the string is not unique, an error will occur.

You can set the Key property when you use the Add method to add an object to a collection.

If you expect the Index property to change dynamically, refer to objects in a collection using the Key property.

In addition, you can use the Key property to make your Visual Basic project "self-documenting" by assigning meaningful names to the objects in a collection.


LargeChange, SmallChange Properties

  • LargeChange — Returns or sets the amount of change to the Value property setting in a scroll bar control (HScrollBar or VScrollBar) when the user clicks the area between the scroll box and scroll arrow.

  • SmallChange — Returns or sets the amount of change to the Value property setting in a scroll bar control when the user clicks a scroll arrow.

Syntax

object.LargeChange [= number]
object.SmallChange [= number]

The LargeChange and SmallChange property syntaxes have these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | An integer that specifies the amount of change to the Value property.

Remarks

For both properties, you can specify an integer between 1 and 32,767, inclusive. By default, each property is set to 1.

The Microsoft Windows operating environment automatically sets proportional scrolling increments for scroll bars on MDI Form objects, ComboBox controls, and ListBox controls based on the amount of data in the object. For the HScrollBar and VScrollBar controls, however, you must specify these increments. Use LargeChange and SmallChange to set scrolling increments appropriate to how the scroll bar is being used.

Typically, you set LargeChange and SmallChange at design time. You can also reset them in code at run time when the scrolling increment must change dynamically.

Note You set the maximum and minimum ranges of the HScrollBar and VScrollBar controls with the Max and Min properties.


{bmr copyprnt.mrb}LargeChange, SmallChange Properties Example

LargeChange, SmallChange Properties Example

This example uses a scroll bar to move a PictureBox control across the form. To try this example, paste the code into the Declarations section of a form that contains a small PictureBox control and an HScrollBar control, and then press F5 and click the scroll bar.

Private Sub Form_Load ()
   HScroll1.Max = 100   ' Set maximum value.
   HScroll1.LargeChange = 20   ' Cross in 5 clicks.
   HScroll1.SmallChange = 5   ' Cross in 20 clicks.
   Picture1.Left = 0   ' Start picture at left.
   Picture1.BackColor = QBColor(3)   ' Set color of picture box.
End Sub
Private Sub HScroll1_Change ()
   ' Move picture according to scroll bar.
   Picture1.Left = (HScroll1.Value / 100) * ScaleWidth
End Sub


LBound Property

Returns the lowest ordinal value of a control in a control array.

Syntax

object.LBound

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The LBound property setting is equal to the Index property value of the first control in the array. Typically this value is 0 because Visual Basic automatically assigns an Index value of 0 to the first control in a control array. If you manually change the Index value for the first control in an array to some other value (for example, 1), LBound returns the value you manually assigned to Index (in this example, 1).


LBound, UBound Properties Example

This example prints the values of these two properties for a control array. Put an OptionButton control on a form, and set its Index property to 0 (to create a control array). To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Paint ()
   Static FlagFormPainted As Integer
   If FlagFormPainted <> True Then ' When form is painting for first time,
      For i = 1 To 3
         Load Option1(i)   ' add three option buttons to array.
         Option1(i).Top = Option1(i - 1).Top + 350
         Option1(i).Visible = True
      Next I
      For I =  0 to 3   ' Put captions on the option buttons.
         Option1(i).Caption = "Option #" & CStr(i)
      Next I
      Option1(0).Value = True   ' Select first option button.
      FlagFormPainted = True   ' Form is done painting.
   End If
End Sub
Private Sub Form_Click ()
   Print "Control array's Count property is " & Option1().Count
   Print "Control array's LBound property is " & Option1().LBound
   Print "Control array's UBound property is " & Option1().UBound
End Sub


Left, Top Properties

  • Left — returns or sets the distance between the internal left edge of an object and the left edge of its container.

  • Top — returns or sets the distance between the internal top edge of an object and the top edge of its container.

Syntax

object.Left [= value]

object.Top [= value]

The Left and Top property syntaxes have these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A numeric expression specifying distance.

Remarks

For a form, the Left and Top properties are always expressed in twips; for a control, they are measured in units depending on the coordinate system of its container. The values for these properties change as the object is moved by the user or by code. For the CommonDialog and Timer controls, these properties aren't available at run time.

For either property, you can specify a single-precision number.

Use the Left, Top, Height, and Width properties for operations based on an object's external dimensions, such as moving or resizing. Use the ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth properties for operations based on an object's internal dimensions, such as drawing or moving objects that are contained within the object. The scale-related properties apply only to PictureBox controls and Form and Printer objects.


LeftMargin, RightMargin Properties

Returns or sets, in twips, the width of the left or right margin.

Syntax

object.LeftMargin [=number]

object.RightMargin[=number]

The LeftMargin and RightMargin properties syntax have these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | Optional. A numeric expression specifying the width of the left or right margin.


RightToLeft Property

Returns a boolean value that indicates the text display direction and controls the visual appearance on a bidirectional system.

Syntax

object.RightToLeft

The RightToLeft property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Settings

The possible boolean return values from the RightToLeft property are:

Setting | Description
True | The control is running on a bi-directional platform, such as Arabic Windows95 or Hebrew Windows95, and text is running from right to left. The control should modify its behavior, such as putting vertical scroll bars at the left side of a text or list box, putting labels to the right of text boxes, etc.
False | The control should act as though it was running on a non-bidirectional platform, such as English Windows95, and text is running from left to right. If the container does not implement this ambient property, this will be the default value.


Left, Top Properties Example

This example sets the size of a form to 75 percent of screen size and centers the form when it's loaded. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Width = Screen.Width * .75   ' Set width of form.
   Height = Screen.Height * .75   ' Set height of form.
   Left = (Screen.Width - Width) / 2   ' Center form horizontally.
   Top = (Screen.Height - Height) / 2   ' Center form vertically.
End Sub


LegalCopyright Property

Returns or sets a string value containing legal copyright information about the running application. Read only at run time.

Syntax

object.LegalCopyright

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You can set this property at design time in the Type box in the Make tab of the Project Properties dialog box.


LegalTrademarks Property

Returns or sets a string value containing legal trademark information about the running application. Read only at run time.

Syntax

object.LegalTrademarks

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You can set this property at design time in the Type box in the Make tab of the Project Properties dialog box.


LicenseKey Property

Returns the license key of a control.

Syntax

object.LicenseKey

The object placeholder is an object expression that evaluates to an object in the Applies To list.

Remarks

You must add the license key to the Licenses collection before attempting to dynamically add a licensed control to the Controls collection.


Licenses Property

Returns a reference to the Licenses Collection.

Syntax

object.Licenses

The object placeholder is an object expression that evaluates to an object in the Applies To list.

Remarks

The Licenses collection is used to contain license keys of unreferenced controls. You must add a control's license key to the collection before adding the control itself to the Controls collection. To add a license key, use the Add method for the Licenses collection.

The Licenses property is a property of the Global object. Since the Global object is referenced automatically, you can use the Licenses property without explicitly naming the object, as shown in the code below:

Licenses.Add "myProject.myControl", "xydsfasfjewfe"


LineSlant Property

Returns or sets the direction the line will slant.

Syntax

object.LineSlant [=integer]

The LineSlant property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
integer | Optional. A numeric expression that specifies the direction of the line's slant, as shown in Settings.

Settings

The settings for integer are:

Constant | Value | Description
rptSlantNWSE | 0 | The line slants from upper left to lower right (northwest to southeast).
rptSlantNESW | 1 | The line slants from upper right to lower left (northeast to southwest).


Lines Property

Returns a string containing the specified block of lines.

Syntax

object.Lines(startline As Long, count As Long)

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
startline | A Long data type specifying the line number to start at.
count | A Long data type specifying the number of lines to highlight.


LinkItem Property

Returns or sets the data passed to a destination control in a DDE conversation with another application.

Syntax

object.LinkItem [= string]

The LinkItem property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
String | A string expression that specifies the data to be passed to the destination control.

Remarks

This property corresponds to the item argument in the standard DDE syntax, with application, topic, and item as arguments. To set this property, specify a recognizable unit of data in an application as a reference — for example, a cell reference such as "R1C1" in Microsoft Excel.

Use LinkItem in combination with the LinkTopic property to specify the complete data link for a destination control to a source application. To activate this link, set the LinkMode property.

You set LinkItem only for a control used as a destination. When a Visual Basic form is a source in a DDE conversation, the name of any Label, PictureBox, or TextBox control on the form can be the item argument in the application|topic!item string used by the destination. For example, the following syntax represents a valid reference from Microsoft Excel to a Visual Basic application:

=VizBasicApplication|MyForm!TextBox1

You could enter the preceding syntax for a destination cell in the Microsoft Excel formula bar.

A DDE control can potentially act as destination and source simultaneously, causing an infinite loop if a destination-source pair is also a source-destination pair with itself. For instance, a TextBox control may be both a source (through its parent form) and destination of the same cell in Microsoft Excel. When data in a Visual Basic TextBox changes, sending data to Microsoft Excel, the cell in Microsoft Excel changes, sending the change to the TextBox, and so on, causing the loop.

To avoid such loops, use related but not identical items for destination-source and source-destination links in both directions between applications. For example, in Microsoft Excel, use related cells (precedents or dependents) to link a worksheet with a Visual Basic control, avoiding use of a single item as both destination and source. Document any application|topic pairs you establish if you include a Paste Link command for run-time use.

Note Setting a permanent data link at design time with the Paste Link command from the Edit menu also sets the LinkMode, LinkTopic, and LinkItem properties. This creates a link that is saved with the form. Each time the form is loaded, Visual Basic attempts to re-establish the conversation.


LinkMode Property

Returns or sets the type of link used for a DDEconversation and activates the connection as follows:

  • Control — Allows a destination control on a Visual Basic form to initiate a conversation, as specified by the control's LinkTopic and LinkItem properties.

  • Form — Allows a destination application to initiate a conversation with a Visual Basic source form, as specified by the destination application's application|topic!item expression.

Syntax

object.LinkMode [= number]

The LinkMode property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | An integer that specifies the type of connection, as described in Settings.

Settings

For controls used as destinations in DDE conversations, the settings for number are:

Constant | Setting | Description
VbLinkNone | 0 | (Default) None — No DDE interaction.
VbLinkAutomatic | 1 | Automatic — Destination control is updated each time the linked data changes.
VbLinkManual | 2 | Manual — {Destination control is updated only when the LinkRequest method is invoked.
VbLinkNotify | 3 | Notify — A LinkNotify event occurs whenever the linked data changes, but the destination control is updated only when the LinkRequest method is invoked.

For forms used as sources in DDE conversations, the settings for number are:

Constant | Setting | Description
VbLinkNone | 0 | (Default) None — No DDE interaction. No destination application can initiate a conversation with the source form as the topic, and no application can poke data to the form. If LinkMode is 0 (None) at design time, you can't change it to 1 (Source) at run time.
VbLinkSource | 1 | Source — Allows any Label, PictureBox, or TextBox control on a form to supply data to any destination application that establishes a DDE conversation with the form. If such a link exists, Visual Basic automatically notifies the destination whenever the contents of a control are changed. In addition, a destination application can poke data to any Label, PictureBox, or TextBox control on the form. If LinkMode is 1 (Source) at design time, you can change it to 0 (None) and back at run time.

Remarks

The following conditions also apply to the LinkMode property:

  • Setting LinkMode to a nonzero value for a destination control causes Visual Basic to attempt to initiate the conversation specified in the LinkTopic and LinkItem properties. The source updates the destination control according to the type of link specified (automatic, manual, or notify).

  • If a source application terminates a conversation with a Visual Basic destination control, the value for that control's LinkMode setting changes to 0 (None).

  • If you leave LinkMode for a form set to the default 0 (None) at design time, you can't change LinkMode at run time. If you want a form to act as a source, you must set LinkMode to 1 (Source) at design time. You can then change the value of LinkMode at run time.

Note Setting a permanent data link at design time with the Paste Link command from the Edit menu also sets the LinkMode, LinkTopic, and LinkItem properties. This creates a link that is saved with the form. Each time the form is loaded, Visual Basic attempts to re-establish the conversation.


LinkTimeout Property

Returns or sets the amount of time a control waits for a response to a DDE message.

Syntax

object.LinkTimeout [= number]

The LinkTimeout property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | A numeric expression that specifies the wait time.

Remarks

By default, the LinkTimeout property is set to 50 (equivalent to 5 seconds). You can specify other settings in tenths of a second.

DDE response time from source applications varies. Use this property to adjust the time a destination control waits for a response from a source application. If you use LinkTimeout, you can avoid generating a Visual Basic error if a given source application takes too long to respond.

Note The maximum length of time that a control can wait is 65,535 tenths of a second, or about 1 hour 49 minutes. Setting LinkTimeout to –1 tells the control to wait the maximum length of time for a response in a DDE conversation. The user can force the control to stop waiting by pressing the ESC key.


LinkTopic Property

For a destination control — returns or sets the source application and the topic (the fundamental data grouping used in that application). Use LinkTopic with the LinkItem property to specify the complete data link.

For a source form — returns or sets the topic that the source form responds to in a DDE conversation.

Syntax

object.LinkTopic [= value]

The LinkTopic property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A string expression specifying a DDE syntax element.

Remarks

The LinkTopic property consists of a string that supplies part of the information necessary to set up either a destination link or source link. The string you use depends on whether you're working with a destination control or a source form. Each string corresponds to one or more elements of standard DDE syntax, which include application, topic, and item.

Note While the standard definition for a DDE link includes the application, topic, and item elements, the actual syntax used within applications for a destination link to a source application may vary slightly. For example, within Microsoft Excel, you use the syntax:

application|topic!item

Within Microsoft Word for Windows, you use:

application topic item

(Don't use the pipe character [|] or exclamation mark [!].)

Within a Visual Basic application, you use:

application|topic

The exclamation mark for topic is implicit.

Destination Control To set LinkTopic for a destination control, use a string with the syntax application|topic as follows:

  • application is the name of the application from which data is requested, usually the executable filename without an extension — for example, Excel (for Microsoft Excel).

  • The pipe character (|, or character code 124) separates the application from the topic.

  • topic is the fundamental data grouping used in the source application — for example, a worksheet in Microsoft Excel.

In addition, for a destination control only, you must set the related LinkItem property to specify the item element for the link. A cell reference, such as R1C1, corresponds to an item in a Microsoft Excel worksheet.

Source Form To set LinkTopic for a source form, set value to an appropriate identifier for the form. A destination application uses this string as the topic argument when establishing a DDE link with the form. Although this string is all you need to set LinkTopic within Visual Basic for a source form, the destination application also needs to specify:

  • The application element that the destination application uses, which is either the Visual Basic project filename without the .vbp extension (if you're running your application in the Visual Basic development environment) or the Visual Basic application filename without the .exe extension (if you're running your application as a stand-alone executable file). The EXEName property of the App object provides this string in your Visual Basic code unless the filename was changed by the user. (EXEName always returns the actual filename of the application on disk; DDE always uses the original name that was specified in the Project Properties dialog box.)

  • The item element that the destination application uses, which corresponds to the Name property setting for the Label, PictureBox, or TextBox control on the source form.

The following syntax is an example of a valid reference from Microsoft Excel to a Visual Basic application acting as a source:

=VizBasicApplication|FormN!TextBox1

You could enter this reference for a destination cell in the Microsoft Excel formula bar.

To activate the data link set with LinkTopic, set the LinkMode property to the appropriate nonzero value to specify the type of link you want. As a general rule, set LinkMode after you set LinkTopic. For a destination control, changing LinkTopic breaks an existing link and terminates the DDE conversation. For a source form, changing LinkTopic breaks all destination links that are using that topic. For these reasons, always set the LinkMode property to 0 before changing LinkTopic. After changing LinkTopic for a destination control, you must set LinkMode to 1 (Automatic), 2 (Manual), or 3 (Notify) to establish a conversation with the new topic.

Note Setting a permanent data link at design time with the Paste Link command on the Edit menu also sets the LinkMode, LinkTopic, and LinkItem properties. This creates a link that is saved with the form. Each time the form is loaded, Visual Basic attempts to reestablish the conversation.


{bmr copyprnt.mrb}LinkItem, LinkMode, LinkTopic Properties Example

LinkItem, LinkMode, LinkTopic Properties Example

In the example, each mouse click causes a cell in a Microsoft Excel worksheet to update the contents of a Visual Basic TextBox control. To try this example, start Microsoft Excel, open a new worksheet named Sheet1, and put some data in the first column. In Visual Basic, create a form with a TextBox control. Paste the code into the Declarations section, and then press F5 to run the program.

Private Sub Form_Click ()
   Dim CurRow As String
   Static Row   ' Worksheet row number.
   Row = Row + 1   ' Increment Row.
   If Row = 1 Then   ' First time only.
      ' Make sure the link isn't active.
      Text1.LinkMode = 0
      ' Set the application name and topic name.
      Text1.LinkTopic = "Excel|Sheet1"
      Text1.LinkItem = "R1C1"   ' Set LinkItem.
      Text1.LinkMode = 1   ' Set LinkMode to Automatic.
   Else
      ' Update the row in the data item.
      CurRow = "R" & Row & "C1"
      Text1.LinkItem = CurRow   ' Set LinkItem.
   End If
End Sub


List Property

Returns or sets the items contained in a control's list portion. The list is a string array in which each element is a list item. Available at design time for ListBox and ComboBox controls through the Properties window; read-only at run time for DirListBox, DriveListBox, and FileListBox controls; read/write at run time for ComboBox and ListBox controls.

Syntax

object.List(index) [= string]

The List property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | The number of a specific item in the list.
string | A string expression specifying the list item.

Remarks

Use this property to access list items.

For all controls except the DirListBox, the index of the first item is 0 and the index of the last item is ListCount–1.

For a DirListBox control, the index number sequence is based on the current directories and subdirectories when the control is created at run time. The directory that is currently expanded is represented using the index–1. Directories above the currently expanded directory are represented by negative indexes with higher absolute values. For example,–2 is the parent directory of the directory that is currently expanded and–3 is the directory above that. Directories below the directory that is currently expanded range from 0 to ListCount–1.

Initially, ComboBox and ListBox controls contain an empty list. For the file-system controls, the list is based on conditions that exist when the control is created at run time:

  • DirListBox — contains a list of all directories, using the range -n to ListCount–1.

  • DriveListBox — contains the list of drive connections in effect.

  • FileListBox — contains the list of files in the directory that is currently expanded that match the Pattern property. The path isn't included.

The List property works in conjunction with the ListCount and ListIndex properties.

For all applicable controls except a DirListBox, enumerating a list from 0 to ListCount -1 returns all items in the list. For a DirListBox control, enumerating the list from–n to ListCount–1 returns a list containing all directories and subdirectories visible from the directory that is currently expanded. In this case n is the number of directory levels above the directory that is currently expanded.

Note To specify items you want to display in a ComboBox or ListBox control, use the AddItem method. To remove items, use the RemoveItem method. To keep items in alphabetic order, set the control's Sorted property to True before adding items to the list.

Using an Option Base = 1 statement in the Declarations section doesn't affect the enumeration of elements in Visual Basic controls. The first element is always 0.

When the List index is outside the range of actual entries in the list box, a zero-length string ("") is returned. For example, List(-1) returns a zero-length string for a ComboBox or ListBox control.


ListCmbo (ListCmbo.vbp)

This sample program demonstrates data binding to the standard ListBox and ComboBox controls.

Background

Visual Basic allows you to bind the standard ListBox and ComboBox controls to a Data control. Unlike other bound controls, the ListBox and ComboBox controls require that you populate the List portions of the control before binding in order to correctly display the current record's value in the control.

When binding to a ComboBox and ListBox control, the Data control selects the current record's value from the list of available entries within the control. For example, binding the ListBox control to a field within a database which contains state abbreviations, the Data control will search the values within the ListBox and select the matching entry. As a result, you must populate the control with all possible state abbreviations before binding the control. If the ListBox is not populated, the Data control will not be able to find the matching entry and no item will be selected.

This sample application demonstrates this behavior and shows how to populate the ListBox and ComboBox controls prior to binding. A single form is used to display the Publishers table contained within Biblio.mdb. Publishers has a "state" field which contains the state abbreviation of the current Publisher's address. At runtime, the sample performs a query of the Publishers table of all distinct values contained within the state field and populates a ListBox and ComboBox control. Then, the controls are bound to the Data control.

When the user cycles through the Publishers records using the navigation buttons on the Data control, the "state" field value for the current record is selected in the ListBox and ComboBox controls. The user can then choose which of these controls to view by clicking on the appropriate option buttons.

File | Description
Frmpub.frm | The main Publishers form, which displays the Publishers records.
Frmpub.frx | The binary portion of the Publishers form.
Frmabout.frm | Standard About form.
Frmabout.frx | The binary portion of the About form.
Listcmbo.vbp | The project file for the sample application.

To Run

From the Visual Basic File menu, choose Open Project and select the ListCmbo.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.

To cycle through the records, click on the navigation buttons on the Data control. To view either the ListBox or ComboBox controls, click on the appropriate option buttons.


ListCount Property

Returns the number of items in the list portion of a control.

Syntax

object.ListCount

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

ListCount provides specific information for each control:

  • ComboBox and ListBox controls — the number of items in the list.

  • DirListBox control — the number of subdirectories in the current directory.

  • DriveListBox control — the number of drive connections.

  • FileListBox control — the number of files in the current directory that match the Pattern property setting.

If no item is selected, the ListIndex property value is –1. The first item in the list is ListIndex = 0, and ListCount is always one more than the largest ListIndex value.


ListCount Property Example

This example loads a list of your printer fonts into a ComboBox control, displays the first item in the list, and prints the total number of fonts. Each click of the command button changes all items in the list to uppercase or lowercase. To try this example, paste the code into the Declarations section of a form that contains a ComboBox control (Style = 2) and a CommandButton control, and then press F5 and click the CommandButton.

Private Sub Form_Load ()
   Dim I   ' Declare variable.
   AutoRedraw = True   ' Set AutoRedraw.
   For I = 0 To Printer.FontCount - 1   ' Put font names in list.
      Combo1.AddItem Printer.Fonts(I)
   Next I
   Combo1.ListIndex = 0   ' Set text to first item.
   ' Print ListCount information on form.
   Print "Number of printer fonts: "; Combo1.ListCount
End Sub
Private Sub Command1_Click ()
   Static UpperCase
   Dim I   ' Declare variable.
   For I = 0 To Combo1.ListCount - 1   ' Loop through list.
      If UpperCase Then
         Combo1.List(I) = UCase(Combo1.List(I))
      Else
         Combo1.List(I) = LCase(Combo1.List(I))
      End If
   Next I
   UpperCase = Not UpperCase   ' Change case.
End Sub


ListIndex Property

Returns or sets the index of the currently selected item in the control. Not available at design time.

Syntax

object.ListIndex [= index]

The ListIndex property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | A numeric expression specifying the index of the current item, as described in Settings.

Settings

The settings for index are:

Setting | Description
–1 | (Default for ComboBox, DirListBox, and DriveListBox controls) Indicates no item is currently selected. For a ComboBox control, indicates the user has entered new text into the text box portion. For a DirListBox control, indicates the index of the current path. For a DriveListBox control, indicates the index of the current drive when the control is created at run time.
n | (Default for FileListBox and ListBox controls) A number indicating the index of the currently selected item.

Remarks

The expression List(List1.ListIndex) returns the string for the currently selected item.

The first item in the list is ListIndex = 0, and ListCount is always one more than the largest ListIndex value.

For a control in which users can make multiple selections, this property's behavior depends on the number of items selected. If only one item is selected, ListIndex returns the index of that item. In a multiple selection, ListIndex returns the index of the item contained within the focus rectangle, whether or not that item is actually selected.


ListIndex Property Example

This example displays the names of three players in a ListBox control and the corresponding salary of the selected player in a Label control. To try this example, paste the code into the Declarations section of a form that contains a ComboBox control and a Label control, and then press F5 and choose a name from the ComboBox.

Dim Player(0 To 2)   ' Dimension two arrays.
Dim Salary(0 To 2)
Private Sub Form_Load ()
   Dim I   ' Declare variable.
   AutoSize = True
   Player(0) = "Miggey McMoo"   ' Enter data into arrays.
   Player(1) = "Alf Hinshaw"
   Player(2) = "Woofer Dean"
   Salary(0) = "$234,500"
   Salary(1) = "$158,900"
   Salary(2) = "$1,030,500"
   For I = 0 To 2   ' Add names to list.
      Combo1.AddItem Player(I)
   Next I
   Combo1.ListIndex = 0   ' Display first item in list.
End Sub

Private Sub Combo1_Click ()
   ' Display corresponding salary for name.
   Label1.Caption = Salary(Combo1.ListIndex)
End Sub


List Property Example

This example loads a ComboBox control with a list of sandwich names and displays the first item in the list. To try this example, paste the code into the Declarations section of a form that contains a ComboBox control, and then press F5.

Private Sub Form_Load ()
   Combo1.AddItem "Denver Sandwich"   ' Add each item to list.
   Combo1.AddItem "Reuben Sandwich"
   Combo1.AddItem "Turkey Sandwich"
   Combo1.Text = Combo1.List(0)   ' Display first item.
End Sub


LocaleID Property

Returns a long value that contains the Locale identification (language and country) of the user.

Syntax

object.LocaleID

The LocaleID property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

The LocaleID ambient property contains identification of the language and country of the current user. Using this identification, the control can modify its behavior and appearance to fit the language and country. This could be as simple as having error notifications in the language of the user, to more complex modifications of property, method, and event names in the language of the user.

If the container does not implement this ambient property, the default value will be the current System LocaleID.


Locked Property

Returns or sets a value indicating whether a control can be edited.

Syntax

object.Locked [ = boolean]

The Locked property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression that specifies whether the control can be edited, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | TextBox control — you can scroll and highlight the text in the control, but you can't edit it. The program can still modify the text by changing the Text property.
 | Column object — you can't edit the values in the column.
 | ComboBox object — you can't type in the textbox.
False | TextBox control — you can edit the text in the control.
 | Column object — you can edit the values in the column.
 | ComboBox object — you can type in the textbox and drop down its list.

Remarks

For the Column object, the default setting of Locked is the value of the DataUpdatable property for the underlying field; however, if Column is unbound or the data source doesn't support DataUpdatable, the default is True. If DataUpdatable in the underlying field is False, you do not create an error by setting this property to True. However, an error will occur when the control attempts to write the changed data to the database.

For the ComboBox control, when Locked is set to True, the user cannot change any data, but can highlight data in the text box and copy it. This property does not affect programmatic access to the ComboBox.


LockType Property (DEDesigner Extensibility)

Sets the type of lock that the provider uses to open the DECommand object, and returns the type of lock used by an open DECommand object.

Syntax

object.LockType [=value]

The LockType property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies the type of lock to use.

Remarks

This property corresponds to the ADO Recordset LockType property.


LogMode Property

Returns a value which determines how logging (through the LogEvent method) will be carried out. Read-only at run time.

Syntax

object.LogMode = mode

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
mode | Long. Determines the method of logging, as shown in Settings below.

Settings

The settings for mode are:

Constant | Value | Description
vbLogAuto | 0 | If running on Windows 95, this option logs messages to the file specified in the LogPath property. If running on Windows NT, messages are logged to the Windows NT Application Event Log, with "VBRunTime" used as the application source and App.Title appearing in the description.
VbLogOff | 1 | Turns all logging off. Messages from UI shunts as well as from the LogEvent method are ignored and discarded.
VbLogToFile | 2 | Forces logging to a file. If no valid filename is present in LogPath, logging is ignored, and the property is set to vbLogOff.
VbLogToNT | 3 | Forces logging to the NT event log. If not running on Windows NT, or the event log is unavailable, logging is ignored and the property is set to vbLogOff.
VbLogOverwrite | 0x10 | Indicates that the logfile should be recreated each time the application starts. This value can be combined with other mode options using the OR operator. The default action for logging is to append to the existing file. In the case of NT event logging, this flag has no meaning.
VbLogThreadID | 0x20 | Indicates that the current thread ID be prepended to the message, in the form "[T:0nnn] ". This value can be combined with other mode options using the OR operator. The default action is to show the thread ID only when the application is multi-threaded (either explicitly marked as thread-safe, or implemented as an implicit multithreaded app, such as a local server with the instancing property set to Single-Use, multithreaded).

Return Type

Long


LogPath Property

Returns the path and filename of the file used to capture output from the LogEvent method. Not available at design-time; read-only at run time.

Syntax

object.LogPath = path

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
path | String. The path and filename of a log file.

Remarks

The LogMode property determines how logging will be carried out. If no LogPath is set, the LogEvent method writes to the NT LogEvent file.


lpOleObject Property

Returns the address of the object.

Syntax

object.lpOleObject

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Many function calls in the ActiveX DLLs require the address of an object as an argument. Pass the value specified in the lpOleObject property when making API calls to the ActiveX DLLs. The value is 0 if no object is currently displayed. If a call is made to an API that makes a callback to the OLE container control, the result is unpredictable.

The address returned by this property is a pointer to the lpOleObject interface for the active object.


Major Property

Returns or sets the major release number of the project. Read only at run time.

Syntax

object.Major

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The value of the Major property is in the range from 0 to 9999.

This property provides version information about the running application.

You can set this property at design time in the Major box in the Make tab of the Project Properties dialog box.


MaskColor Property

Returns or sets a color in a button’s picture to be a “mask” (that is, transparent).

Syntax

object.MaskColor [= color]

The MaskColor property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
color | A value or constant that determines the color to be used as a mask, as described in Settings.

Settings

Visual Basic uses the Microsoft Windows operating environment red-green-blue (RGB) color scheme. The settings for color are:

Setting | Description
Normal RGB colors | Colors specified using the Color palette or by using the RGB or QBColor functions in code.
&H00C0C0C0 | (Default) Light gray.

Remarks

If the system colors change, then the color which is transparent will change, making the look of your picture unpredictable. It is good programming practice to use non-system colors.

This property is used only when the UseMaskColor property is set to True and the button has a bitmap-style picture assigned to its Picture property. (Icons and metafiles already contain transparency information.)

If the MaskColor property is changed at run time, the button will redraw itself with the new color acting as a mask.


MaskColor Property (UserControl Object)

Returns or sets the color that determines the transparent region of the bitmap assigned to the MaskPicture property of a UserControl object whose BackStyle property is set to 0 (Transparent).

Syntax

object.MaskColor [= color]

The MaskColor property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
color | A value or constant that determines the color to be used as a mask, as described in Settings.

Settings

Visual Basic uses the Microsoft Windows operating environment red-green-blue (RGB) color scheme. The settings for color are:

Setting | Description
RGB colors | Colors specified by using the Color palette or by using the RGB or QBColor functions in code.

Remarks

When a bitmap is assigned to the MaskPicture property of a UserControl whose BackStyle property is set to 0 (Transparent), the control becomes transparent wherever it is covered by areas of the bitmap that match the MaskColor property.

Mouse events that occur over the transparent areas are received by the container or by controls that would otherwise be covered by the UserControl.

If there is no bitmap assigned to the MaskPicture property, or if the BackStyle property of the UserControl is not set to 0 (Transparent), then setting the MaskColor property has no effect.

For further details, see the MaskPicture property of the UserControl object.

Note Although MaskColor accepts the system color constants listed in the Visual Basic (VB) object library in the Object Browser, as described in Help for the BackColor and ForeColor properties, this is only useful if the MaskPicture bitmap contains a system color.


MaskPicture Property (UserControl Object)

Returns or sets the bitmap that, combined with the MaskColor property, determines the transparent and visible regions of a UserControl object whose BackStyle property is set to 0 (Transparent).

Syntax

object.MaskPicture [= picture]

The MaskPicture property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
picture | A graphic image of one of the types described in Settings.

Settings

The settings for picture are:

Setting | Description
Nothing | (Default) No picture. At design time, highlight the property value and press the Delete key; "(None)" will appear in the Properties window. At run time, assign the return value of the LoadPicture function with no filename, or use the Set statement to assign the value Nothing to the property.
(Bitmap, DIB, GIF, or JPEG) | Specifies an image-type bitmap. At design time, you can use the Properties window to enter a string expression specifying a file containing a graphic. At run time, you can set this property using a Picture object, using another object's Picture property, or using the LoadPicture function on an image-type bitmap file.

Important This feature is supported only for image-type bitmaps, such as GIF, JPEG, and DIB. It is not supported for Windows metafiles, icons, or cursors.

Remarks

When a bitmap is assigned to the MaskPicture property of a UserControl whose BackStyle property is set to 0 (Transparent), the control becomes transparent wherever it is covered by areas of the bitmap that match the MaskColor property.

Mouse events that occur over the transparent areas are received by the container or by controls that would otherwise be covered by the UserControl.

The non-transparent parts of the MaskPicture bitmap are painted with the color specified by the UserControl's BackColor property. These areas, which need not be contiguous, define the clipping region for drawing on the UserControl. That is, any drawing that is done on the surface of the UserControl is clipped to the non-transparent parts of the MaskPicture bitmap.

Important The bitmap assigned to the MaskPicture property is only used to define the transparent region and clipping region for the UserControl. The bitmap is never displayed. To display a bitmap on top of the clipping region defined by MaskPicture and MaskColor, you can assign the bitmap to the Picture property of the UserControl, or draw it on the UserControl using PaintPicture in the UserControl's Paint event.

You can create an animated clipping region for your control by drawing on a hidden PictureBox, and transferring the resulting image to the MaskPicture property of the UserControl.

Note When you set the MaskPicture property at design time, the graphic is saved and loaded with the .ctl and .ctx files that define the UserControl. If you make the project into a control component (.ocx file), the file contains the image. When you load a graphic at run time, by contrast, the graphic isn't saved with the component.

For more information, see "Giving Your Control a Transparent Background," in "Building ActiveX Controls" in "Creating ActiveX Components" in the Component Tools Guide.


MaxButton Property

Returns a value indicating whether a form has a Maximize button.

Syntax

object.MaxButton

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The MaxButton property settings are:

Setting | Description
True | (Default) The form has a Maximize button.
False | The form doesn't have a Maximize button.

Remarks

A Maximize button enables users to enlarge a form window to full-screen size. To display a Maximize button, you must also set the form's BorderStyle property to either 1 (Fixed Single), 2 (Sizable), or 3 (Fixed Double).

A Maximize button automatically becomes a Restore button when a window is maximized. Minimizing or restoring a window automatically changes the Restore button back to a Maximize button.

The settings you specify for the MaxButton, MinButton, BorderStyle, and ControlBox properties aren't reflected in the form's appearance until run time.

Note Maximizing a form at run time generates a Resize event. The WindowState property reflects the current state of the window. If you set the WindowState property to 2 (Maximized), the form is maximized independently of whatever settings are in effect for the MaxButton and BorderStyle properties.


MaxLength Property

Returns or sets a value indicating whether there is a maximum number of characters that can be entered in the TextBox control and, if so, specifies the maximum number of characters that can be entered.

Note In DBCS (double-byte character set) systems, each character can take up to two bytes instead of only one, which limits the number of characters you can enter.

Syntax

object.MaxLength [= value]

The MaxLength property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | An integer specifying the maximum number of characters a user can enter in a TextBox control. The default for the MaxLength property is 0, indicating no maximum other than that created by memory constraints on the user's system for single-line TextBox controls and a maximum of approximately 32K for multiple-line TextBox controls. Any number greater than 0 indicates the maximum number of characters.

Remarks

Use the MaxLength property to limit the number of characters a user can enter in a TextBox.

If text that exceeds the MaxLength property setting is assigned to a TextBox from code, no error occurs; however, only the maximum number of characters is assigned to the Text property, and extra characters are truncated. Changing this property doesn't affect the current contents of a TextBox but will affect any subsequent changes to the contents.


MaxLength Property Example

This example uses a numeric value in one TextBox control to limit the length of text in another TextBox control. To try this example, paste the code into the Declarations section of a form that contains two TextBox controls. Make Text1 fairly large, and then press F5. Enter a number into Text2 and text into Text1.

Private Sub Text1_Change ()
   Text1.MaxLength = Text2.Text
End Sub


MaxRecords Property

Returns or sets the maximum number of records that can be retrieved from the data source.

Syntax

object.MaxRecords [=number]

The MaxRecords property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
number | Integer. A numeric expression that specifies the number of records that can be retrieved from the data source.

Remarks

This property corresponds to the ADO Recordset MaxRecords property.


Max, Min Properties (Scroll Bar)

  • Max — returns or sets a scroll bar position's maximum Value property setting when the scroll box is in its bottom or rightmost position. For the ProgressBar control, it returns or sets its maximum value.

  • Min — returns or sets a scroll bar position's minimum Value property setting when the scroll box is in its top or leftmost position. For the ProgressBar control, it returns or sets its minimum value.

Syntax

object.Max [= value]

object.Min [= value]

The Max and Min property syntaxes have these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A numeric expression specifying the maximum or minimum Value property setting, as described in Settings.

Settings

For each property, you can specify an integer between -32,768 and 32,767, inclusive. The default settings are:

  • Max — 32,767.

  • Min — 0.

Remarks

The Microsoft Windows operating environment automatically sets ranges for scroll bars proportional to the contents of forms, ComboBox controls, and ListBox controls. For a scroll bar (HScrollBar or VScrollBar) control, however, you must specify these ranges. Use Max and Min to set a range appropriate to how the scroll bar control is used — for example, as an input device or as an indicator of speed or quantity.

Typically, you set Max and Min at design time. You can also set them in code at run time if the scrolling range must change dynamically — for example, when adding records to a database that can be scrolled through. You set the maximum and minimum scrolling increments for a scroll bar control with the LargeChange and SmallChange properties.

Note If Max is set to less than Min, the maximum value is set at the leftmost or topmost position of a horizontal or vertical scroll bar, respectively. The Max property of a ProgressBar control must always be greater than its Min property, and its Min property must always be greater than or equal to 0.

The Max and Min properties define the range of the control. The ProgressBar control’s Min property is 0 and its Max property is 100 by default, representing the percentage duration of the operation.


MDIChild Property

Returns or sets a value indicating whether a form is displayed as an MDI child form inside an MDI form. Read only at run time.

Syntax

object.MDIChild

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The MDIChild property settings are:

Setting | Description
True | The form is an MDI child form and is displayed inside the parent MDI form.
False | (Default) The form isn't an MDI child form.

Remarks

Use this property when creating a multiple-document interface (MDI) application. At run time, forms with this property set to True are displayed inside an MDI form. An MDI child form can be maximized, minimized, and moved, all inside the parent MDI form.

When working with MDI child forms, keep the following in mind:

  • At run time, when an MDI child form is maximized, its caption is combined with that of the parent MDI form.

  • At design time, an MDI child form is displayed like any other form because the form is displayed inside the parent form only at run time. An MDI child form's icon in the Project window is different from icons for other kinds of forms.

  • MDI child forms can't be modal.

  • The initial size and placement of MDI child forms are controlled by the Microsoft Windows operating environment unless you specifically set them in the Load event procedure.

  • If an MDI child form is referenced before the parent is loaded, the parent MDI form is automatically loaded. However, if the parent MDI form is referenced before loading an MDI child form, the child form isn't loaded.

Note All MDI child forms have sizable borders, a Control-menu box, and Minimize and Maximize buttons, regardless of the settings of the BorderStyle, ControlBox, MinButton, and MaxButton properties.

Any reference to an MDIForm object, including reading or setting properties, causes the form to load and become visible.


MDIChild Property Example

This example creates a second instance of an MDI child form within an MDIForm object. To try this example, set the MDIChild property to True on Form1, and then create an MDIForm object with the Add MDI Form command on the Project menu. Paste the code into the Declarations section of the MDIForm, and then press F5 to run the program.

Private Sub MDIForm_Load ()
   Dim NewForm As New Form1   ' Declare new form.
   NewForm.Show   ' Show new form.
End Sub


MDI (MDINote.vbp)

This sample application demonstrates a Multiple Document Interface (MDI) notepad application. It also provides an introduction to menu creation.

Background

The sample is comprised of a parent form, a child form, a modal dialog form, and two basic modules. You can use this sample application in conjunction with the SDINote sample application to understand the differences between interface styles. For more information, see "Creating a User Interface," in the Programmer's Guide.

File | Description
Filopen.bas | Module containing common file handling code.
Find.frm | Modal dialog form.
Mdi.frm | The MDI parent form.
Mdi.frx | Binary data file for the Mdi.frm file.
Mdinote.bas | Module containing shared code.
MDINote.vbp | The MDInote project file.
Notepad.frm | The MDI child form.

To Run

From the Visual Basic File menu, choose Open Project and select the Mdinote.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


Members Property

Contains identifiers that have module-level scope and can be considered properties, methods, or events of the specified CodeModule object.

Syntax

object.Members

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


MesageReflect Property

MessageReflect Property

Returns a boolean value stating whether the control container handles message reflection automatically.

Syntax

object.MessageReflect

The MessageReflect property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Settings

The possible boolean return values from the MessageReflect property are:

Setting | Description
True | The container for the control will reflect messages.
False | The container for the control cannot reflect messages. If the container does not implement this ambient property, this will be the default value.

Remarks

When a control is subclassed, there are certain messages that are normally sent to the parent control. Under normal conditions, these messages are actually reflected back to the sending control, so that the control can handle its own message. This message reflection can be handled by the container, which will reflect the messages back as events. The MessageReflect property tells if the container for the control does message reflection.

If the control is ever placed in a container that does not reflect messages, the operation of the control will be severely compromised; much of the operation of a control depends on reflected messages.


MinButton Property

Returns a value indicating whether a form has a Minimize button.

Syntax

object.MinButton

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Values

The MinButton return values are:

Setting | Description
True | (Default) The form has a Minimize button.
False | The form doesn't have a Minimize button.

Remarks

A Minimize button enables users to minimize a form window to an icon. To display a Minimize button, you must also set the form's BorderStyle property to either 1 (Fixed Single), 2 (Sizable), or 3 (Fixed Double).

The settings you specify for the MaxButton, MinButton, BorderStyle, and ControlBox properties aren't reflected in the form's appearance until run time.

Note Minimizing a form to an icon at run time generates a Resize event. The WindowState property reflects the current state of the window. If you set the WindowState property to 2 (Maximized), the form is maximized independently of whatever settings are in effect for the MaxButton and BorderStyle properties.


MinHeight, MinWidth Properties

Returns or sets the minimum height or width of the Viewport at which scrollbars will appear on the container.

Syntax

object.MinHeight = single

object.MinWidth = single

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
single | The height or width of a UserDocument at which scrollbars will appear on a container.

Remarks

The default values of the MinHeight and MinWidth properties are set by the Height and Width properties of the UserDocument.

The MinWidth and MinHeight have no effect if the ScrollBars property is set to False.


Minor Property

Returns or sets the minor release number of the project. Read only at run time.

Syntax

object.Minor

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The value of the Minor property is in the range from 0 to 9999.

This property provides version information about the running application.

You can set this property at design time in the Minor box in the Make tab of the Project Properties dialog box.


MiscFlags Property

Returns or sets a value that determines access to one or more additional features of the OLE container control.

Syntax

object.MiscFlags [ = value]

The MiscFlags property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | An integer or constant specifying access to an additional feature, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
VbOLEMiscFlagMemStorage | 1 | Causes the control to use memory to store the object while it's loaded.
VbOLEMiscFlagDisableInPlace | 2 | Overrides the control's default behavior of allowing in-place activation for objects that support it.

Remarks

The vbOLEMiscFlagMemStorage flag setting is faster than the object's default action, which is to store it on disk as a temporary file. This setting can, however, use a great deal of memory for objects whose data requires a lot of space, such as a bitmap for a paint program.

If an object supports in-place activation, you can use the vbOLEMiscFlagDisableInPlace setting to force the object to activate in a separate window.

To combine values, use the Or operator. For example, to combine both flags, you could use this code:

Ole1.MiscFlags = vbOLEMiscFlagMemStorage Or _ vbOLEMiscFlagDisableInPlace


MouseIcon Property

Returns or sets a custom mouse icon.

Syntax

object.MouseIcon = LoadPicture(pathname)

object.MouseIcon [= picture]

The MouseIcon property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
pathname | A string expression specifying the path and filename of the file containing the custom icon.
picture | The Picture property of a Form object, PictureBox control, or Image control.

Remarks

The MouseIcon property provides a custom icon that is used when the MousePointer property is set to 99.

The MouseIcon property provides your program with easy access to custom cursors of any size, with any desired hot spot location. Visual Basic does not load animated cursor (.ani) files, even though 32-bit versions of Windows support these cursors.


MouseIcon Property Example

This example illustrates how the MouseIcon property sets a custom mouse icon. To try the example, create a ListBox control on a form, and then set the MultiSelect property to 1 or 2. At run time, select one or more items. Different icons will appear, depending on whether you selected a single item or multiple items.

Private Sub Form_Load ()
   ' Put some items in the ListBox.
   List1.AddItem "Selection 1"
   List1.AddItem "Selection 2"
   List1.AddItem "Selection 3"
   List1.AddItem "Selection 4"
   List1.AddItem "Selection 5"
End Sub

Private Sub List1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
   ' Set the custom mouse icon for multiple items.
   If List1.SelCount > 1 Then
      List1.MouseIcon = LoadPicture("ICONS\COMPUTER\MOUSE04.ICO")
      List1.MousePointer = 99
   Else   ' Set the custom mouse icon for a single item.
      List1.MouseIcon = LoadPicture("ICONS\COMPUTER\MOUSE02.ICO")
      List1.MousePointer = 99
   End If
End Sub


MousePointer Property

Returns or sets a value indicating the type of mouse pointer displayed when the mouse is over a particular part of an object at run time.

Syntax

object.MousePointer [= value]

The MousePointer property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | An integer specifying the type of mouse pointer displayed, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
vbDefault | 0 | (Default) Shape determined by the object.
vbArrow | 1 | Arrow.
vbCrosshair | 2 | Cross (crosshair pointer).
vbIbeam | 3 | I beam.
vbIconPointer | 4 | Icon (small square within a square).
vbSizePointer | 5 | Size (four-pointed arrow pointing north, south, east, and west).
vbSizeNESW | 6 | Size NE SW (double arrow pointing northeast and southwest).
vbSizeNS | 7 | Size N S (double arrow pointing north and south).
vbSizeNWSE | 8 | Size NW SE (double arrow pointing northwest and southeast).
vbSizeWE | 9 | Size W E (double arrow pointing west and east).
vbUpArrow | 10 | Up Arrow.
vbHourglass | 11 | Hourglass (wait).
vbNoDrop | 12 | No Drop.
vbArrowHourglass | 13 | Arrow and hourglass.
vbArrowQuestion | 14 | Arrow and question mark.
vbSizeAll | 15 | Size all.
vbCustom | 99 | Custom icon specified by the MouseIcon property.

Remarks

You can use this property when you want to indicate changes in functionality as the mouse pointer passes over controls on a form or dialog box. The Hourglass setting (11) is useful for indicating that the user should wait for a process or operation to finish.

Note If your application calls DoEvents, the MousePointer property may temporarily change when over an ActiveX component.


MousePointer Property Example

This example changes the mouse pointer to an hourglass while circles are drawn across the screen and then changes the hourglass back to a pointer at the end of the procedure. To try this example, paste the code into the Declarations section of a form. Press F5 to run the program, and then click the form.

Private Sub Form_Click ()
   Dim I   ' Declare variable.
   ' Change mouse pointer to hourglass.
   Screen.MousePointer = vbHourglass
 ' Set random color and draw circles on form.
   For I = 0 To ScaleWidth Step 50
      ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
      Circle (I, ScaleHeight * Rnd), 400
   Next
   ' Return mouse pointer to normal.   Screen.MousePointer = vbDefault
End Sub


Moveable Property

Returns or sets a value which specifies if the object can be moved.

Syntax

object.Moveable = boolean

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that specifies if the object can be moved.

Settings

The settings for boolean are:

Constant | Value | Description
True | -1 | The object can be moved.
False | 0 | The object cannot be moved.


MSFlexGd (MSFlexGd.vbp)

The MSFlexGd sample application demonstrates the MSFlexGrid control.

File | Description
Flex.frx | Binary information for the Flex.frm file
Flex.frm | The main form which displays the control.
Flex.vbp | The project file for the application.

To Run

From the Visual Basic File menu, choose Open Project and select the MSFlexGd.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.

To cycle through the records, click on the navigation buttons on the Data control. To view either the ListBox or ComboBox controls, click on the appropriate option buttons.


MTSTransactionMode Property

Specifies the transactional behavior of a class. This property is only used by components running in the Microsoft Transaction Server, and has no effect if the component is run outside of the Transaction Server.

Syntax

object.MTSTransactionMode [= value]

The MTSTransactionMode property has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | An integer or constant specifying the transactional behavior of a class.

Settings

The settings for value are:

Constant | Value | Description
NotAnMTSObject | 0 | (Default) The component doesn't support Microsoft Transaction Server.
NoTransactions | 1 | Does not support transactions. This value indicates that the component's objects do not run within the scope of transactions. When a new object is created, its object context is created without a transaction, regardless of whether the client has a transaction.
RequiresTransaction | 2 | This value indicates that the component's objects must execute within the scope of a transaction. When a new object is created, its object context inherits the transaction from the context of the client. If the client does not have a transaction, MTS automatically creates a new transaction for the object.
UsesTransaction | 3 | This value indicates that the component's objects can execute within the scope of their client's transactions. When a new object is created, its object context inherits the transaction from the context of the client. If the client does not have a transaction, the new context is also created without one.
RequiresNewTransaction | 4 | This value indicates that the component's objects must execute within their own transactions. When a new object is created, MTS automatically creates a new transaction for the object, regardless of whether its client has a transaction.

Remarks

The Microsoft Transaction Server uses the MTSTransactionMode property during object creation to determine whether the object should be created to execute within a transaction, and whether a transaction is required or optional.

Most MTS components are declared as either UsesTransactions or RequiresTransaction. These values allow an object to execute within the scope of its client's transaction. You can see the difference between these values when an object is created from a context that does not have a transaction. If the component's transaction attribute is UsesTransactions, the new object runs without a transaction. If it is declared as RequiresTransaction, MTS automatically initiates a transaction for the new object.

Declaring a component as RequiresNewTransaction is similar to using RequiresTransaction in that the component's objects are guaranteed to execute within transactions. However, when you declare the transaction attribute this way, an object never runs inside the scope of its client's transaction. Instead, the system always creates independent transactions for the new objects. For example, you can use this attribute for auditing components that record work done on behalf of another transaction regardless of whether the original transaction commits or aborts.


MultiLine Property

Returns or sets a value indicating whether a TextBox control can accept and display multiple lines of text. Read only at run time.

Syntax

object.MultiLine

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The MultiLine property settings are:

Setting | Description
True | Allows multiple lines of text.
False | (Default) Ignores carriage returns and restricts data to a single line.

Remarks

A multiple-line TextBox control wraps text as the user types text extending beyond the text box.

You can also add scroll bars to larger TextBox controls using the ScrollBars property. If no horizontal scroll bar is specified, the text in a multiple-line TextBox automatically wraps.

Note On a form with no default button, pressing ENTER in a multiple-line TextBox control moves the focus to the next line. If a default button exists, you must press CTRL+ENTER to move to the next line.


MultiSelect Property

Returns or sets a value indicating whether a user can make multiple selections in a FileListBox or ListBox control and how the multiple selections can be made. Read only at run time.

Syntax

object.MultiSelect

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The MultiSelect property settings are:

Setting | Description
0 | (Default) Multiple selection isn't allowed.
1 | Simple multiple selection. A mouse click or pressing the SPACEBAR selects or deselects an item in the list. (Arrow keys move the focus.)
2 | Extended multiple selection. Pressing SHIFT and clicking the mouse or pressing SHIFT and one of the arrow keys (UP ARROW, DOWN ARROW, LEFT ARROW, and RIGHT ARROW) extends the selection from the previously selected item to the current item. Pressing CTRL and clicking the mouse selects or deselects an item in the list.


MultiSelect Property Example

This example fills a ListBox control with the names of your screen fonts and illustrates how the MultiSelect property affects the behavior of a ListBox. To try this example, create two ListBox controls and a CommandButton control on a form. In the first ListBox, set the MultiSelect property to 1 or 2. At run time, select several items in the first ListBox, and then click the CommandButton. All selected items are displayed in the second ListBox. Run the example several times with different settings of the MultiSelect property. Paste the code into the Declarations section, and then press F5 to run the program.

Private Sub Form_Load ()
   Dim I   ' Declare variable.
   ' Fill the list box with screen font names.
   For I = 0 To Screen.FontCount - 1
      List1.AddItem Screen.Fonts(I)
   Next I
End Sub

Private Sub Command1_Click ()
   Dim I   ' Declare variable.
   ' Clear all items from the list.
   List2.Clear
   ' If an item is selected, add it to List2.
   For I = 0 To List1.ListCount - 1
      If List1.Selected(I) Then
         List2.AddItem List1.List(I)
      End If
   Next I
End Sub


Name Property

  • Returns the name used in code to identify a form, control, or data access object. Read-only at run time.

  • Returns or sets the name of a font object.

Syntax

object.Name

The object placeholder represents an object expression that evaluates to an object in the Applies To list. If object is omitted, the form associated with the active form module is assumed to be object.

Remarks

The default name for new objects is the kind of object plus a unique integer. For example, the first new Form object is Form1, a new MDIForm object is MDIForm1, and the third TextBox control you create on a form is Text3.

An object's Name property must start with a letter and can be a maximum of 40 characters. It can include numbers and underline (_) characters but can't include punctuation or spaces. Forms can't have the same name as another public object such as Clipboard, Screen, or App. Although the Name property setting can be a keyword, property name, or the name of another object, this can create conflicts in your code.

You can use a form's Name property with the Dim statement at run time to create other instances of the form. You can't have two forms with the same name at design time.

You can create an array of controls of the same type by setting the Name property to the same value. For example, when you set the name of all option buttons in a group to MyOpt, Visual Basic assigns unique values to the Index property of each control to distinguish it from others in the array. Two controls of different types can't share the same name.

Note Although Visual Basic often uses the Name property setting as the default value for the Caption, LinkTopic, and Text properties, changing one of these properties doesn't affect the others.

Changing the case of the Name property value for a Form or other module without otherwise changing the name itself, however, can cause a “Conflicting names” error message the next time the project containing the form or module is loaded. For example, changing “Form1” to “form1” will cause the error; changing “Form1” to “formX” will not.

The error is caused by the way module names are stored within the project file – the procedure for changing names within the project file isn’t case sensitive, while the procedure for reading names on project load is.


Name Property (DEDesigner Extensibility)

Returns or sets a unique name for each object within the current Data Environment designer. This can be the name of a DEAggregate, DECommand, DEConnection, DEField, or DEParameter object. For DEField objects, this is a read-only property.

The Name property enables you to easily differentiate multiple objects within your DataEnvironment object. Each name must be unique within its domain, as duplicate names result in errors. That is, the names of the DEConnection and DECommand objects must be unique among each other, and the name of a DEAggregate object must be unique among the DEField and other DEAggregate objects.

Syntax

object.Name [=string]

The Name property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that evaluates the name of the DataEnvironment, DEAggregate, DECommand, DEConnection, DEField, or DEParameter object.

Remarks

When you create a DataEnvironment object, its default name is "DataEnvironment" and an integer, such as DataEnvironment1. This default name is similar for the DECommand, DEConnection, and DEAggregate objects. You should set the Name property and provide the object with a meaningful, unique name. For example, if you are a creating a DEConnection object based on the Northwind database, a logical name could be "Northwind." Likewise, if you are creating a DECommand object based on the Customers table, a logical name could be "Customers."


NameInURL Property

Sets the name of the .asp file for the WebClass object.

Syntax

object.NameInURL = [value]

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | Alphanumeric value; the value must be unique across the project and across other projects in the same directory and project group. By default, is set equal to the value of the Name property.

Remarks

The NameinURL property value is the name that will be used in URL references to this WebClass. For example, if you specify CustomerInquiry as the NameinURL property value, the .asp file generated for the webclass will be named CustomerInquiry.asp. In URLs, this would appear as:

http://www.mycompany.com/CustomerSupport/CustomerInquiry.asp

If you change the value of the NameinURL property, the designer will automatically update the URLs in your template that are shown in the Webclass designer's Detail panel. However, if you entered manual notation for a URL in the template, you will have to change the name of the .asp file yourself after you change the value of this property. Any links to the webclass other than those shown in the Detail panel need to be changed manually. These include URLs in other webclasses, .asp files, HTML pages, and client-side script.


Name Property (WebClass, WebItem)

Sets or returns the name used in code to identify a WebClass or WebItem object. Read-only at run time.

Syntax

object.Name = [value]

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | Alphanumeric value; the name must must start with a letter and can be a maximum of 40 characters. It can include numbers and underline (_) characters but can't include punctuation or spaces.

Remarks

The default name for new objects is the type of object plus a unique integer. For example, the first new WebClass object is WebClass1.


Negotiate Property

Sets a value that determines whether a control that can be aligned is displayed when an active object on the form displays one or more toolbars. Not available at run time.

Settings

The Negotiate property has these settings:

Setting | Description
True | If the control is aligned within the form (the Align property is set to a nonzero value), the control remains visible when an active object on the form displays a toolbar.
False | (Default) The control isn't displayed when an active object on the form displays a toolbar. The toolbar of the active object is displayed in place of the control.

Remarks

The Negotiate property exists for all controls with an Align property. You use the Align property to align the control within a Form or MDIForm object; however, the toolbar negotiation occurs only on the MDIForm. The aligned control must be on the MDIForm.

If the NegotiateToolbars property is set to False, the setting of the Negotiate property has no effect.


NegotiateMenus Property

Sets a value that determines whether or not a form incorporates the menus from an object on the form on the form's menu bar. Not available at run time.

Settings

The NegotiateMenus property has these settings:

Setting | Description
True | (Default) When an object on the form is active for editing, the menus of that object are displayed on the form's menu bar.
False | Menus of objects on the form aren't displayed on the form's menu bar.

Remarks

Using the NegotiateMenus property, you determine if the menu bar of a form will share (or negotiate) space with the menus of an active object on the form. If you don't want to include the menus of the active object on the menu bar of your form, set NegotiateMenus to False.

You can't negotiate menus between an MDIForm object and an object on the MDIForm.

If NegotiateMenus is set to True, the form must have a menu bar defined, even if the menu bar isn't visible. If the MDIChild property of the form is set to True, the menus of the active object are displayed on the menu bar of the MDI parent window (MDIForm object).

When NegotiateMenus is set to True, you can use the NegotiatePosition property of individual Menu controls to determine the menus that your form displays along with the menus of the active object.


NegotiatePosition Property

Sets a value that determines whether or not top-level Menu controls are displayed on the menu bar while a linked object or embedded object object on a form is active and displaying its menus. Not available at run time.

Settings

The NegotiatePosition property has these settings:

Setting | Description
0 | (Default) None. The menu isn't displayed on the menu bar when the object is active.
1 | Left. The menu is displayed at the left end of the menu bar when the object is active.
2 | Middle. The menu is displayed in the middle of the menu bar when the object is active.
3 | Right. The menu is displayed at the right end of the menu bar when the object is active.

Remarks

Using the NegotiatePosition property, you determine the individual menus on the menu bar of your form that share (or negotiate) menu bar space with the menus of an active object on the form. Any menu with NegotiatePosition set to a nonzero value is displayed on the menu bar of the form along with menus from the active object.

If the NegotiateMenus property is set to False, the setting of the NegotiatePosition property has no effect.


NegotiateToolbars Property

Sets a value that determines whether the toolbars of an object on an MDI child form are displayed on the MDIForm when the object on the MDI child form is active. Not available at run time.

Settings

The NegotiateToolbars property has these settings:

Setting | Description
True | (Default) The MDIForm object displays the toolbars of the active object on the top or bottom of the MDIForm. The active object determines whether the toolbars are displayed at the top or bottom of the MDIForm.
False | The toolbars of the active object either aren't displayed at all or are displayed as floating tool palettes, as determined by the active object.

Remarks

Use the NegotiateToolbars property when creating a multiple-document interface (MDI) application that includes objects on MDI child forms. With this property, you determine how the active object displays its toolbars. By setting this property to True, the MDIForm shares (or negotiates) space at the top or bottom of the form to display the toolbars of the active object.

If the MDIForm also contains a toolbar, use the Negotiate property to determine how the various toolbars share the available space.


NewIndex Property

Returns the index of the item most recently added to a ComboBox or ListBox control. Read only at run time.

Syntax

object.NewIndex

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You can use this property with sorted lists when you need a list of values that correspond to each item in the ItemData property array. As you add an item in a sorted list, Visual Basic inserts the item in the list in alphabetic order. This property tells you where the item was inserted so that you can insert a corresponding value in the ItemData property at the same index.

The NewIndex property returns -1 if there are no items in the list or if an item has been deleted since the last item was added.


NextItem Property

Returns another WebItem object within the current WebClass object. Used to shift processing from one WebItem to another during a single request.

Syntax

object.NextItem

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Prior to firing events within a WebClass, this property is set to Nothing. On completion of an event procedure, if the property is set to another WebItem in the WebClass, the Respond event for that WebItem is fired. This property can be used in the Start event of the WebClass to display the initial WebItem. The value of NextItem is ignored for the following events:

  • EndRequest

  • ProcessTag

  • FatalErrorResponse


NonModalAllowed Property

Returns a value which indicates if a form can be shown non-modally (modeless). Not available at design-time.

Syntax

object.nonModalAllowed

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Type

Boolean


NullValue Property

Sets or returns a value used to format and unformat Null values. Read/write both at design time and run time.

Syntax

object.NullValue [= value]

The NullValue property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | Optional Variant. When formatting occurs, if the data is a Null, value is returned. When data is returned to the database, if the data matches value, a Null is written.

Remarks

Ignored when the Type property is set to fmtGeneral. The NullValue property is read each time a null field is fetched.


NumericScale Property

Returns or sets the maximum number of digits to the right of the decimal point for the DEField or DEParameter object. This property is read-only for the DEField object, is read-write for the DEParameter object, and applies only to numeric DEField and DEParameter objects.

Syntax

object.NumericScale [=number]

The NumericScale property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
number | A Long expression that specifies the maximum number of digits to the right of the decimal point for the DEField or DEParameter object.

Remarks

This property corresponds to the ADO Field or Parameter NumericScale properties.


ObjectAcceptFormatsCount Property

Returns the number of formats that can be accepted by an object.

Syntax

object.ObjectAcceptFormatsCount

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

Use this property to get the number of elements in the ObjectAcceptFormats property array.


ObjectAcceptFormats Property

Returns the list of formats an object can accept.

Syntax

object.ObjectAcceptFormats(number)

The ObjectAcceptFormats property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression that evaluates to an integer indicating the element in the array.

Remarks

The list is a zero-based string array. Elements of the array can be used to set the Format property when getting data from an object using the Data and DataText properties.


ObjectAcceptFormats, ObjectAcceptFormatsCount, ObjectGetFormats, ObjectGetFormatsCount, ObjectVerbs, ObjectVerbsCount Properties Example

To run this example, place an OLE container control and three ListBox controls on a form. Paste the example code into the Declarations section of the form and press F5. When the Insert Object dialog box is displayed, select an application in the New Object list box and choose OK to create an object.

Private Sub Form_Click ()
   Dim I   ' Declare variable.
   ' Display the Insert Object dialog box.
   Ole1.InsertObjDlg
   ' Update the list of available verbs.
   Ole1.FetchVerbs   ' Fetch verbs.
   ' Clear the list boxes.
   List1.Clear
   List2.Clear
   List3.Clear
   ' Fill the verbs list box. Because ObjectVerbs(0) is
   ' the default verb and is repeated in the ObjectVerbs()
   ' array, start the count at 1.
   For I = 1 To Ole1.ObjectVerbsCount - 1
      List1.AddItem Ole1.ObjectVerbs(I)
   Next I
   'Fill the Accept Formats list box.
   For I = 0 To Ole1.ObjectAcceptFormatsCount - 1
      List2.AddItem Ole1.ObjectAcceptFormats(I)
   Next I
   ' Fill the Get Formats list box.
   For I = 0 To Ole1.ObjectGetFormatsCount - 1
      List3.AddItem Ole1.ObjectGetFormats(I)
   Next I
End Sub


Object Property

Returns a reference to a property or method of a control which has the same name as a property or method automatically extended to the control by Visual Basic.

Syntax

object.Object[.property | .method]

The Object property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
property | Property of the control that is identical to the name of a Visual Basic-supplied property.
Method | Method of the control that is identical to the name of a Visual Basic-supplied method.

Remarks

Note The Object property returns the object which is the basis for the control without the properties or methods automatically extended to the control by Visual Basic. Therefore, you can also reference the controls' "custom" properties and methods through the Object property, such as Print SSTab1.Object.Tabs.

Visual Basic supplies some or all of a standard set of properties and methods to controls in a Visual Basic project. It is possible for a control or ActiveX component (such as Microsoft Excel or Microsoft Word) to define a property or method which has the same name as one of these standard properties or methods. When this occurs, Visual Basic automatically uses the property or method it supplies instead of the one with the same name defined in the control. The Object property allows you to bypass the Visual Basic-supplied property or method and use the identically named property or method defined in the control.

For example, the Tag property is a property supplied to all controls in a Visual Basic project. If a control in a project has the name ctlDemo, and you access the Tag property using this syntax:

ctlDemo.Tag

Visual Basic automatically uses the Tag property it supplies. However, if the control defines its own Tag property and you want to access that property, you use the Object property in this syntax:

ctlDemo.Object.Tag

Visual Basic automatically extends some or all of the following properties, methods, and events to controls in a Visual Basic project:

Properties |  |
Align | Height | Object
Binding | HelpContextID | Parent
Bindings | Index | TabIndex
Cancel | Left | TabStop
Container | LeftNoRun | TagParent
DataChanged | LinkItem | ToolTipText
DataField | LinkMode | Top
DataSource | LinkTimeout | TopNoRun
Default | LinkTopic | VisibleTabStop
DragIcon | Name | WhatsThisHelpID
DragMode | NegotiateLinkItem | Width

Methods |  |
Drag | LinkSend | ShowWhatsThis
LinkExecute | Move | Zorder
LinkPoke | Refresh |
LinkRequest | SetFocus |

Events |  |
GotFocus | LinkError | LinkOpen
LinkClose | LinkNotify | LostFocus

If you use a property or method of a control and don't get the behavior you expect, check to see if the property or method has the same name as one of those shown in the preceding list. If the names match, check the documentation provided with the control to see if the behavior matches the Visual Basic-supplied property or method. If the behaviors aren't identical, you may need to use the Object property to access the feature of the control that you want.


ObjectGetFormats Property

Returns the list of formats an object can provide.

Syntax

object.ObjectGetFormats(number)

The ObjectGetFormats property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression indicating the element in the array.

Remarks

The list is a zero-based string array. Elements of the array can be used to set the Format property when getting data from an object using the Data and DataText properties.


ObjectGetFormatsCount Property

Returns the number of formats an object can provide.

Syntax

object.ObjectGetFormatsCount

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

Use this property to determine the number of elements in the ObjectGetFormats property array.


TargetObject Property

Returns the bound object, or another object as determined by the bound control. Read-only at run time.

Syntax

object.TargetObject

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

The TargetObject property provides access in the Format and Unformat events to the bound control's properties, methods, and events. If the bound control passes an object other than the control itself, you can use its properties, methods, and events to manipulate data or navigate up the hierarchy to other objects in the control's object model.


Object Property (OLE Container)

Returns the object and/or a setting of an object's method or property in an OLE container control.

Syntax

object.Object[.property | .method]

The Object property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Property | Property that the object supports.
Method | Method that the object supports.

Remarks

Use this property to specify an object you want to use in an Automation task.

You use the object returned by the Object property in an Automation task by using the properties and methods of that object. For information on which properties and methods an object supports, see the documentation for the application that created the object.


ObjectVerbFlags Property

Returns the menu state (such as enabled or disabled, checked, and so on) for each verb in a given ObjectVerbs array.

Syntax

object.ObjectVerbFlags(number)

The ObjectVerbFlags property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | A numeric expression indicating the element in the array.

Return Values

The ObjectVerbFlags property returns the following values:

Constant | Value | Description
VbOLEFlagChecked | &H0008 | The menu item is checked.
VbOLEFlagDisabled | &H0002 | The menu item is disabled (but not dimmed).
VbOLEFlagEnabled | &H0000 | The menu item is enabled.
VbOLEFlagGrayed | &H0001 | The menu item is dimmed.
VbOLEFlagSeparator | &H0800 | The menu item is a separator bar.

Note These constants are also listed in the Visual Basic objects and procedures library in the Object Browser.

Remarks

The first verb in the ObjectVerbs array is the default verb. The ObjectVerbFlags array contains information about the menu state (such as dimmed, checked, and so on) for each verb in the ObjectVerbs array.

When displaying a menu containing an object's verbs, check the value of this property to see how the item is set to be displayed.


ObjectVerbs Property

Returns the list of verbs an object supports.

Syntax

object.ObjectVerbs(number)

The ObjectVerbs property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression indicating the element in the array.

Remarks

ObjectVerbs is a zero-based string array. Use this property along with the ObjectVerbsCount property to get the verbs supported by an object. These verbs are used to determine an action to perform when an object is activated with the DoVerb method. The list of verbs in the array varies from object to object and depends on the current conditions.

Each object can support its own set of verbs. The following values represent standard verbs supported by every object:

Constant | Value | Description
vbOLEPrimary | 0 | The default action for the object.
vbOLEShow | -1 | Activates the object for editing. If the application that created the object supports in-place activation, the object is activated within the OLE container control.
vbOLEOpen | -2 | Opens the object in a separate application window. If the application that created the object supports in-place activation, the object is activated in its own window.
vbOLEHide | -3 | For embedded objects, hides the application that created the object.
vbOLEUInPlaceUIActivate | -4 | If the object supports in-place activation, activates the object for in-place activation and shows any user interface tools. If the object doesn't support in-place activation, the object doesn't activate, and an error occurs.
vbOLEInPlaceActivate | -5 | If the user moves the focus to the OLE container control, creates a window for the object and prepares the object to be edited. An error occurs if the object doesn't support activation on a single mouse click.
vbOLEDiscardUndoState | -6 | Used when the object is activated for editing to discard all record of changes that the object's application can undo.

Note These verbs may not be listed in the ObjectVerbs property array.

The first verb in the ObjectVerbs array, ObjectVerbs(0), is the default verb. Unless otherwise specified, this verb activates the object.

The remaining verbs in the array can be displayed on a menu. If it's appropriate to display the default verb in a menu, the default verb has two entries in the ObjectVerbs array.

Applications that display objects typically include an Object command on the Edit menu. When the user chooses Edit Object, a menu displays the object's verbs. Use the ObjectVerbs, ObjectVerbsCount, and ObjectVerbFlags properties to create such a menu at run time.

The list of verbs an object supports may vary, depending on the state of the object. To update the list of verbs an object supports, use the FetchVerbs method. Be sure to update the list of verbs before presenting it to the user.

To automatically display the verbs in the ObjectVerbs array in a pop-up menu when the user clicks an object with the right mouse button, set the AutoVerbMenu property to True.


ObjectVerbsCount Property

Returns the number of verbs supported by an object.

Syntax

object.ObjectVerbsCount

The object is an object expression that evaluates to an OLE container control.

Remarks

Use this property to determine the number of elements in the ObjectVerbs property array.

The list of verbs an object supports may vary, depending on the state of the object. To update the list of verbs an object supports, use the FetchVerbs method.


OleCont (OleCont.vbp)

This sample application demonstrates the capabilities of the OLE Container control. The sample allows you to save or open OLE objects using the SaveToFile and ReadFromFile methods. For more information, see "Using the OLE Container Control," in the Programmer's Guide.

File | Description
Contchld.frm. | An MDI child form containing the OLE Container control
Contmdi.frm | The main form.
Olecont.bas | Module containing Public Sub and Function procedures.
Colecont.vbp | The project file for this sample.

To Run

From the Visual Basic File menu, choose Open Project and select the Olecont.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


OLEDragMode Property

Returns or sets whether the component or the programmer handles an OLE drag/drop operation.

Syntax

object.OLEDragMode = mode

The OLEDragMode property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Mode | An integer which specifies the method with which an component handles OLE drag/drop operations, as described in Settings.

Settings

The settings for mode are:

Constant | Value | Description
VbOLEDragManual | 0 | (Default) Manual. The programmer handles all OLE drag/drop operations.
VbOLEDragAutomatic | 1 | Automatic. The component handles all OLE drag/drop operations.

Remarks

When OLEDragMode is set to Manual, you must call the OLEDrag method to start dragging, which then triggers the OLEStartDrag event.

When OLEDragMode is set to Automatic, the source component fills the DataObject object with the data it contains and sets the effects parameter before initiating the OLEStartDrag event (as well as the OLESetData and other source-level OLE drag/drop events) when the user attempts to drag out of the control. This gives you control over the drag/drop operation and allows you to intercede by adding other formats, or by overriding or disabling the automatic data and formats using the Clear or SetData methods.

If the source’s OLEDragMode property is set to Automatic, and no data is loaded in the OLEStartDrag event, or aftereffects is set to 0, then the OLE drag/drop operation does not occur.

Note If the DragMode property of a control is set to Automatic, the setting of OLEDragMode is ignored, because regular Visual Basic drag and drop events take precedence.


OLEDropAllowed Property

Returns or sets a value that determines whether an OLE container control can be a drop target for OLE drag-and-drop operations.

Syntax

object.OLEDropAllowed [= boolean]

The OLEDropAllowed property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying whether the OLE container control can be a drop target, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | When dragging an object that can be linked object or embedded object, a drop icon appears when the mouse pointer moves over the OLE container control. Dropping the object on the OLE container control has the same effect as pasting the object from the system Clipboard using the Paste method.
False | (Default) No drop icon appears over the OLE container control when dragging an object that can be linked or embedded. Dropping the object on the OLE container control has no effect on the control.

Remarks

The MousePointer property determines the shape of the mouse pointer when the OLEDropAllowed property is set to True. If the setting of the MousePointer property is 0 (Default), Visual Basic displays the standard drag-and-drop icon for the action taking place.

The setting of the OLETypeAllowed property must be 1 (vbOLEEmbedded) or 2 (vbOLEEither) to move or copy the object that can be linked or embedded, or 0 (vbOLELinked) or 2 to link the object. Dropping an object when OLEDropAllowed is set to True has the same effect on the Class, SourceDoc, and SourceItem property settings as using the Paste method of the OLE container control.

If the OLEDropAllowed property is set to True, the OLE container control doesn't receive DragDrop or DragOver events when dragging an object. Also, the setting of the DragMode property has no effect on the drag-and-drop behavior of the OLE container control when the OLEDropAllowed property is set to True.


OLEDropMode Property

Returns or sets how a target component handles drop operations.

Syntax

object.OLEDropMode [= mode]

The OLEDropMode property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
mode | An enumerated integer which specifies the method which a component handles OLE drag/drop operations, as described in Settings.

Settings

The settings for mode are:

Constant | Value | Description
vbOLEDropNone | 0 | (Default) None. The target component does not accept OLE drops and displays the No Drop cursor.
vbOLEDropManual | 1 | Manual. The target component triggers the OLE drop events, allowing the programmer to handle the OLE drop operation in code.
vbOLEDropAutomatic | 2 | Automatic. The target component automatically accepts OLE drops if the DataObject object contains data in a format it recognizes. No mouse or OLE drag/drop events on the target will occur when OLEDropMode is set to vbOLEDropAutomatic.

Remarks

Note The target component inspects what is being dragged over it in order to determine which events to trigger; the OLE drag/drop events, or the Visual Basic drag/drop events. There is no collision of components or confusion about which events are fired, since only one type of object can be dragged at a time.


OLERequestPendingMsgText Property

Returns or sets the text of the alternate "busy" message displayed when mouse or keyboard input is received while an automation request is pending. Not available at design time.

Syntax

object.OLERequestPendingMsgText [ = string]

The OLERequestPendingMsgText property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | A string expression that evaluates to the message text that will be displayed in the alternate message box for the ActiveX request pending condition.

Remarks

Visual Basic displays a default Component Request Pending dialog box when mouse or keyboard input is received while an automation request is pending. This dialog box includes text and a Switch To button which are intended for use with visible ActiveX components such as Microsoft Excel. There are situations in which the default dialog box may not meet your needs:

  • Your program may call a method of an object provided by an ActiveX component that has no user interface. ActiveX components created using Visual Basic Professional edition, for example, may run in the background without any visible forms.

  • The ActiveX component you call may have been created using the Remote Automation features of Visual Basic, Enterprise edition, and may be running on another computer located at some distance from the user.

  • If your program has loaded a Microsoft Excel workbook using the GetObject function, the workbook will not be visible when the user switches to Microsoft Excel. In fact, Microsoft Excel itself may not be visible, in which case the Switch To button does nothing.

In these situations, the default text and Switch To button are inappropriate and may confuse the user of your program.

The OLERequestPendingMsgText property allows you to replace the default Component Request Pending dialog box with an alternate message box. Setting OLERequestPendingMsgText to your own message string causes the default Component Request Pending dialog box to be replaced by a simple message box containing your message text and an OK button.

Note Once an automation request has been accepted by an ActiveX component, there is no way to cancel it.

If OLERequestPendingMsgText is equal to an empty string (""), the default Component Request Pending dialog is displayed.

Important When you know that an automation request may take more than a few seconds, and you are using a hidden or remote ActiveX component, you should set an alternate message. For remote ActiveX components, the alternate message is recommended for all requests. Network traffic may occasionally cause even a very short ActiveX request to take several seconds.


OLERequestPendingMsgTitle Property

Returns or sets the caption of the alternate "busy" message displayed when mouse or keyboard input is received while an automation request is pending. Not available at design time.

Syntax

object.OLERequestPendingMsgTitle [= string]

The OLERequestPendingMsgTitle property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | A string expression that evaluates to the caption of the alternate message box for the ActiveX request pending condition.

Remarks

If the OLERequestPendingMsgText property has been set, the value of the OLERequestPendingMsgTitle property is used as the caption of the alternate "busy" message box that replaces the default Component Request Pending dialog box. The default value of the OLERequestPendingMsgTitle property is the current value of the Title property of the App object. This is the recommended setting.

If the OLERequestPendingMsgText property is set to an empty string (""), the OLERequestPendingMsgTitle property is ignored.


OLERequestPendingTimeout Property

Returns or sets the number of milliseconds that must elapse before the Component Request Pending dialog box (or an alternate message) can be triggered by mouse or keyboard input received while an automation request is pending. Not available at design time.

Syntax

object.OLERequestPendingTimeout [= milliseconds]

The OLERequestPendingTimeout property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
milliseconds | A Long integer representing the number of milliseconds that must elapse before a busy message can be triggered.

Remarks

The default value of this property is 5000 milliseconds (five seconds).

Important This time-out value also affects documents you link or embed using the OLE Container control or the Toolbox. If you are using linked or embedded documents and you change this property before an automation request, it is a good idea to reset the value afterward.


OLEServerBusyMsgText Property

Returns or sets the text of the alternate "busy" message which is displayed in place of the default Component Busy dialog if an ActiveX component rejects an automation request. Not available at design time.

Syntax

object.OLEServerBusyMsgText [= string]

The OLEServerBusyMsgText property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | A string expression that evaluates to the message text that will be displayed in the alternate message box for the ActiveX component busy condition.

Remarks

Visual Basic continues to retry an automation request for the number of milliseconds specified by the OLEServerBusyTimeout property. If the ActiveX component has not accepted the request in that interval, Visual Basic displays a default Component Busy dialog box. This dialog box includes text and a Switch To button which are intended for use with visible ActiveX components such as Microsoft Excel. There are situations in which the default dialog box may not meet your needs:

  • Your program may call a method of an object provided by an ActiveX component that has no user interface. ActiveX components created using Visual Basic Professional edition, for example, may run in the background without any visible forms.

  • The ActiveX component you call may have been created using the Remote automation features of Visual Basic, Enterprise edition, and may be running on another computer located at some distance from the user.

  • If your program has loaded a Microsoft Excel workbook using the GetObject function, the workbook will not be visible when the user switches to Microsoft Excel. In fact, Microsoft Excel itself may not be visible, in which case the Switch To button does nothing.

In these situations, the default text and Switch To button are inappropriate and may confuse the user of your program.

The OLEServerBusyMsgText property allows you to replace the default Component Busy dialog box with an alternate message box. Setting OLEServerBusyMsgText to your own message string causes the default Component Busy dialog box to be replaced by a simple message box containing your message text, an OK button, and a Cancel button.

If OLERequestPendingMsgText is equal to an empty string (""), the default Component Busy dialog is displayed.

If the user presses the Cancel button of the default Component Busy dialog box or the alternate message box, the ActiveX error -2147418111 (&H80010001) is raised in the procedure that made the automation request.

Important When you know that an automation request may take more than a few seconds and you are using a hidden or remote ActiveX component, you should set an alternate message. For remote ActiveX components, the alternate message is recommended for all requests. Network traffic may occasionally cause even a very short ActiveX request to take several seconds.


OLEServerBusyMsgTitle Property

Returns or sets the caption of the alternate "busy" message which is displayed when an ActiveX component rejects an automation request. Not available at design time.

Syntax

object.OLEServerBusyMsgTitle [= string]

The OLEServerBusyMsgTitle property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | A string expression that evaluates to the caption of the alternate message box for the ActiveX component busy condition.

Remarks

If the OLEServerBusyMsgText property has been set, the value of the OLEServerBusyMsgTitle property is used as the caption of the alternate busy message that replaces the default Component Busy dialog box. The default value of the OLEServerBusyMsgTitle property is the current value of the Title property of the App object. This is the recommended setting.

If the OLEServerBusyMsgText property is set to an empty string (""), the OLEServerBusyMsgTitle property is ignored.


OLEServerBusyRaiseError Property

Determines whether a rejected automation request raises an error, instead of displaying the default Component Busy dialog box or an alternate message. Not available at design time.

Syntax

object.OLEServerBusyRaiseError [ = boolean]

The OLEServerBusyRaiseError property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that specifies whether an error is to be raised, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default) An error is raised when the number of milliseconds specified by the OLEServerBusyTimeout property have elapsed.
False | Depending on the setting of the OLEServerBusyMsgText property, either the default Server Busy dialog box or an alternate busy message will be displayed.

Remarks

Raising an error when an ActiveX component rejects an automation request returns control to your program, which allows you to provide your own custom dialog box in place of either the default Component Busy dialog box or the alternate busy message.

The automation error that will be raised is -2147418111 (&H80010001).


OLEServerBusyTimeout Property

Returns or sets the number of milliseconds during which an automation request will continue to be retried, before the default Component Busy dialog box (or an alternate message) is displayed. Not available at design time.

Syntax

object.OLEServerBusyTimeout [= milliseconds]

The OLEServerBusyTimeout property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
milliseconds | A Long integer representing the number of milliseconds during which an automation request will be retried.

Remarks

The default value of this property is 10000 milliseconds (ten seconds).

Important This time-out value also affects documents you link or embed using the OLE Container control or the Toolbox. If you are using linked or embedded documents and you change this property before an automation request, it is a good idea to reset the value afterward.


OLEType Property

Returns the status of the object in an OLE container control.

Syntax

object.OLEType

The object is an object expression that evaluates to an object in the Applies To list.

Return Values

The OLEType property returns the following values:

Constant | Value | Description
vbOLELinked | 0 | Linked. The OLE container control contains a linked object. All the object's data is managed by the application that created it. When the object is saved using the SaveToFile method, only link information such as SourceDoc, SourceItem, and so on is saved in the specified file by your Visual Basic application.
vbOLEEmbedded | 1 | Embedded. The OLE container control contains an embedded object. All the object's data is managed within the Visual Basic application. When the object is saved using the SaveToFile method, all data associated with the object is saved in the specified file.
vbOLENone | 3 | None. The OLE container control doesn't contain an object.

Remarks

Use this property to determine if the OLE container control contains an object or to determine the type of object the OLE container control contains.

Use the AppIsRunning property to determine if the application that created the object is running.

When creating an object, use the OLETypeAllowed property to determine the type of object that can be created.


OLETypeAllowed Property

Returns or sets the type of object the OLE container control can contain.

Syntax

object.OLETypeAllowed [ = value]

The OLETypeAllowed property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | An integer or constant that specifies the type of object, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
VbOLELinked | 0 | Linked. The OLE container control can contain only a linked object.
VbOLEEmbedded | 1 | Embedded. The OLE container control can contain only an embedded object.
VbOLEEither | 2 | (Default) Either. The OLE container control can contain either a linked or an embedded object.

Remarks

This property determines the type of object a user can create:

  • When using the Insert Object dialog box, use the InsertObjDlg method to display this dialog box.

  • When using the Paste Special dialog box, use the PasteSpecialDlg method to display this dialog box.

  • When pasting an object from the system Clipboard, use the Paste method to paste objects from the system Clipboard.

Use the OLEType property to determine an object's type (linked, embedded, or none).


Optimize (Optimize.vbp)

This sample application demonstrates several optimization techniques for Visual Basic. Speed comparisons are made between various coding techniques to illustrate performance differences.

Background

The sample is comprised of several forms, each demonstrating optimized and non-optimized code. When running this sample, it’s a good idea to shut down any other running applications in order to get accurate timings. For more information, see "Designing for Performance and Compatibility," in the Programmer's Guide.

File | Description
About.frm | About box form for application.
About.frx | Binary data file for the ABOUT.FRM file.
Algorith.frm | Form demonstrating algorithms for drawing.
Code.frm | Form demonstrating code optimizations.
Collection.frm | Form demonstrating optimizations for collections.
Explore.frm | The main form for the sample application with an Explorer style interface.
Explore.frx | Binary data file for the EXPLORE.FRM file.
Frmimage.frm | Auxiliary form for the Splash Screen demonstration.
Frmimage.frx | Binary data file for the FRMIMAGE.FRM file.
FrmPics.frm | Form demonstrating optimizations for displaying images.
FrmPics.frx | Binary data file for the FRMPICS.FRM file.
FrmShow1.frm | Form demonstrating optimizations for forms.
FrmShow2.frm | Auxiliary form demonstrating optimizations for forms.
Global.bas | Module containing shared code.
Graphics.frm | Form demonstrating optimizations for graphics methods.
Graphics.frx | Binary data file for the GRAPHICS.FRM file.
Numbers.frm | Form demonstrating data type optimizations.
Optimize.vbp | Project file for this application.
Paintpic.frm | Form demonstrating painting optimizations.
Paintpic.frx | Binary data file for the PAINTPIC.FRM file.
Splash.frm | Sample splash screen.
Splash.frx | Binary data file for the SPLASH.FRM file.
Splshdmo.frm | Form demonstrating startup optimizations.
Strings.frm | Form demonstrating string handling optimizations

To Run

From the Visual Basic File menu, choose Open Project and select the Optimize.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


Options Property

Returns or sets a value that specifies one or more characteristics of the Recordset object in the control's Recordset property.

Syntax

object.Options [ = value ]

The Options property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A constant or value that specifies a characteristic of a Recordset, as described in Settings.

Settings

Use one or more of the following values to set the Options property. If you use more than one option, you must add their values:

Constant | Value | Description
dbDenyWrite | 1 | In a multi-user environment, other users can't make changes to records in the Recordset.
dbDenyRead | 2 | In a multi-user environment, other users can't read records (table-type Recordset only).
dbReadOnly | 4 | You can't make changes to records in the Recordset.
dbAppendOnly | 8 | You can add new records to the Recordset, but you can't read existing records.
dbInconsistent | 16 | Updates can apply to all fields of the Recordset, even if they violate the join condition.
dbConsistent | 32 | (Default) Updates apply only to those fields that don't violate the join condition.
dbSQLPassThrough | 64 | When using Data controls with an SQL statement in the RecordSource property, sends the SQL statement to an ODBC database, such as a SQL Server or Oracle database, for processing.
dbForwardOnly | 256 | The Recordset object supports forward-only scrolling. The only move method allowed is MoveNext. This option cannot be used on Recordset objects manipulated with the Data control.
dbSeeChanges | 512 | Generate a trappable error if another user is changing data you are editing.

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

If you change the Options property at run time, you must use the Refresh method for the change to have any effect.

In the Professional and Enterprise Editions, this property corresponds to the options argument in the OpenRecordset method.

To set more than one value for this property, you can combine options by adding values together. For example, to set both dbAppendOnly and dbInconsistent you can use this code:

Data1.Options = dbAppendOnly + dbInconsistent

To determine if the property contains a specific value, you can use the And operator. For example, to find out if the Recordset is open for read-only access, you could use this code:

If Data1.Options And dbReadOnly Then...

Using both dbInconsistent and dbConsistent results in consistent updates, the default for Recordset objects.

Note The dbSQLPassThrough option can only be used when creating dynaset- or snapshot-type Recordset objects and is supported only to provide compatibility with previous versions. For better performance and functionality, you should use a previously created SQL PassThrough QueryDef object and set the Data control's Recordset property to a Recordset object created with the QueryDef.

Note If you attempt to access a SQL Server 6.0 table that includes an identity column, you can trigger an erroneous 3622 error. To prevent this problem, use the dbSeeChanges option with the Options property or OpenRecordset method.

Data Type

Integer


Orientation Property

Returns or sets a value indicating whether documents are printed in portrait or landscape mode. Not available at design time.

Syntax

object.Orientation [= value]

The Orientation property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A value or constant that determines the page orientation, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
vbPRORPortrait | 1 | Documents are printed with the top at the narrow side of the paper.
vbPRORLandscape | 2 | Documents are printed with the top at the wide side of the paper.

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

Note The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may or may not produce an error. For more information, see the manufacturer's documentation for the specific driver.


HasDC Property

Returns or sets a value that determines whether a unique display context (or hDC) is allocated to a control.

Syntax

object.HasDC [ = boolean]

The HasDC property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that specifies whether an hDC is allocated to a control.

Settings

The settings for boolean are:

Setting | Description
True | (Default) An hDC is allocated to the control.
False | No hDC is allocated to the control.

Remarks

If you set the HasDC property to False, you should copy the hDC of the control only into a local variable. Calling APIs with an hDC obtained outside of the scope of an event can cause crashes or other unpredictable results.

For windowless UserControls, the HasDC property will only take effect if the UserControl is created with a window (i.e., it's in a container that doesn't support windowless activation, such as Visual Basic version 4.0 or Internet Explorer version 3.0). Windowless UserControls that are activated windowless never have their own hDC, and therefore ignore the value of their HasDC property.


Page Property

Returns the current page number.

Syntax

object.Page

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Visual Basic keeps a count of pages that have been printed since your application started or since the last time the EndDoc statement was used on the Printer object. This count starts at one and increases by one if:

  • You use the NewPage method.

  • You use the Print method and the text you want to print doesn't fit on the current page.

Note Graphics methods output that doesn't fit on the page doesn't generate a new page. The output is clipped to fit the page's printable area.


{bmr copyprnt.mrb}Page Property Example

Page Property Example

This example prints three pages of text with the current page number at the top of each page. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   Dim Header, I, Y   ' Declare variables.
   Print "Now printing..."   ' Put notice on form.
   Header = "Printing Demo - Page "   ' Set header string.
   For I = 1 To 3
      Printer.Print Header;   ' Print header.
      Printer.Print Printer.Page   ' Print page number.
      Y = Printer.CurrentY + 10   ' Set position for line.
      ' Draw a line across page.
      Printer.Line (0, Y) - (Printer.ScaleWidth, Y)   ' Draw line.
      For K = 1 To 50
         Printer.Print String(K, " ");   ' Print string of spaces.
         Printer.Print "Visual Basic ";   ' Print text.
         Printer.Print Printer.Page   ' Print page number.
      Next
      Printer.NewPage
   Next I
   Printer.EndDoc
   End
End Sub


PaletteMode Property

Returns or sets a value that determines which palette to use for the controls on a object.

Syntax

object.PaletteMode = integer

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
integer | Determines the palette mode to be used, as described in Settings, below.

Settings

The settings for integer are:

Constant | Value | Description
vbPaletteModeHalfTone | 0 | (Default) Use the Halftone palette.
vbPaletteModeUseZOrder | 1 | Use the palette from the topmost control that has a palette.
vbPaletteModeCustom | 2 | Use the palette specified in the Palette property.
vbPaletteModeContainer | 3 | Use the container's palette for containers that support ambient Palette property. Applies to UserControls only.
vbPaletteModeNone | 4 | Do not use any palette. Applies to UserControls only.
vbPaletteModeObject | 5 | Use the ActiveX designer’s palette. (Applies only to ActiveX designers which contain a palette.)

Remarks

If no palette is available, the halftone palette becomes the default palette.

Note For previous versions of Visual Basic, PaletteMode corresponded to UseZOrder.


Palette Property

Returns or sets an image that contains the palette to use for the control.

Syntax

object.Palette = path

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
path | The path of the bitmap image containing the palette to be used.

Remarks

You can use a .dib, .gif, or .bmp file to set the palette.


PalMode (Palettes.vbp)

This sample application demonstrates the effects of different PaletteMode settings on 256 color images. It also provides an introduction to the Picture object.

Background

This sample is comprised of a single form for displaying images. In order to see the effects of the PaletteMode property, it is necessary to run this sample on a display set to 256 color mode. For more information, see "Working with Text and Graphics," in the Programmer's Guide.

File | Description
Banner.gif | GIF image file.
Clouds.bmp | Bitmap image file.
Forest.jpg | JPG image file.
Palettes.frm | Main form for application.
Palettes.frx | Binary data file for the Palettes.frm file.
Palettes.vbp | The Palettes project file.

To Run

From the Visual Basic File menu, choose Open Project and select the Palettes.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


PaperBin Property

Returns or sets a value indicating the default paper bin on the printer from which paper is fed when printing. Not available at design time.

Syntax

object.PaperBin [= value]

The PaperBin property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A value or constant specifying the default paper bin, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
vbPRBNUpper | 1 | Use paper from the upper bin.
vbPRBNLower | 2 | Use paper from the lower bin.
vbPRBNMiddle | 3 | Use paper from the middle bin.
vbPRBNManual | 4 | Wait for manual insertion of each sheet of paper.
vbPRBNEnvelope | 5 | Use envelopes from the envelope feeder.
vbPRBNEnvManual | 6 | Use envelopes from the envelope feeder, but wait for manual insertion.
vbPRBNAuto | 7 | (Default) Use paper from the current default bin.
vbPRBNTractor | 8 | Use paper fed from the tractor feeder.
vbPRBNSmallFmt | 9 | Use paper from the small paper feeder.
vbPRBNLargeFmt | 10 | Use paper from the large paper bin.
vbPRBNLargeCapacity | 11 | Use paper from the large capacity feeder.
vbPRBNCassette | 14 | Use paper from the attached cassette cartridge.

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

Not all of the bin options are available on every printer. Check the printer documentation for more specific descriptions of these options.

Note The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may or may not produce an error. For more information, see the manufacturer's documentation for the specific driver.


PaperSize Property

Returns or sets a value indicating the paper size for the current printer. Not available at design time.

Syntax

object.PaperSize [= value]

The PaperSize property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A value or constant specifying the paper size, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
vbPRPSLetter | 1 | Letter, 8 1/2 x 11 in.
vbPRPSLetterSmall | 2 | Letter Small, 8 1/2 x 11 in.
vbPRPSTabloid | 3 | Tabloid, 11 x 17 in.
vbPRPSLedger | 4 | Ledger, 17 x 11 in.
vbPRPSLegal | 5 | Legal, 8 1/2 x 14 in.
vbPRPSStatement | 6 | Statement, 5 1/2 x 8 1/2 in.
vbPRPSExecutive | 7 | Executive, 7 1/2 x 10 1/2 in.
vbPRPSA3 | 8 | A3, 297 x 420 mm
vbPRPSA4 | 9 | A4, 210 x 297 mm
vbPRPSA4Small | 10 | A4 Small, 210 x 297 mm
vbPRPSA5 | 11 | A5, 148 x 210 mm
vbPRPSB4 | 12 | B4, 250 x 354 mm
vbPRPSB5 | 13 | B5, 182 x 257 mm
vbPRPSFolio | 14 | Folio, 8 1/2 x 13 in.
vbPRPSQuarto | 15 | Quarto, 215 x 275 mm
vbPRPS10x14 | 16 | 10 x 14 in.
vbPRPS11x17 | 17 | 11 x 17 in.
vbPRPSNote | 18 | Note, 8 1/2 x 11 in.
vbPRPSEnv9 | 19 | Envelope #9, 3 7/8 x 8 7/8 in.
vbPRPSEnv10 | 20 | Envelope #10, 4 1/8 x 9 1/2 in.
vbPRPSEnv11 | 21 | Envelope #11, 4 1/2 x 10 3/8 in.
vbPRPSEnv12 | 22 | Envelope #12, 4 1/2 x 11 in.
vbPRPSEnv14 | 23 | Envelope #14, 5 x 11 1/2 in.
vbPRPSCSheet | 24 | C size sheet
vbPRPSDSheet | 25 | D size sheet
vbPRPSESheet | 26 | E size sheet
vbPRPSEnvDL | 27 | Envelope DL, 110 x 220 mm
vbPRPSEnvC3 | 29 | Envelope C3, 324 x 458 mm
vbPRPSEnvC4 | 30 | Envelope C4, 229 x 324 mm
vbPRPSEnvC5 | 28 | Envelope C5, 162 x 229 mm
vbPRPSEnvC6 | 31 | Envelope C6, 114 x 162 mm
vbPRPSEnvC65 | 32 | Envelope C65, 114 x 229 mm
vbPRPSEnvB4 | 33 | Envelope B4, 250 x 353 mm
vbPRPSEnvB5 | 34 | Envelope B5, 176 x 250 mm
vbPRPSEnvB6 | 35 | Envelope B6, 176 x 125 mm
vbPRPSEnvItaly | 36 | Envelope, 110 x 230 mm
vbPRPSEnvMonarch | 37 | Envelope Monarch, 3 7/8 x 7 1/2 in.
vbPRPSEnvPersonal | 38 | Envelope, 3 5/8 x 6 1/2 in.
vbPRPSFanfoldUS | 39 | U.S. Standard Fanfold, 14 7/8 x 11 in.
vbPRPSFanfoldStdGerman | 40 | German Standard Fanfold, 8 1/2 x 12 in.
vbPRPSFanfoldLglGerman | 41 | German Legal Fanfold, 8 1/2 x 13 in.
vbPRPSUser | 256 | User-defined

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

Setting a printer's Height or Width property automatically sets PaperSize to vbPRPSUser.

Note The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may or may not produce an error. For more information, see the manufacturer's documentation for the specific driver.


EventParameters Property (EventInfo Object)

Returns a reference to the Parameters collection.

Syntax

object.Parameters

The object placeholder is an object expression that evaluates to an object in the Applies To list.


Parent Property

Returns the form, object, or collection that contains a control or another object or collection.

Syntax

object.Parent

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

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

MyButton.Parent.MousePointer = 4

The Parent 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 the Parent property to access its parent form.

There is no relationship between the Parent property and the MDIChild property. There is, however, a parent-child relationship between an MDIForm object and any Form object that has its MDIChild property set to True.


ParentCommandName Property

Returns or sets the name of an existing parent DECommand object to which you are linking the child DECommand object. This property is only used for relation hierarchies.

Syntax

object.ParentCommandName [=string]

The ParentCommandName property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the name of an existing DECommand object to which you are linking the child DECommand object.


ParentControls Property

Returns a collection of the other controls in the control’s container. The ParentControls property is not available at the control’s authoring time, and read-only at the control’s run time.

Syntax

object.ParentControls

The ParentControls property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

In most cases, the container of the control will be a form; this collection functions in a similar manner to the Controls collection on the form, but will also contain the form itself.

This collection is useful if the control wants to perform some action on the controls on the form; the control can iterate through the collection.

Controls cannot be added or removed by the developer who uses the control through this collection; the controls must be changed in whatever manner the container allows.

The contents of this collection is determined entirely by the container.


ParentControlsType Property

Returns or sets a value that determines whether the ParentControls collection contains references to controls incorporating the container's Extender object, or to controls without the Extender.

Syntax

object.ParentControlsType [= type]

The ParentControlsType property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
type | An integer or named constant that indicates what the ParentControls collection will return.

Settings

The settings for type are as follows:

Constant | Value | Description
vbExtender | 1 | (Default) The ParentControls collection will return the control and extender.
vbNoExtender | 0 | The ParentControls collection will return the control itself, without the extender.

Remarks

The ParentControls collection allows you to access the other controls on a container where your control has been sited. The default is for the references to these controls to include the Extender object properties and methods provided by the container.

Some containers, such as Internet Explorer, provide an extender object that cannot be used by Visual Basic. In such a container, Visual Basic will raise an error when you attempt to access the objects in ParentControls using the default settings.

You can access the controls on an HTML page in Internet Explorer by setting ParentControlsType to vbNoExtender, so that ParentControls will contain references to the controls themselves, without the extender properties and methods.

Because the property can be set at run time, you can switch back and forth between vbExtender and vbNoExtender depending on what container your control is sited on. If necessary, you can alternate between the settings in containers that support both.


ParentField Property

Returns or sets the name of the Field object that the parent DECommand object uses in its hierarchical comparison condition.

Syntax

object.ParentField [=string]

The ParentField property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the name of the Field object that the parent DECommand object uses in its hierarchical comparison condition.


Parent Property (UserControl Object)

Returns a reference to the container object on which the control is sited. Not available at design time and read-only at run time.

Syntax

object.Parent

The Parent property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

The Parent property returns a reference to the container object even when the UserControl's AmbientProperties object does not provide a Parent property. You can use the Parent property of the UserControl object to access the container's object model.

By testing TypeName(Parent), you can determine what container your control is sited on.

  • Excel returns the workbook.

  • Word returns the document.

  • Powerpoint returns the presentation.

  • VB4/VB5 returns the form.

  • Internet Explorer returns an object whose Script property returns the IOmWindow object.

For example, in Internet Explorer, the following code will change the background color of the HTML page on which your control is located:

Parent.Script.get_document.bgColor = "Blue"

More information on the Internet Explorer Scripting Object Model can be found on Microsoft’s Web site.

Important Always use late binding for calls to the Internet Explorer Scripting Object Model. Using early binding will almost certainly cause compatibility problems in the future, while late binding will always work. In other containers, you can use early binding.


Parent Property Example

This example passes a control from a form that doesn't have the focus to a procedure in a module, and then displays the state of the control on the parent form. To try this example, create three forms: Form1, containing a CommandButton control, and Form2 and Form3, each containing a CheckBox control. You must also create a new module (click Add Module in the Project menu). Paste the code into the Declarations sections of the respective forms or module, and then press F5 to run the program.

' Enter this code into Form1.
Private Sub Form_Load ()
   Form2.Show   ' Display all forms.
   Form3.Show
   Form2.AutoRedraw = True
   Form3.AutoRedraw = True
End Sub

Private Sub Command1_Click ()
   ReadCheckBox Form2.Check1   ' Call procedure in other module
   ReadCheckBox Form3.Check1   ' and send control as argument.
End Sub

' Enter this code into Module1.
Sub ReadCheckBox (Source As Control)
   If Source.Value Then
      Source.Parent.Cls   ' Clear parent form.
      Source.Parent.Print "CheckBox is ON."  ' Display on parent form.
   Else
      Source.Parent.Cls   ' Clear parent form.
      Source.Parent.Print "CheckBox is OFF."  ' Display on parent form.
   End If
End Sub


RescanReplacements Property

Sets or returns a value that determines whether to rescan for tokens contained within replacement text. You will always scan once, and if RescanReplacement=TRUE, then replacement text that contains tokens will be continually scanned until there are no tokens left.

Syntax

object.RescanReplacements[=boolean]

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that indicates whether or not to rescan tokens within replacement text.

Remarks

See the ProcessTag event, which allows you to replace specified strings with replacement text.


PasswordChar Property

Returns or sets a value indicating whether the characters typed by a user or placeholder characters are displayed in a TextBox control; returns or sets the character used as a placeholder.

Syntax

object.PasswordChar [= value]

The PasswordChar property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A string expression specifying the placeholder character.

Remarks

Use this property to create a password field in a dialog box. Although you can use any character, most Windows-based applications use the asterisk (*) (Chr(42)).

This property doesn't affect the Text property; Text contains exactly what the user types or what was set from code. Set PasswordChar to a zero-length string (""), which is the default, to display the actual text.

You can assign any string to this property, but only the first character is significant; all others are ignored.

Note If the MultiLine Property is set to True, setting the PasswordChar property will have no effect.


PasswordChar Property Example

This example illustrates how the PasswordChar property affects the way a TextBox control displays text. To try this example, paste the code into the Declarations section of a form that contains a TextBox, and then press F5 and click the form. Each time you click the form, the text toggles between an asterisk (*) password character and plain text.

Private Sub Form_Click ()
   If Text1.PasswordChar = "" Then
      Text1.PasswordChar = "*"
   Else
      Text1.PasswordChar = ""
   End If
End Sub


PasteOK Property

Returns a value that determines whether the contents of the system Clipboard can be pasted into the OLE container control.

Syntax

object.PasteOK

The object is an object expression that evaluates to an object in the Applies To list.

Remarks

When this property setting is True, you can paste the contents of the system Clipboard into the OLE container control.

Use the OLETypeAllowed property to specify the type of object ( linked or embedded) you want to paste into the OLE container control. Once you successfully paste an object into the OLE container control, you can check the OLEType property setting to determine the type of object that was created.

You can use this property if your application supports a Paste command on an Edit menu. If PasteOK is False, disable the menu command; otherwise, it can be enabled. Enable and disable menu commands by setting their Enabled property to True or False, respectively.

You paste an object into the OLE container control with the Paste method.

To provide more flexibility to the user, display a Paste Special dialog box when the user chooses the Edit Paste command. (Set OLETypeAllowed = 2, and then use the PasteSpecialDlg method.) When this dialog box is displayed, an object is pasted onto the system Clipboard based on the user's selections in the dialog box.


PasteOK Property Example

This example pastes an object in the OLE container control if the PasteOK property setting is True. Otherwise, the example displays a message box.

Private Sub mnuEditPaste_Click ()
   ' Check value of PasteOK.
   If Ole1.PasteOK Then
      Ole1.Paste         ' Enable Paste command if True.
   Else         ' Otherwise, disable Paste
      mnuEditPaste.Enabled = False   ' menu command and give
      MsgBox "Can't paste."   ' appropriate message.
   End If
End Sub


Path Property

Returns or sets the current path. Not available at design time. For the App object, read-only at run time.

Syntax

object.Path [= pathname]

The Path property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
pathname | A string expression that evaluates to the path name.

Remarks

The value of the Path property is a string indicating a path, such as C:\Ob or C:\Windows\System. For a DirListBox or FileListBox control, the default is the current path when the control is created at run time. For the App object, Path specifies the path of the project .VBP file when running the application from the development environment or the path of the .exe file when running the application as an executable file.

Use this property when building an application's file-browsing and manipulation capabilities. Setting the Path property has effects on a control similar to the MS-DOS chdir command — relative paths are allowed with or without a drive specification. Specifying only a drive with a colon (:) selects the current directory on that drive.

The Path property can also be set to a qualified network path without a drive connection using the following syntax:

\\servername\sharename\path

The preceding syntax changes the Drive property to a zero-length string ("").

Changing the value of Path has these effects:

  • For a DirListBox control, generates a Change event.

  • For a FileListBox control, generates a PathChange event.

Note For DirListBox, the return value of Path is different from that of List(ListIndex), which returns only the selection.


Path Property Example

This example displays a list of files for the selected drive and directory. To try this example, paste the code into the Declarations section of a form that contains DriveListBox, DirListBox, and FileListBox controls. Press F5. Use the mouse to change the drive or directory.

Private Sub Drive1_Change ()
   Dir1.Path = Drive1.Drive   ' Set directory path.
End Sub

Private Sub Dir1_Change ()
   File1.Path = Dir1.Path   ' Set file path.
End Sub


Pattern Property

Returns or sets a value indicating the filenames displayed in a FileListBox control at run time.

Syntax

object.Pattern [= value]

The Pattern property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A string expression indicating a file specification, such as "*.*" or "*.FRM". The default is "*.*", which returns a list of all files. In addition to using wildcard characters, you can also use multiple patterns separated by semicolons (;). For example, "*.exe; *.bat" would return a list of all executable files and all MS-DOS batch files.

Remarks

The Pattern property plays a key role in designing an application's file-browsing and manipulation capabilities. Use Pattern in combination with other file-control properties to provide the user with ways to explore files or groups of similar files. For example, in an application dedicated to launching other programs, you could designate that only .exe files be displayed in the file list box (*.exe). Other key file-control properties include Drive, FileName, and Path.

Changing the value of the Pattern property generates a PatternChange event.


Pattern Property Example

This example updates a TextBox control with the new pattern selected in a FileListBox control. The controls are set up so that when the user enters a pattern in the TextBox, such as *.txt, it's reflected in the FileListBox, much like the interaction you see in a typical File Open dialog box in a Windows-based application. If a full path such as C:\Bin\*.exe is entered into the TextBox control, the text is automatically parsed into path and pattern components by the FileListBox control. To try this example, paste the code into the Declarations section of a form that contains the following controls: a DirListBox, a FileListBox, a TextBox, and a CommandButton. Press F5 and type a valid file pattern into the TextBox.

Private Sub Form_Load ()
   Command1.Default = True   ' Set Default property.
End Sub

Private Sub Command1_Click ()
   ' Text is parsed into path and pattern components.
   File1.Filename = Text1.Text
   Dir1.Path = File1.Path   ' Set directory path.
End Sub

Private Sub File1_PatternChange ()
   Text1.Text = File1.Pattern   ' Set text to new pattern.
End Sub

Private Sub Dir1_Change
   File1.Path = Dir1.Path   ' Set file list box path.
End Sub


Persistable Property

Sets a value that determines if an object can save and restore data across instances. May only be set at design time.

Syntax

object.Persistable [= number]

The Persistable property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | An integer that specifies persistence behavior, as described in Settings.

Settings

The settings for number are:

Constant | Setting | Description
vbNotPersistable | 0 | (Default) The object can't be persisted.
vbPersistable | 1 | The object can be persisted.

Remarks

The Persistable property is only available for classes that are public and creatable. When Persistable is set to vbPersistable, the following events are added to the class: InitProperties, ReadProperties, and WriteProperties. The PropertyChanged method is added to the class as well.


PicClip (RedTop.vbp)

This sample program demonstrates one of the possible uses of the PictureClip control. This sample application uses the PictureClip control to spin a top.

File | Description
Infoform.frm | The information form.
Infoform.frx | The binary portion of the information form.
Redtop.frm | The main form.
Redtop.frx | The binary portion of the main form.
Redtop.vbp | The project file for the sample application.

To Run

From the Visual Basic File menu, choose Open Project and select the Redtop.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


Picture Property

Returns or sets a graphic to be displayed in a control. For the OLE container control, not available at design time and read-only at run time.

Syntax

object.Picture [= picture]

The Picture property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
picture | A string expression specifying a file containing a graphic, as described in Settings.

Settings

The settings for picture are:

Setting | Description
(None) | (Default) No picture.
(Bitmap, icon, metafile, GIF, JPEG) | Specifies a graphic. You can load the graphic from the Properties window at design time. At run time, you can also set this property using the LoadPicture function on a bitmap, icon, or metafile.

Remarks

At design time, you can transfer a graphic with the Clipboard using the Copy, Cut, and Paste commands on the Edit menu. At run time, you can use Clipboard methods such as GetData, SetData, and GetFormat with the nontext Clipboard constants vbCFBitmap, vbCFMetafile, and vbCFDIB, which are listed in the Visual Basic (VB) object library in the Object Browser.

When setting the Picture property at design time, the graphic is saved and loaded with the form. If you create an executable file, the file contains the image. When you load a graphic at run time, the graphic isn't saved with the application. Use the SavePicture statement to save a graphic from a form or picture box into a file.

Note At run time, the Picture property can be set to any other object's DragIcon, Icon, Image, or Picture property, or you can assign it the graphic returned by the LoadPicture function.

Note The Unisys Corporation has a patent that it alleges covers certain aspects of GIF-LZW compression technology, which the PictureBox and Image controls use. Microsoft Corporation obtained a license to the Unisys LZW patents in September, 1996. Microsoft's license does not, however, extend to software developers or third parties who use any Microsoft toolkit, language development, or operating system products to provide GIF read/write and/or any other LZW capabilities in their own products (for example, by way of DLLs and APIs).

If your commercial application uses either of these controls (and thus, the LZW technology), you may wish to obtain an independent legal opinion on the effect of the patent, or contact Unisys USA at http://www.unisys.com/ for more information.


PictureAlignment Property

Returns or sets a value that determines where the picture will appear in a Data Report designer's Image control.

Syntax

object.PictureAlignment [=integer]

The PictureAlignment property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
integer | Optional. A numeric expression that specifies the position of the picture, as shown in Settings.

Settings

The settings for integer are:

Constant | Value | Description
rptPATopLeft | 0 | The picture appears at the top left.
rptPATop | 1 | The picture appears at the top.
rptPATopRight | 2 | The picture appears at the top right.
rptPARight | 3 | The picture appears at the right.
rptPABottomRight | 4 | The picture appears at the bottom right.
rptPABottom | 5 | The picture appears at the bottom.
rptPABottomLeft | 6 | The picture appears at the bottom left.
rptPALeft | 7 | The picture appears at the left.
rptPACenter | 8 | The picture appears centered.


Picture Property Example

This example loads icons from the Visual Basic icon library into two of three PictureBox controls. When you click the form, the third PictureBox is used to switch the icons. You can use any two icons. Paste the code into the Declarations section of a form that has three small PictureBox controls (for Picture3, set Visible = False). Press F5 to run the program, and then click the form.

Private Sub Form_Load ()
   ' Load the icons.
   Picture1.Picture = LoadPicture("ICONS\COMPUTER\TRASH02A.ICO")
   Picture2.Picture = LoadPicture("ICONS\COMPUTER\TRASH02B.ICO")
End Sub

Private Sub Form_Click ()
   ' Switch the icons.
   Picture3.Picture = Picture1.Picture
   Picture1.Picture = Picture2.Picture
   Picture2.Picture = Picture3.Picture
   ' Clear the third picture (not necessary if not visible).
   Picture3.Picture = LoadPicture()
End Sub

This example pastes a bitmap from the Clipboard into a PictureBox control. To find the value of Clipboard format constants (starting with vbCF), see the Visual Basic (VB) object library in the Object Browser. To try this example, paste the code into the Declarations section of a form that has a PictureBox control. Press F5, and then in another application, copy an icon onto the Clipboard, switch to Visual Basic, and click the form.

Private Sub Form_Click ()
   Picture1.Picture = Clipboard.GetData(vbCFDIB)
End Sub


Port Property

Returns the name of the port through which a document is sent to a printer.

Syntax

object.Port

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The operating system determines the name of the port, such as LPT1: or LPT2:.

Note The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may or may not produce an error. For more information, see the manufacturer's documentation for the specific driver.


Port Property Example

This example examines each Printer object in the Printers collection to find one connected to a specific port and makes it the default printer.

Dim P As Object
For Each P In Printers
   If P.Port = "LPT2:" Or P.DeviceName Like "*LaserJet*" Then
      Set Printer = P
      Exit For
   End If
Next P


Precision Property

Returns or sets the maximum total number of digits, the precision, used by the data type of the DEField or DEParameter object. This property is read-only for the DEField object, is read-write for the DEParameter object, and applies only to numeric DEField and DEParameter objects.

Syntax

object.Precision [=value]

The Precision property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | Integer. A numeric expression that specifies the maximum total number of digits used by the DEField or DEParameter object.

Remarks

This property corresponds to the ADO Field or Parameter Precision properties.


Prepared Property (DEDesigner Extensibility)

Specifies whether the source of the DECommand object is prepared before the DECommand object is executed.

Syntax

object.Prepared [=Boolean]

The Prepared property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that specifies whether the source of the DECommand object is prepared before the DECommand object is executed. The default is False.

Remarks

The provider produces a compiled representation of the DECommand object during the first invocation. When the representation is maintained, preparing implies that successive invocations of the DECommand object are accelerated.

If the provider cannot prepare a DECommand object, an exception indicates that Prepared DECommand objects are not supported. This occurs when you attempt to set this property to True.

This property corresponds to the ADO Command Prepared property.


PrevInstance Property

Returns a value indicating whether a previous instance of an application is already running.

Syntax

object.PrevInstance

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You can use this property in a Load event procedure to specify whether a user is already running an instance of an application. Depending on the application, you might want only one instance running in the Microsoft Windows operating environment at a time.

Note Since a computer running Windows NT can support multiple desktops, if you use a component designed to work with distributed COM, it can result in the following scenario:

  • A client program in a user desktop requests one of the objects the component provides. Because the component is physically located on the same machine, the component is started in the user desktop.

  • Subsequently, a client program on another computer uses distributed COM to request one of the objects the component provides. A second instance of the component is started, in a system desktop.

There are now two instances of the component running on the same NT computer, in different desktops.

This scenario is not a problem unless the author of the component has placed a test for App.PrevInstance in the startup code for the component to prevent multiple copies of the component from running on the same computer. In this case, the remote component creation will fail.


Printer Property

Returns a Printer object, which enables you to communicate with a system printer (initially the default system printer).

Syntax

Printer

Remarks

Use graphics methods to draw text and graphics on the Printer object. Once the Printer object contains the output you want to print, you can use the EndDoc method to send the output directly to the default printer for the application.

You should check and possibly revise the layout of your forms if you print them. If you use the PrintForm method to print a form, for example, graphical images may be clipped at the bottom of the page and text carried over to the next page.


Printers Property

Returns a Printers collection, which enables you to gather information about all the available printers on the system.

Syntax

Printers(index)

The index placeholder represents an integer with a range from 0 to Printers.Count-1.

Remarks

The Printers collection enables you to query the available printers so you can specify a default printer for your application. For example, you may want to find out which of the available printers uses a specific printer driver. The following code searches all available printers to locate the first printer with its page orientation set to portrait, then sets it as the default printer:

Dim X As Printer
For Each X In Printers
   If X.Orientation = vbPRORPortrait Then
      ' Set printer as system default.
      Set Printer = X
      ' Stop looking for a printer.
      Exit For
   End If
Next

You designate one of the printers in the Printers collection as the default printer by using the Set statement. The preceding example designates the printer identified by the object variable X, the default printer for the application.

Note If you use the Printers collection to specify a particular printer, as in Printers(3), you can only access properties on a read-only basis. To both read and write the properties of an individual printer, you must first make that printer the default printer for the application.


PrintQuality Property

Returns or sets a value indicating the printer resolution. Not available at design time.

Syntax

object.PrintQuality [= value]

The PrintQuality property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A value or constant specifying printer resolution, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
vbPRPQDraft | -1 | Draft resolution
vbPRPQLow | -2 | Low resolution
vbPRPQMedium | -3 | Medium resolution
vbPRPQHigh | -4 | High resolution

In addition to the predefined negative values, you can also set value to a positive dots per inch (dpi) value, such as 300.

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

The default value depends on the printer driver and the current settings of the printer. The effect of these settings varies among printers and printer drivers. On some printers, some or all of the settings may produce the same result.

Note The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may or may not produce an error. For more information, see the manufacturer's documentation for the specific driver.


ProductName Property

Returns or sets a string value containing the product name of the running application. Read only at run time.

Syntax

object.ProductName

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

You can set this property at design time in the Type box in the Make tab of the Project Properties dialog box.


ProgID Property (LicenseInfo Object)

Returns the programmatic ID (progID) of a control.

Syntax

object.LicenseKey

The object placeholder is an object expression that evaluates to an object in the Applies To list.

Remarks

The programmatic ID for most controls can be determined by checking the Visual Basic Object Browser. The programmatic ID consists of two parts: the name of the control's Library, and it's Class. For example, the Visual Basic CommandButton object's programmatic ID is VB.CommandButton.


PromptBeforeExecuting Property

Specifies whether a confirmation displays before an object is executed at design time.

Syntax

object.PromptBeforeExecuting [=Boolean]

The PromptBeforeExecuting property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that specifies whether a confirmation dialog box displays before an object is executed.

Remarks

This property corresponds to the Prompt before executing command check box in the Options dialog box and is specific to your system. Therefore, changing it for one DataEnvironment object automatically changes it for all DataEnvironment objects on your system.

When setting the source of a DECommand object using the Data Environment Extensibility Object Model, first set the PromptBeforeExecuting property to False to prevent the confirmation dialog box from appearing.


PromptDelete Property

Specifies whether a confirmation displays when an object is deleted.

Syntax

object.PromptDelete [=Boolean]

The PromptDelete property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that specifies whether a confirmation dialog box displays when an object within a DataEnvironment object is deleted.

Remarks

This property corresponds to the Confirm Delete check box in the Options dialog box and is specific to your system. Therefore, changing it for one DataEnvironment object automatically changes it for all DataEnvironment objects on your system.

When removing objects using the Data Environment Extensibility Object Model, first set the PromptDelete property to False to prevent the confirmation dialog box from appearing.


Properties Property

Returns a WebItemProperties object that is a collection of user-defined properties for a WebItem.

Syntax

object.Properties

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Allows you to create and remove properties on a WebItem.


PropertyName Property

The behavior of the PropertyName property depends upon the context in which it is being used.

  • AsyncRead method — Sets the name of the property that will be associated with the AsyncProperty object’s Value property.

  • AsyncReadComplete event — Specifies the name of the property currently being read. This should correspond to a name assigned to the AsyncProperty object when invoking the AsyncRead method.

  • DataBinding Object — Read-only. Returns the name of the property that the DataBinding object refers to.

Syntax

object.PropertyName = string

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | The name of a property to be saved or retrieved.


PropertyName Property Example

The example assigns a value to the PropertyName property in the AsyncRead method. The same value will be used to assign the result of the method to a PictureBox control. To try the example, place a PictureBox control on a UserDocument object. Paste the code into the General section, and press F5 to run. Start Internet Explorer 3.0 (or later), and type the path and file name of the UserDocument.vbd file into the Address box.

Private Sub UserDocument_InitProperties()
   Dim strPath As String
   ' Set the variable to a valid path for a bitmap
   ' on your computer.
   strPath = "C:\Program Files\Microsoft Visual Studio\VB\" & _
      "Samples\VCR\Bfly1.bmp"
   AsyncRead strPath, vbAsyncTypeFile, _
      PropertyName:= "butterfly"
End Sub

Private Sub UserDocument_AsyncReadComplete (AsyncProp _
   As AsyncProperty)
   ' Use the Select statement to determine which
   ' Property is being returned.
   Select Case AsyncProp.PropertyName
      Case "butterfly"
         Picture1.Picture = _
         LoadPicture(AsyncProp.Value)
   End Select
End Sub


PropertyPage Property

Returns or sets the PropertyPage attribute of a Member object.

Syntax

object.PropertyPage

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


PropertyPages Property

Returns or sets a string that is the name of a property page that is associated with a control.

Syntax

object.PropertyPages(index) [= PropPageName]

The PropertyPages property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | Index into the string array.
PropPageName | A string containing the name of a property page in the project.

Remarks

PropertyPages property is a string array containing the names of the property pages in the project that are associated with this control. A property page may be added to the array by setting the last item in the array (which is always empty). A property page may be deleted from the array by setting that element in the array to an empty string.

The order of the names of property pages in the array determine the order in which pages appear in the property page’s dialog box for the control.


Public Property

Returns or sets a value determining if a control can be shared with other applications. The Public property is read/write at the control’s authoring time, and not available at the control’s run time.

Settings

The settings for Public are:

Setting | Description
True | The control can be shared with other applications. This is the default for ActiveX Control project types.
False | The control cannot be shared with other applications. When the control is contained in an ActiveX Control project, the control cannot be seen outside of the ActiveX Control project. This means that other controls or other forms in the project can use the control, but outside applications cannot. This is the only valid value for project types other than ActiveX Control.


ReadOnly Property

Returns or sets a value that determines whether a FileListBox control contains files with read-only attributes.

Syntax

object.ReadOnly [ = boolean]

The ReadOnly property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that specifies whether the control displays files with read-only attributes, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | The control includes read-only files in the list.
False | No read-only files are listed in the control.

Remarks

Use the ReadOnly property with a FileListBox control to specify whether files with read-only attributes are displayed in the file list or not.


ReadOnly Property (Data Access)

Returns or sets a value that determines whether the control's Database is opened for read-only access.

Syntax

object.ReadOnly [= boolean]

The ReadOnly property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that determines read/write access, as described in Settings.

Settings

The settings for value are:

Setting | Description
True | The control's Database object is opened with read-only access. Changes to data aren't allowed.
False | (Default) The control's Database is opened with read/write access to data.

Remarks

Use the ReadOnly property with a Data control to specify whether data in the underlying Database can be changed. For example, you might create an application that only displays data. Accessing a Database using read-only result sets is also faster.

For a Data control, this property is used only the first time a database is opened by your application. If your application subsequently opens other instances of the database, the property is ignored. For a change in this property to take effect, you must close all instances of the database and then use the Refresh method.

In the Professional and Enterprise Editions, this property corresponds to the readonly argument in the OpenDatabase method.

Data Type

Boolean


Recordset Property

Returns or sets a Recordset object defined by a Data control's properties or by an existing Recordset object.

Syntax

Set object.Recordset [= value ]

The Recordset property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | An object variable containing a Recordset object.

Remarks

The Data control is automatically initialized when your application starts before the initial Form_Load procedure. If the Connect, DatabaseName, Options, RecordSource, Exclusive, ReadOnly and RecordsetType properties are valid, or if you set these Data control properties at run time and use the Refresh method, the Microsoft Jet database engine attempts to create a new Recordset object based on those properties. This Recordset is accessible through the Data control's Recordset property. If, however, one or more of these properties is set incorrectly at design time, an untrappable error occurs when Visual Basic attempts to use the properties to open the specified database and create the Recordset object.

You can use the Recordset property as you would any other Recordset object. For example, you can use any of the Recordset methods or properties and examine the structure of the Recordset object's underlying schema.

You can also request the type of Recordset to be created by setting the Data control's RecordsetType property. If you don't request a specific type, a dynaset-type Recordset is created. Using the RecordsetType property, you can request to create either a table-, snapshot- or dynaset-type Recordset. However, if the Jet engine can't create the type requested, a trappable error occurs.

In many cases, the default type and configuration of the Recordset object created is extremely inefficient. That is, you might not need an updatable, fully-scrollable, keyset-type cursor to access your data. For example, a read-only, snapshot-type Recordset might be far faster to create than the default Recordset. Be sure to choose the most efficient Type, Exclusive, Options and ReadOnly properties possible for your situation.

The type of Recordset created can be determined at run time by examining the Recordset property's Type property or the Data control's RecordsetType property. Note, however, that the constants used for the type of Recordset created are different. For example:

If Data1.Recordset.Type = dbOpenDynaset Then ...
If Data1.RecordsetType = dbDynasetType Then ...

A Recordset might not be updatable even if you request a dynaset- or table-type Recordset. If the underlying database, table, or field isn't updatable, all or portions of your Recordset may be read-only. Examine the Database and Recordset objects' Updatable property or the Field object's DataUpdatable property to determine if your code can change the records. Even when the DataUpdatable property returns True, there are situations where the underlying data fields might not be updatable if, for example, you do not have sufficient permissions to make changes. Other factors can also prevent fields from being updatable.

The number of records returned by the Recordset can be determined by moving to the last record in the Recordset and examining the Recordset object's RecordCount property. Before you move to the last record, the value returned by the RecordCount property only reflects the number of rows processed by the Jet engine. The following example shows how you can combine the RecordCount property of a Recordset with the Recordset property to display the number of records in a Data control's recordset:

Data1.Recordset.MoveLast
MsgBox "Records: " & Data1.Recordset.RecordCount

Professional and Enterprise Editions

If you create a Recordset object using either code or another Data control, you can set the Recordset property of the Data control to this new Recordset. Any existing Recordset in the Data control, and the Database object associated with it are released when a new Recordset is assigned to the Recordset property.

Note When the Recordset property is set, the Data control doesn't close the current Recordset or Database, but it does release it. If there are no other users, the database is closed automatically. You may wish to consider closing the Recordset and Database associated with the Data control prior to setting the Recordset property using the Close method.

Make sure the DataField properties of the bound controls connected to the Data control are set to match the new Recordset object's field names.

For example, to create a Recordset in code and pass it to an existing Data control:

Dim Db As Database, Rs As Recordset   ' Defined as public variables.
Sub ApplyRecordset()
   Set Db = Workspaces(0).OpenDatabase("BIBLIO.MDB")
   Set Rs = Db.OpenRecordset("AUTHORS") ' Defaults to Table object.
   Set Data1.Recordset = Rs   ' Assign Recordset.
   Data1.Recordset.Index = "PrimaryKey"
   Debug.print Rs.Type   ' Show type created.
End Sub

You can use this technique to create an MDI parent and child data connection with a single hidden Data control on the MDI parent form and another visible Data control on the MDI child. In the MDI child's Form_Load event, set the child's Data control Recordset property to the parent's Data control Recordset property. Using this technique synchronizes all the child forms and their bound controls with the parent.

Note The Data control doesn't support forward-only Recordset objects. If you try to assign a forward-only Recordset object to the Recordset property of the Data control, a trappable error results.

All Recordset objects created by the Data control are created in Workspaces(0) except ODBCDirect (DefaultType = dbUseODBC) Recordset objects. If you need to use the Data control to manipulate a database in another Workspace, use the technique shown above to open the database in the desired Workspace, create a new Recordset and set the Data control's Recordset property to this new Recordset.

Important You can always reference the properties of the Data control's Recordset by using the Recordset property. By directly referencing the Recordset, you can determine the Index to use with Table objects, the Parameters collection of a QueryDef, or the Recordset type.

Data Type

Recordset


RecordSetReturning Property

Specifies whether the DECommand object, when executed at run time, returns an ADO Recordset object.

Syntax

object.RecordSetReturning [=string]

Parameters

The RecordSetReturning property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that identifies the returning Recordset object.

Remarks

The RecordSetReturning property provides you with the ability to force the DECommand object to be either Recordset returning or non-Recordset returning.

If the DECommand object is non-Recordset returning, no RecordSet property is exposed from the DataEnvironment object, and "rs" does not precede it (for example, rsCommand1). Most non-Recordset returning DECommand objects are associated with stored procedures that perform updates or deletes.


RecordsetType Property

Returns or sets a value indicating the type of Recordset object you want the Data control to create.

Syntax

object.RecordsetType [= value ]

The RecordsetType property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A constant or value that specifies a type of Recordset, as described in Settings.

Settings

The settings for value are:

Setting | Value | Description
vbRSTypeTable | 0 | A table-type Recordset
vbRSTypeDynaset | 1 | (Default) A dynaset-type Recordset
vbRSTypeSnapshot | 2 | A snapshot-type Recordset

Remarks

If the Microsoft Jet database engine can't create the type of Recordset you requested, a trappable error occurs.

If you don't specify a RecordsetType before the Data control creates the Recordset, a dynaset-type Recordset is created (if possible).

If you create a Recordset without using the Data control (even with another Data control) and set the Recordset property with this new Recordset object, the RecordsetType property of the Data control is set to the Recordset. Type property of the new Recordset.

Important The RecordsetType property value doesn't correspond to the value used to identify Recordset object types. See the OpenRecordset method or the Type property for details.

In many cases, the default type and configuration of the Recordset object created is extremely inefficient. That is, you might not need an updatable, fully-scrollable, keyset-type cursor to access your data. For example, a read-only, forward-only, snapshot-type Recordset might be far faster to create than the default cursor. Be sure to choose the most efficient settings for the RecordsetType, Exclusive, Options and ReadOnly properties for your situation.

Data Type

Integer


RecordsetType Property Example

This example uses the Data control to create a Recordset object and examines the Data control's RecordsetType property to determine what type of recordset was created.

Sub DisplayRecordsetType()
' Indicate type of Recordset wanted.
Data1.RecordsetType = vbRSTypeDynaset
Data1.DatabaseName = "BIBLIO.MDB"
Data1.RecordSource = "Authors"
Data1.Refresh

Select Case Data1.RecordsetType
   Case vbRSTypeTable
      Debug.print "Table-type Recordset created."
   Case vbRSTypeDynaset
      Debug.print "Dynaset-type Recordset created."
   Case vbRSTypeSnapshot
      Debug.print "Snapshot-type Recordset created."
End Select
End Sub


RecordSource Property

Returns or sets the underlying table, SQL statement, or stored procedure.

Syntax

object.RecordSource [= value ]

The RecordSource property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | A string expression specifying a name, as described in Settings.

Settings

The settings for value are:

Setting | Description
A table name | The name of one of the tables defined in the Database object's TableDefs collection.
An SQL query | A valid SQL string using syntax appropriate for the data source.
stored procedure | The name of a stored procedure in the database. When using DAO, the name of one of the QueryDef objects in the Database object's QueryDefs collection.

Remarks

The RecordSource property specifies the source of the records accessible through bound controls on your form.

If you set the RecordSource property to the name of an existing table in the database, all of the fields in that table are visible to the bound controls attached to the Data control. For table-type recordsets (RecordsetType = vbRSTypeTable), the order of the records retrieved is set by the Index object that you select using the Index property of the Recordset. For dynaset-type and snapshot-type Recordset objects, you can order the records by using a SQL statement with an Order By clause in the RecordSource property of the Data control. Otherwise, the data is returned in no particular order.

If you set the RecordSource property to the name of an existing QueryDef in the database, all fields returned by the QueryDef are visible to the bound controls attached to the Data control. The order of the records retrieved is set by the QueryDef object's query. For example, the QueryDef may include an ORDER BY clause to change the order of the records returned by the Recordset created by the Data control or a WHERE clause to filter the records. If the QueryDef doesn't specify an order, the data is returned in no particular order.

Note At design-time, the QueryDef objects displayed in the Properties window for the RecordSource property are filtered out to display only QueryDef objects that are usable with the Data control. QueryDef objects which have parameters, and QueryDef objects which have the following types are not displayed: dbQAction, dbQCrosstab, dbQSQLPassThrough and dbQSetOperation.

If you set the RecordSource property to an SQL statement that returns records, all fields returned by the SQL query are visible to the bound controls attached to the Data control. This statement may include an ORDER BY clause to change the order of the records returned by the Recordset created by the Data control or a WHERE clause to filter the records. If the database you specify in the Database and Connect property isn't a Microsoft Jet engine database, and if the dbSQLPassThrough option is set in the Options property, your SQL query must use the syntax required by that database engine.

Note Whenever your QueryDef or SQL statement returns a value from an expression, the field name of the expression is created automatically by the Microsoft Jet database engine. Generally, the name is Expr1 followed by a three-character number beginning with 000. For example, the first expression would be named: Expr1000.

In most cases you'll want to alias expressions so you know the name of the column to bind to the bound control. See the SQL SELECT statement AS clause for more information.

After changing the value of the RecordSource property at run time, you must use the Refresh method to enable the change and rebuild the Recordset.

At run time, if the Recordset specifies an invalid Table name, QueryDef name, or contains invalid SQL syntax, a trappable error will result. If this error occurs during the initial Form_Load procedure, the error is not trappable.

Note Make sure each bound control has a valid setting for its DataField property. If you change the setting of a Data control's RecordSource property and then use Refresh, the Recordset identifies the new object. This may invalidate the DataField settings of bound controls and cause a trappable error.

Data Type

String


RelateToParent Property

Specifies whether the current DECommand object (child) is related to another DECommand object (parent).

Syntax

object.RelateToParent [=Boolean]

The RelateToParent property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that specifies whether the current DECommand object is related to a parent DECommand object. The default is False, or non-hierarchical.

Remarks

This property is used in defining a relation hierarchy. If True, this DECommand object is used in a relation hierarchy.


ReportWidth Property

Returns or sets the width of the report, in twips.

Syntax

object.ReportWidth[= integer]

The ReportWidth property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
integer | Optional. A numeric expression that specifies the width of the report in twips.

Remarks

The DataReport object's Height, Width, Top, and Left properties determine the print preview window's size, while the ReportWidth property values specifies the actual report width.


RequestEdit Property

Returns or sets the RequestEdit attribute of a Member object.

Syntax

object.RequestEdit

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


Request Property

Returns the Active Server Pages Request object.

Syntax

object.Request

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

A WebClass uses the Request object to read the contents of a request from the client. The Request object contains information from the browser that the WebClass can use to respond to the request. This includes any data the user entered in an HTML form and parameters in the URL.

If the WebClass object places state in the URLs using the URLData property, the Request object is used to read that state in subsequent HTTP requests.

See the Active Server Pages documentation for details of the properties, methods, and events for the Request object.


Required Property (DEDesigner Extensibility)

Specifies whether the value of the DEParameter object is required.

Syntax

object.Required(Boolean)

The Required property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | Optional. A Boolean expression that specifies whether the value of the DEParameter object is required. When True, the default, a value must be supplied to successfully execute the stored procedure.

Remarks

If a child DECommand object has required parameters, each of the parameters must be used in a relation definition to successfully execute the SHAPE Command at run time.


Response Property

Returns the Active Server Pages Response object.

Syntax

object.Response

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

A WebClass uses the Response object to send information to the client for display. See the Active Server Pages documentation for details of the properties, methods, and events for this object.


RetainedProject Property

Returns a value that determines whether a project will remain loaded in memory.

Syntax

object.RetainedProject [= boolean]

The RetainedProject property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that specifies whether a project will remain loaded in memory.

Settings

The settings for boolean are:

Setting | Description
True | A project remains loaded in memory.
False | (Default) A project does not remain loaded in memory.


Revision Property

Returns or sets the revision version number of the project. Read only at run time.

Syntax

object.Revision

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The value of the Revision property is in the range from 0 to 9999.

This property provides version information about the running application.

You can set this property at design time in the Revision box in the Make tab of the Project Properties dialog box.


RowHeight Property

Returns or sets the height of all rows in the DataGrid control. RowHeight is always in the same unit of measure as the container for the DataGrid control.

Syntax

object.RowHeight[= value ]

The RowHeight property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A numeric expression specifying height.

Remarks

Users can change the RowHeight of any row at run time by placing the mouse pointer on a gridline between rows and dragging.


RowHeight Property Example

This example sets the height of the current row to 500 twips when you click the form. To try this example, create a new project, use the Components dialog box to add a DataGrid control to the toolbox (from the Project menu, choose Components, and then select Microsoft DataGrid Control), and then draw a DataGrid control on the form. Paste the code into the Declarations section of the form, press F5 to run the program, and then select a cell and click the form.

Private Sub Form_Load ()
   DataGrid1.Rows = 5   ' Set columns and rows.
   DataGrid1.Cols = 7
End Sub

Private Sub Form_Click ()
   DataGrid1.RowHeight(DataGrid1.Row) = 500
End Sub


RunPassword Property

Returns or sets the password for the current user name at run time.

Note This property is only saved if the RunSaveAuthentication property is True.

Syntax

object.RunPassword [=string]

The RunPassword property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that defines the password that is used at design time.

Remarks

This property is passed to ADO by appending "Password=" and a value to the connection string which is passed to ADO at run time.


RunPromptBehavior Property

Specifies the prompting behavior by the DEConnection object, such as when to request logon information, at run time.

Syntax

object.RunPromptBehavior [=value]

The RunPromptBehavior property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies the prompt behavior of the Connection object.

Remarks

This property corresponds to the ADO Connection Prompt property.


RunSaveAuthentication Property

Specifies whether the authentication information is saved with the run-time class.

Syntax

object.RunSaveAuthentication [=Boolean]

The RunSaveAuthentication property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that specifies whether to save the authentication information with the run-time class. The default is False.

Remarks

When set to True, the user identification and password are saved with the project.

Note Since the password is not encrypted, for maximum security you should not specify your password to persist for run time.


RunUserName Property

Returns or sets the user name that is used when connecting to the data source at run time.

Note This is only saved if the RunSaveAuthentication property is True.

Syntax

object.RunUserName [=string]

The RunUserName property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the user name to use when connecting to the data source at run time.

Remarks

This property is passed to ADO by appending "User ID=" and a value onto the connection string which is passed to ADO at run time.


ScaleHeight, ScaleWidth Properties

Return or set the number of units for the horizontal (ScaleWidth) and vertical (ScaleHeight) measurement of the interior of an object when using graphics methods or when positioning controls. For MDIForm objects, not available at design time and read-only at run time.

Syntax

object.ScaleHeight [= value]

object.ScaleWidth [= value]

The ScaleHeight and ScaleWidth property syntaxes have these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A numeric expression specifying the horizontal or vertical measurement.

Remarks

You can use these properties to create a custom coordinate scale for drawing or printing. For example, the statement ScaleHeight = 100 changes the units of measure of the actual interior height of the form. Instead of the height being n current units (twips, pixels, ...), the height will be 100 user-defined units. Therefore, a distance of 50 units is half the height/width of the object, and a distance of 101 units will be off the object by 1 unit.

Use the ScaleMode property to define a scale based on a standard unit of measurement, such as twips, points, pixels, characters, inches, millimeters, or centimeters.

Setting these properties to positive values makes coordinates increase from top to bottom and left to right. Setting them to negative values makes coordinates increase from bottom to top and right to left.

Using these properties and the related ScaleLeft and ScaleTop properties, you can set up a full coordinate system with both positive and negative coordinates. All four of these Scale properties interact with the ScaleMode property in the following ways:

  • Setting any other Scale property to any value automatically sets ScaleMode to 0. A ScaleMode of 0 is user-defined.

  • Setting ScaleMode to a number greater than 0 changes ScaleHeight and ScaleWidth to the new unit of measurement and sets ScaleLeft and ScaleTop to 0. In addition, the CurrentX and CurrentY settings change to reflect the new coordinates of the current point.

You can also use the Scale method to set the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties in one statement.

Note The ScaleHeight and ScaleWidth properties aren't the same as the Height and Width properties.

For MDIForm objects, ScaleHeight and ScaleWidth refer only to the area not covered by PictureBox controls in the form. Avoid using these properties to size a PictureBox in the Resize event of an MDIForm.


ScaleHeight, ScaleWidth Properties Example

This example uses the ScaleHeight and ScaleWidth properties to change the vertical and horizontal units of measurement for a form. To try this example, paste the code into the Declarations section of a form, and then press F5. To see the effect, click the form, resize it, and then click it again.

Private Sub Form_Click ()
   Dim Radius As Integer   ' Declare variable.
   ScaleHeight = 100   ' Set height units.
   ScaleWidth = 100   ' Set width units.
   For Radius = 5 to 50 Step 5
      FillStyle = 1
      Circle (50, 50), Radius   ' Draw circle.
   Next Radius
End Sub


ScaleLeft, ScaleTop Properties

Return or set the horizontal (ScaleLeft) and vertical (ScaleTop) coordinates for the left and top edges of an object when using graphics methods or when positioning controls.

Syntax

object.ScaleLeft [= value]

object.ScaleTop [= value]

The ScaleLeft and ScaleTop property syntaxes have these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A numeric expression specifying the horizontal or vertical coordinate. The default is 0.

Remarks

Using these properties and the related ScaleHeight and ScaleWidth properties, you can set up a full coordinate system with both positive and negative coordinates. These four Scale properties interact with the ScaleMode property in the following ways:

  • Setting any other Scale property to any value automatically sets ScaleMode to 0. A ScaleMode of 0 is user-defined.

  • Setting the ScaleMode property to a number greater than 0 changes ScaleHeight and ScaleWidth to the new unit of measurement and sets ScaleLeft and ScaleTop to 0. The CurrentX and CurrentY property settings change to reflect the new coordinates of the current point.

You can also use the Scale method to set the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties in one statement.

Note The ScaleLeft and ScaleTop properties aren't the same as the Left and Top properties.


ScaleLeft, ScaleTop Properties Example

This example creates a grid in a PictureBox control and sets coordinates for the upper-left corner to -1, -1 instead of 0, 0. Every 0.25 second, dots are randomly plotted from the upper-left corner to the lower-right corner. To try this example, paste the code into the Declarations section of a form that contains a large PictureBox and a Timer control, and then press F5.

Private Sub Form_Load ()
   Timer1.Interval = 250   ' Set Timer interval.
   Picture1.ScaleTop = -1   ' Set scale for top of grid.
   Picture1.ScaleLeft = -1   ' Set scale for left of grid.
   Picture1.ScaleWidth = 2   ' Set scale (-1 to 1).
   Picture1.ScaleHeight = 2
   Picture1.Line (-1, 0)-(1, 0)   ' Draw horizontal line.
   Picture1.Line (0, -1)-(0, 1)   ' Draw vertical line.
End Sub

Private Sub Timer1_Timer ()
   Dim I   ' Declare variable.
   ' Plot dots randomly within a range.
   For I = -1 To 1 Step .05
      Picture1.PSet (I * Rnd, I * Rnd)   ' Draw a point.
   Next I
End Sub


ScaleMode Property

Returns or sets a value indicating the unit of measurement for coordinates of an object when using graphics methods or when positioning controls.

Syntax

object.ScaleMode [= value]

The ScaleMode property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | An integer specifying the unit of measurement, as described in Settings.

Settings

The settings for value are:

Constant | Setting | Description
vbUser | 0 | Indicates that one or more of the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties are set to custom values.
vbTwips | 1 | (Default) Twip (1440 twips per logical inch; 567 twips per logical centimeter).
vbPoints | 2 | Point (72 points per logical inch).
vbPixels | 3 | Pixel (smallest unit of monitor or printer resolution).
vbCharacters | 4 | Character (horizontal = 120 twips per unit; vertical = 240 twips per unit).
vbInches | 5 | Inch.
vbMillimeters | 6 | Millimeter.
vbCentimeters | 7 | Centimeter.
vbHimetric | 8 | HiMetric
vbContainerPosition | 9 | Units used by the control's container to determine the control's position.
vbContainerSize | 10 | Units used by the control's container to determine the control's size.

Remarks

Using the related ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties, you can create a custom coordinate system with both positive and negative coordinates. These four Scale properties interact with the ScaleMode property in the following ways:

  • Setting the value of any other Scale property to any value automatically sets ScaleMode to 0. A ScaleMode of 0 is user-defined.

  • Setting the ScaleMode property to a number greater than 0 changes ScaleHeight and ScaleWidth to the new unit of measurement and sets ScaleLeft and ScaleTop to 0. The CurrentX and CurrentY property settings change to reflect the new coordinates of the current point.


ScaleMode Property Example

This example shows how different ScaleMode property settings change the size of a circle. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form. When you click the form, the unit of measurement changes to the next ScaleMode setting and a circle is drawn on the form.

Private Sub Form_Click ()
   ' Cycle through each of the seven ScaleMode settings.
   ScaleMode = ((ScaleMode + 1) Mod 7) + 1
   ' Draw a circle with radius of 2 in center of form.
   Circle (ScaleWidth / 2, ScaleHeight / 2), 2
End Sub


ScaleUnits Property

Returns a string value that is the name of the coordinate units being used by the container.

Syntax

object.ScaleUnits

The ScaleUnits property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

This string represents the coordinates used by the container of the control, such as "twips". This string can be used by the control as a units indicator when displaying coordinate values.

If the container does not implement this ambient property, the default value will be an empty string.


Screen Property

Returns a Screen object, which enables you to manipulate forms according to their placement on the screen and control the mouse pointer outside your application's forms at run time. The Screen object is accessed with the keyword Screen.

Syntax

Screen

Remarks

The Screen object is the entire Windows desktop. Using the Screen object, you can set the MousePointer property of the Screen object to the hourglass pointer while a modal form is displayed.


ScrollBars Property

Returns or sets a value indicating whether an object has horizontal or vertical scroll bars. Read only at run time.

Syntax

object.ScrollBars

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

For an MDIForm object, the ScrollBars property settings are:

Setting | Description
True | (Default) The form has a horizontal or vertical scroll bar, or both.
False | The form has no scroll bars.

For a TextBox control, the ScrollBars property settings are:

Constant | Setting | Description
vbSBNone | 0 | (Default) None
vbHorizontal | 1 | Horizontal
vbVertical | 2 | Vertical
vbBoth | 3 | Both

For a DataGrid control, the ScrollBars property settings are:

Constant | Setting | Description
dbgNone | 0 | (Default) None
dbgHorizontal | 1 | Horizontal
dbgVertical | 2 | Vertical
dbgBoth | 3 | Both
dbgAutomatic | 4 | Automatic

Remarks

For a TextBox control with setting 1 (Horizontal), 2 (Vertical), or 3 (Both), you must set the MultiLine property to True.

At run time, the Microsoft Windows operating environment automatically implements a standard keyboard interface to allow navigation in TextBox controls with the arrow keys (UP ARROW, DOWN ARROW, LEFT ARROW, and RIGHT ARROW), the HOME and END keys, and so on.

Scroll bars are displayed on an object only if its contents extend beyond the object's borders. For example, in an MDIForm object, if part of a child form is hidden behind the border of the parent MDI form, a horizontal scroll bar (HScrollBar control) is displayed. The exception to this is the TextBox control which will always display scroll bars. If ScrollBars is set to False, the object won't have scroll bars, regardless of its contents.


Sdi (SdiNote.vbp)

This sample application demonstrates a Single Document Interface (SDI) notepad application. It also provides an introduction to menu creation and toolbars.

Background

The sample is comprised of a main form, a modal dialog form, and two basic modules. You can use this sample application in conjunction with the MDINote sample application to understand the differences between interface styles.For more information, "Creating a User Interface," in the Programmer's Guide.

File | Description
Filopen.bas | Module containing common file handling code.
Find.frm | Modal dialog form.
FrmSDI.frm | The main notepad form.
Frmsdi.frx | Binary data file for the Frmsdi.frm file.
SDInote.bas | Module containing shared code.
SDINote.vbp | The SDINote project file.

To Run

From the Visual Basic File menu, choose Open Project and select the Sdinote.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


Sections Property

Returns a reference to the Sections Collection.

Syntax

object.Sections

object.Sections(index)

The Sections property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
index | Optional. The index or name of a section.

Remarks

The property uses collection syntax to specify either the collection or a member of the collection to return.


SelCount Property

Returns the number of selected items in a ListBox control.

Syntax

object.SelCount

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The SelCount property returns 0 if no items are selected. Otherwise, it returns the number of list items currently selected. This property is particularly useful when users can make multiple selections.


Selected Property

Returns or sets the selection status of an item in a FileListBox or ListBox control. This property is an array of Boolean values with the same number of items as the List property. Not available at design time.

Syntax

object.Selected(index) [= boolean]

The Selected property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Index | The index number of the item in the control.
Boolean | A Boolean expression specifying whether the item is selected, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | The item is selected.
False | (Default) The item isn't selected.

Remarks

This property is particularly useful when users can make multiple selections. You can quickly check which items in a list are selected. You can also use this property to select or deselect items in a list from code.

If the MultiSelect property is set to 0, you can use the ListIndex property to get the index of the selected item. However, in a multiple selection, the ListIndex property returns the index of the item contained within the focus rectangle, whether or not the item is actually selected.

If a ListBox control’s Style property is set to 1 (check boxes), the Selected property returns True only for those items whose check boxes are selected. The Selected property will not return True for those items which are only highlighted.


SelectedControls Property

Returns a collection that contains all the currently selected controls on the form. The SelectedControls property is not available at the property page’s authoring time, and read-only at the property page’s run time.

Syntax

object.SelectedControls

The SelectedControls property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

This collection is useful to a property page in determining which controls are currently selected, and therefore which controls might need properties changed. Some containers only allow one control to be selected at once; in that case SelectedControls will only contain one control. Other containers allow more than one control to be selected at once; in that case there may be more than one control selected, and the property page must iterate through the controls in the SelectedControls collection and attempt to set the changed properties. Suitable error handling should be written to take care of the cases when a particular control in the collection does not have the changed property, or when the control raises an error when the property is set.


SelEndCol, SelStartCol, SelEndRow, SelStartRow Properties

Return or set the first or last row or column for a range of cells. Not available at design time.

  • SelEndCol — the last selected column on the right.

  • SelStartCol — the first selected column on the left.

  • SelEndRow — the last selected row.

  • SelStartRow—the first selected row.

Syntax

object.SelEndCol [= value ]

object.SelStartCol [= value]

object.SelEndRow [= value]

object.SelStartRow [= value]

The SelEndCol, SelStartCol, SelEndRow, and SelStartRow property syntaxes have these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A numeric expression specifying the first or last column or row.

Remarks

You can use these properties to select a specific region of a DataGrid control from code or to return in code the dimensions of an area that the user selects.

SelStartCol and SelStartRow together specify the cell in the upper-left corner of a selected range. SelEndCol and SelEndRow specify the cell in the lower-right corner of a selected range.

To specify a cell without moving the current selection, use the Col and Row properties.

The default value for SelStartCol and SelEndCol is -1.


SelLength, SelStart, SelText Properties

  • SelLength — returns or sets the number of characters selected.

  • SelStart — returns or sets the starting point of text selected; indicates the position of the insertion point if no text is selected.

  • SelText — returns or sets the string containing the currently selected text; consists of a zero-length string ("") if no characters are selected.

These properties aren't available at design time.

Syntax

object.SelLength [= number]

object.SelStart [= index]

object.SelText [= value]

The SelLength, SelStart, and SelText property syntaxes have these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Number | A numeric expression specifying the number of characters selected. For SelLength and SelStart, the valid range of settings is 0 to text length — the total number of characters in the edit area of a ComboBox or TextBox control.
Index | A numeric expression specifying the starting point of the selected text, as described in Settings.
Value | A string expression containing the selected text.

Remarks

Use these properties for tasks such as setting the insertion point, establishing an insertion range, selecting substrings in a control, or clearing text. Used in conjunction with the Clipboard object, these properties are useful for copy, cut, and paste operations.

When working with these properties:

  • Setting SelLength less than 0 causes a run-time error.

  • Setting SelStart greater than the text length sets the property to the existing text length; changing SelStart changes the selection to an insertion point and sets SelLength to 0.

  • Setting SelText to a new value sets SelLength to 0 and replaces the selected text with the new string.


SelLength, SelStart, SelText Properties Example

This example enables the user to specify some text to search for and then searches for the text and selects it, if found. To try this example, paste the code into the Declarations section of a form that contains a wide TextBox control, and then press F5 and click the form.

Private Sub Form_Load ()
   Text1.Text = "Two of the peak human experiences"
   Text1.Text = Text1.Text & " are good food and classical music."
End Sub
Private Sub Form_Click ()
   Dim Search, Where   ' Declare variables.
   ' Get search string from user.
   Search = InputBox("Enter text to be found:")
   Where = InStr(Text1.Text, Search)   ' Find string in text.
   If Where Then   ' If found,
      Text1.SelStart = Where - 1   ' set selection start and
      Text1.SelLength = Len(Search)   ' set selection length.
   Else
      MsgBox "String not found."   ' Notify user.
   End If
End Sub

This example shows how the Clipboard object is used in cut, copy, paste, and delete operations. To try this example, create a form with a TextBox control and use the Menu Editor to create an Edit menu (for each of the commands, set the Caption property = Cut, Copy, Paste, and Delete, respectively; set the Name property = EditCut, EditCopy, EditPaste, and EditDelete, respectively).

Private Sub EditCut_Click ()
   ' Clear the contents of the Clipboard.
 Clipboard.Clear
   ' Copy selected text to Clipboard.
   ClipBoard.SetText Screen.ActiveControl.SelText
   ' Delete selected text.
   Screen.ActiveControl.SelText = ""
End Sub

Private Sub EditCopy_Click ()
   ' Clear the contents of the Clipboard.
 Clipboard.Clear
   ' Copy selected text to Clipboard.
   ClipBoard.SetText Screen.ActiveControl.SelText
End Sub

Private Sub EditPaste_Click ()
   ' Place text from Clipboard into active control.
   Screen.ActiveControl.SelText = ClipBoard.GetText ()
End Sub

Private Sub EditDelete_Click ()
' Delete selected text.
Screen.ActiveControl.SelText = ""
End Sub


Server Property

Returns the Active Server Pages Server object.

Syntax

object.Server

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

A WebClass uses the Server object to create other objects and determine server-specific properties that might influence its processing. When creating objects which are to be stored in the Session or Application object, Server.CreateObject must be used instead of Visual Basic’s New keyword or CreateObject function.

See the Active Server Pages documentation for details of the properties, methods, and events for the Server object.


Session Property

Returns the Active Server Pages Session object.

Syntax

object.Session

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

A WebClass uses the Session object to maintain information about the current user session and possibly to store and retrieve state information. The Session object can be used to maintain state across different WebClasses and between WebClasses and Active Server Pages.

See the Active Server Pages documentation for details of the properties, methods, and events for the Session object.


Shape Property

Returns or sets a value indicating the appearance of a Shape control.

Syntax

object.Shape [= value]

The Shape property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | An integer specifying the control's appearance, as described in Settings.

Settings

The settings for value are:

Constant | Setting | Description
vbShapeRectangle | 0 | (Default) Rectangle
vbShapeSquare | 1 | Square
vbShapeOval | 2 | Oval
vbShapeCircle | 3 | Circle
vbShapeRoundedRectangle | 4 | Rounded Rectangle
vbShapeRoundedSquare | 5 | Rounded Square


ShapeText Property

Specifies the SHAPE string generated by the DataEnvironment object for a Command hierarchy.

Syntax

object.ShapeText [=string]

The ShapeText property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that generates when you create a Command hierarchy either by relating two DECommand objects or by grouping a DECommand object.

Remarks

This property is only applicable to the top-most DECommand object that is either grouped or in a relation hierarchy. Alternatively, this property is null and cannot be set.


Shape Property Example

This example illustrates the six possible shapes of the Shape control. To try this example, paste the code into the Declarations section of a form that contains an OptionButton control and a Shape control. For the OptionButton, set the Index property to 0 to create a control array of one element, and then press F5. Click each OptionButton to see each different shape.

Private Sub Form_Load ()
   Dim I   ' Declare variable.
   Option1(0).Caption = "Shape #0"
   For I = 1 To 5    ' Create five instances of Option1.
      Load Option1(I)
      ' Set the location of the new option button.
      Option1(I).Top = Option1(I - 1).Top + Option1(0).Height + 40
      ' Set the option button caption.
      Option1(I).Caption = "Shape #" & I
      ' Display the new option button.
      Option1(I).Visible = True
   Next I
End Sub

Private Sub Option1_Click (Index As Integer)
   Shape1.Shape = Index
End Sub


Shortcut Property

Sets a value that specifies a shortcut key for a Menu object. Not available at run time.

Remarks

Use this property to provide keyboard shortcuts for menu commands. You can set this property using the Menu Editor. For a list of shortcut keys you can use, see the Shortcut list in the Menu Editor.

Note In addition to shortcut keys, you can also assign access keys to commands, menus, and controls by using an ampersand (&) in the Caption property setting.


ShowGrabHandles Property

Returns a boolean value stating whether the control should show grab handles.

Syntax

object.ShowGrabHandles

The ShowGrabHandles property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Settings

The possible boolean return values from the ShowGrabHandles property are:

Setting | Description
True | The control should show grab handles, if needed. If the container does not implement this ambient property, this will be the default value.
False | The control should not show grab handles.

Remarks

The default behavior for a control is to automatically show grab handles when the control is in a container that is in design mode (the control’s run mode.) However, many containers do not want the control to show grab handles, preferring to handle the indication of control sizing in another way. The ShowGrabHandles property is how the container notifies the control of who is to display the sizing indications.

Note All known containers prefer to handle the indication of control sizing themselves, and therefore set the ShowGrabHandles property to False. It is probably not necessary to actually handle the case when ShowGrabHandles is True.


ShowHatching Property

Returns a boolean value stating whether the control should show hatching around the control.

Syntax

object.ShowHatching

The ShowHatching property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Settings

The possible boolean return values from the ShowHatching property are:

Setting | Description
True | The control should show hatch marks, if needed. If the container does not implement this ambient property, this will be the default value.
False | The control should not show hatch marks.

Remarks

The default behavior for a control is to automatically show hatching when the control is in a container that is in design mode (the control’s run mode) and the control is the one that has focus. However, many containers do not want the control to show hatching, preferring to handle the indication of control focus in another way. The ShowHatching property is how the container notifies the control of who is to display the control focus indications.

Note Visual Basic forms do not implement this ambient property, and therefore the ShowHatching property is set to the default value of True when the control is placed in a Visual Basic form. However, Visual Basic does not expect the control to actually do anything in response to a ShowHatching value of True, therefore it is probably not necessary to actually handle the case when ShowHatching is True.


ShowInTaskbar Property

Returns or sets a value that determines whether a Form object appears in the Windows 95 taskbar. Read-only at run time.

Syntax

object.ShowInTaskbar

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The settings for the ShowInTaskbar property are:

Setting | Description
True | (Default) The Form object appears in the taskbar.
False | The Form object does not appear in the taskbar.

Remarks

Use the ShowInTaskbar property to keep dialog boxes in your application from appearing in the taskbar.

The default value for the ShowInTaskbar property assumes the default setting for the BorderStyle property of the Form object (Sizable). Changing the BorderStyle property may change the setting of the ShowInTaskbar property.


ShowPropertiesAfterCreate Property

Specifies whether the Properties dialog box displays immediately after a DECommand or DEConnection object is created.

Syntax

object.ShowProperties [=Boolean]

The ShowProperties property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that specifies whether the Command or Connection Properties dialog box displays after a DECommand or DEConnection object is created.

Remarks

This property corresponds to the Show Properties After Create check box in the Options dialog box and is specific to your system. Therefore, changing it for one DataEnvironment object automatically changes it for all DataEnvironment objects on your system.

When adding an object using the Data Environment Extensibility Object Model, first set the ShowPropertiesAfterCreate property to False to prevent the Properties dialog box from appearing.


ShowStatusBar Property

Specifies whether the status bar displays in the Data Environment designer window.

Syntax

object.ShowStatusBar [=Boolean]

The ShowStatusBar property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that specifies whether the status bar displays in the Data Environment designer window.

Remarks

This property corresponds to the Show Status Bar check box in the Options dialog box and is specific to your system. Therefore, changing it for one DataEnvironment object automatically changes it for all DataEnvironment objects on your system.


ShowSystemObjects Property

Specifies whether system database objects display in the Database Object drop-down list on the General tab of the Command Properties dialog box.

Syntax

object.ShowSystemObjects [=Boolean]

The ShowSystemObjects property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
Boolean | A Boolean expression that specifies whether the system database objects display in the Command Properties dialog box.

Remarks

This property corresponds to the Show System Objects check box in the Options dialog box and is specific to your system. Therefore, changing it for one DataEnvironment object automatically changes it for all DataEnvironment objects on your system.


Size Property (Font)

Returns or sets the font size used in the Font object.

Syntax

object.Size [= number]

The Size property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression specifying the size of the font in points.

Remarks

Use this property to format text in the font size you want. The default font size is determined by the operating system. To change the default, specify the size of the font in points. The maximum value for the Size property is 2048 points.

The Font object isn't directly available at design time. Instead you set the Size property by selecting a control's Font property in the Properties window and clicking the Properties button. In the Size box of the Font dialog box, select the size you want. At run time, however, set Size directly by specifying its setting for the Font object.


Size Property (DEDesigner Extensibility)

Specifies the maximum size, in bytes, of a DEParameter object.

Syntax

object.Size [=value]

The Size property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A Long expression that specifies the size of the DEParameter object.

Remarks

This property corresponds to the ADO Parameter Size property.


SizeMode Property

Returns or sets a value specifying how the OLE container control is sized or how its image is displayed when it contains an object.

Syntax

object.SizeMode [ = value]

The SizeMode property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | An integer or constant specifying how the control is sized or how its image is displayed, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
VbOLESizeClip | 0 | (Default) Clip. The object is displayed in actual size. If the object is larger than the OLE container control, its image is clipped by the control's borders.
VbOLESizeStretch | 1 | Stretch. The object's image is sized to fill the OLE container control. The image may not maintain the original proportions of the object.
VbOLESizeAutoSize | 2 | Autosize. The OLE container control is resized to display the entire object.
VbOLESizeZoom | 3 | Zoom. The object is resized to fill the OLE container control as much as possible while still maintaining the original proportions of the object.

Remarks

When SizeMode is set to 2 (Autosize), the OLE container control is automatically resized when the display size of an object changes. When this occurs, the Resize event is invoked before the OLE container control is automatically resized. The heightnew and widthnew arguments in the Resize event procedure indicate the optimal size for displaying the object (this size is determined by the application that created the object). You can size the control by changing the values of the heightnew and widthnew arguments in the Resize event procedure.


SizeMode Property (RptImage Control)

Returns or sets a value that specifies how to size a picture in the Data Report designer's Image control.

Syntax

object.SizeMode [=integer]

The SizeMode property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
integer | Optional. A numeric expression that specifies how a picture will be sized, as shown in Settings.

Settings

The settings for integer are:

Constant | Value | Description
rptSizeClip | 0 | The picture will be clipped.
rptSizeStretch | 1 | The picture will be stretched to fit the control.
rptSizeZoom | 2 | Same as stretched, except the X:Y proportion of the image remains constant.


Sorted Property

Returns a value indicating whether the elements of a control are automatically sorted alphabetically.

Syntax

object.Sorted

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Values

The Sorted property return values are:

Setting | Description
True | List items are sorted by character code order.
False | (Default) List items aren't sorted alphabetically.

Remarks

When this property is True, Visual Basic handles almost all necessary string processing to maintain alphabetic order, including changing the index numbers for items as required by the addition or removal of items.

Note Using the AddItem method to add an element to a specific location in the list may violate the sort order, and subsequent additions may not be correctly sorted.


SourceDoc Property

Returns or sets the filename to use when you create an object.

Note You set the SourceDoc property for compatibility with the Action property in earlier versions. For current functionality, use the CreateEmbed and CreateLink methods.

Syntax

object.SourceDoc [ = name]

The SourceDoc property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
name | A string expression specifying a filename.

Remarks

Use the SourceDoc property to specify the file to be linked when creating a linked object using the Action property. Use the SourceItem property to specify data within the file to be linked.

When creating an embedded object using the Action property, if the SourceDoc property is set to a valid filename, an embedded object is created using the specified file as a template.

When a linked object is created, the SourceItem property is concatenated to the SourceDoc property. At run time, the SourceItem property returns a zero-length string (""), and the SourceDoc property returns the entire path to the linked file, followed by an exclamation point (!) or a backslash (\), followed by the SourceItem. For example:

"C:\WORK\QTR1\REVENUE.XLS!R1C1:R30C15"


SourceItem Property

Returns or sets the data within the file to be linked when you create a linked object.

Syntax

object.SourceItem [ = string]

The SourceItem property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | A string expression specifying the data to be linked.

Remarks

OLETypeAllowed must be set to 0 (Linked) or 2 (Either) when using this property. Use the SourceDoc property to specify the file to link.

Each object uses its own syntax to describe units of data. To set this property, specify a unit of data recognized by the object. For example, when you link to Microsoft Excel, specify the SourceItem using a cell or cell-range reference such as R1C1 or R3C4:R9C22, or a named range such as Revenues.

To determine the syntax to describe a unit of data for an object, see the documentation for the application that created the object.

Note You may be able to determine this syntax by creating a linked object at design time using the Paste Special command (click the OLE container control with the right mouse button). Once the object is created, select the SourceDoc property in the Properties window and look at the string in the Settings box. For most objects, this string contains a path to the linked file, followed by an exclamation point (!) or a backslash (\) and the syntax for the linked data.

When a linked object is created, the SourceItem property is concatenated to the SourceDoc property. At run time, the SourceItem property returns a zero-length string (""), and the SourceDoc property returns the entire path to the linked file, followed by an exclamation point (!) or a backslash (\), followed by the SourceItem. For example:

"C:\WORK\QTR1\REVENUE.XLS!R1C1:R30C15"


SourceOfData Property

Specifies the source of the DEConnection object definition.

Syntax

object.SourceOfData [=value]

The SourceOfData property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies the source of data for the DEConnection object, as described in Settings.

Settings

The settings for value are:

Constant | Description
deOLEDBConnectionString | Use OLE DB Connection String. The source is an OLE DB connection string.
deUseODBCDataSource | Use ODBC Datasource. Default. The source is a connection string.
deOLEDBFile | Use OLE DB File. The source is an OLE DB file.


Source Property

Returns the source of an error.

Syntax

object.Source

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Type

String


Container Property

Returns or sets the container of a control on a Form. Not available at design time.

Syntax

Set object.Container [= container]

The Container property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
container | An object expression that evaluates to an object that can serve as a container for other controls, as described in Remarks.

Remarks

The following controls can contain other controls:

  • Frame control

  • PictureBox control

  • SSTab control


Container Property Example

This example demonstrates moving a CommandButton control from container to container on a Form object. To try this example, paste the code into the Declarations section of a form that contains a Frame control, a PictureBox control and a CommandButton, and then press F5.

Private Sub Form_Click()
   Static intX As Integer
   Select Case intX
      Case 0
         Set Command1.Container = Picture1
         Command1.Top= 0
         Command1.Left= 0
      Case 1
         Set Command1.Container = Frame1
         Command1.Top= 0
         Command1.Left= 0
      Case 2
         Set Command1.Container = Form1
         Command1.Top= 0
         Command1.Left= 0
   End Select
   intX = intX + 1
End Sub


StandardMethod Property

Returns or sets the StandardMethod attribute of a Member object.

Syntax

object.StandardMethod

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


StandardSize Property

Sets the property page to a standard size.

Syntax

object.StandardSize [= value]

The StandardSize property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | An integer expression specifying the type of mouse pointer displayed, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
Custom | 0 | (Default) Size determined by the object.
Small | 1 | Sets the PropertyPage StandardSize to 101 pixels high by 375 pixels wide.
Large | 2 | Sets the PropertyPage StandardSize to 179 pixels high by 375 pixels wide.

Remarks

The StandardSize property for property pages may not give the expected result when set to 1 - Small or 2 - Large. This property only affects the size of the property page for the author’s display driver and resolution. Unexpected results my occur on other displays.

It is suggested that you use the default StandardSize property value (0 - Custom) and treat a property page as you would any other form.


StartMode Property

Returns or sets a value that determines whether an application starts as a stand-alone project or as an ActiveX component. Read-only at run time.

Syntax

object.StartMode

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The StartMode property settings are:

Constant | Value | Description
vbSModeStandalone | 0 | (Default) Application starts as a stand-alone project.
VbSModeAutomation | 1 | Application starts as an ActiveX component.

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

At design time, you can set StartMode in the Project Options dialog box to 1 (vbSModeAutomation) to debug an application as if it were started as an ActiveX component.

Once a project is compiled, the value of the StartMode property is determined by how that application is started, not by its nominal setting in the Project Options dialog box.

When StartMode is set to 1 and there are no public classes in the project, you must use the End statement or choose End from the Run menu or toolbar to end the application. If you choose Close from the System menu, the form closes but the project is still running.


StartMode Property Example

This example shows one possible effect of setting the StartMode property to 1 (vbSModeAutomation) at design time. Create an ActiveX EXE project. Create a new form. From the Project menu, choose the Project Properties command. Select the Component tab, then select the ActiveX component option button in the Start Mode group. Choose OK to close the Project Properties dialog box. To try this example, paste the code into the Declarations section of the form, and then press F5 and double-click the Control menu at the left of the form’s title bar. If the form doesn’t display, enter Form1.Show in the Immediate window.

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   If UnloadMode = vbFormControlMenu And App.StartMode = vbSModeAutomation Then
      Msg = "Form will close but application will still be running." & Chr(10)
      Msg = Msg + "To terminate application without a public class," & Chr(10)
      Msg = Msg + "you must use an End statement."
      MsgBox Msg
   End If
End Sub


StartUpPosition Property

Returns or sets a value specifying the position of an object when it first appears. Not available at run time.

Syntax

object.StartUpPosition = position

The StartUpPosition property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
StartUpPosition | An integer that specifies the position of the object, as shown in Settings.

Settings

You can use one of four settings for StartUpPosition:

Constant | Value | Description
vbStartUpManual | 0 | No initial setting specified.
vbStartUpOwner | 1 | Center on the item to which the UserForm belongs.
vbStartUpScreen | 2 | Center on the whole screen.
vbStartUpWindowsDefault | 3 | Position in upper-left corner of screen.


StateManagement Property

Sets or returns the state type for a WebClass.

Syntax

object.StateManagement[= enum]

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
enum | Constant that determines how the WebClass maintains state, as described in Settings.

Settings

The settings for enum are:

Setting | Description
1-wcNoState | The WebClass instance is created when an HTTP request is received. The instance is used for the duration of the HTTP request and then destroyed. Any state required by the WebClass object must be stored externally, for example, in a database management system. Alternatively, state or key information for the state can be saved within the Session object, the URL itself using the URLData property or cookies using the Response.Cookies collection.
2-wcRetainInstance | The WebClass object instance is created when the first HTTP request is received. The instance is not destroyed until either the WebClass object calls ReleaseInstance or the Active Server Pages session times out. State can be safely kept within properties of the WebClass object; however, this will increase the size and decrease the scalability of your application.


StatusCode Property

Returns a constant specifying the current status of an AsyncRead operation.

Syntax

object.StatusCode

The StatusCode property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Settings

The possible enumerated return values for StatusCode property are:

Constant | Setting | Description
vbAsyncStatusCodeError | 0 | An error occurred during the asynchronous download. To find out the error, check the Value property of the AsyncProp object.
vbAsyncStatusCodeFindingResource | 1 | AsyncRead is finding the resource specified in the Status property that holds the storage being downloaded.
vbAsyncStatusCodeRedirecting | 2 | AsyncRead is connecting to the resource specified in the Status property that holds the storage being downloaded.
vbAsyncStatusCodeRedirecting | 3 | AsyncRead has been redirected to a different location specified in the Status property.
vbAsyncStatusCodeBeginDownloadData | 4 | AsyncRead has begun receiving data for the storage specified in the Status property.
vbAsyncStatusCodeDownloadingData | 5 | AsyncRead has received more data for the storage specified in the Status property.
vbAsyncStatusCodeEndDownloadData | 6 | AsyncRead has finished receiving data for the storage specified in the Status property.
vbAsyncStatusCodeUsingCachedCopy | 10 | AsyncRead is retrieving the requested storage from a cached copy since the Status property is empty.
vbAsyncStatusCodeSendingRequest | 11 | AsyncRead is requesting the storage specified in the Status property
vbAsyncStatusCodeMIMETypeAvailable | 13 | The MIME type of the requested storage is specified in the Status property.
vbAsyncStatusCodeCacheFileNameAvailable | 14 | The file name of the local file cache for requested storage is specified in the Status property.
vbAsyncStatusCodeBeginSyncOperation | 15 | The AsyncRead will operate synchronously.
vbAsyncStatusCodeEndSyncOperation | 16 | The AsyncRead has completed synchronous operation.

Remarks

The StatusCode constants list contains only the Visual Basic constants. Other constants not specific to Visual Basic or the AsyncRead method can be found in the Internet Explorer SDK under BINDSTATUS flags.


Status Property (AsyncProperty Object)

Returns protocol-specific status information about an AsyncRead operation.

Syntax

object.Status

The Status property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

The Status property returns a string specific to the StatusCode property and can be an empty string. For example, for vbAsyncStatusCodeBeginConnecting, the string is the TCP/IP port address.


Stretch Property

Returns or sets a value indicating whether a graphic resizes to fit the size of an Image control.

Syntax

object.Stretch [= boolean]

The Stretch property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression specifying whether the graphic resizes, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | The graphic resizes to fit the control.
False | (Default) The control resizes to fit the graphic.

Remarks

If Stretch is set to True, resizing the control also resizes the graphic it contains.


Stretch Property Example

This example loads an arrow icon from an icons directory into an Image control. The arrow crawls across the form when the Stretch property is set to True and hops across the form when Stretch is set to False. To try this example, paste the code into the Declarations section of a form that contains an Image control, a CheckBox control, and a Timer control, and then press F5 and click the form. Be sure to check the path to your icons directory and change it if necessary. To see the effects of the Stretch property, click the CheckBox, and then click the form again.

Dim ImgW   ' Declare variable.
Private Sub Form_Load ()
   ' Load an icon into the Image control.
   Image1.Picture = LoadPicture("ICONS\ARROWS\ARW02RT.ICO")
   Image1.Left = 0   ' Move image to left edge.
   ImgW = Image1.Width   ' Save width of image.
   Timer1.Interval = 300
   Timer1.Enabled = False   ' Turn off timer.
   Check1.Caption = "Stretch Property"
End Sub

Private Sub Form_Click ()
   Timer1.Enabled = True   ' Turn on the timer.
End Sub

Private Sub Timer1_Timer ()
   Static MoveIcon As Integer   ' Flag for moving the icon.
   If Not MoveIcon Then
      Image1.Move Image1.Left + ImgW, Image1.Top, ImgW * 2
   Else
      ' Move the image and return it to original width.
      Image1.Move Image1.Left + ImgW, Image1.Top, ImgW
   End If
   ' If image is off edge of form, start over.
   If Image1.Left > ScaleWidth Then
      Image1.Left = 0
      Timer1.Enabled = False
   End If
   MoveIcon = Not MoveIcon   ' Reset flag.
End Sub

Private Sub Check1_Click ()
   Image1.Stretch = Check1.Value
End Sub


StrikeThrough Property

Returns or sets the font style of the Font object to either strikethrough or nonstrikethrough.

Syntax

object.StrikeThrough [= boolean]

The StrikeThrough property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying the font style, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | Turns on strikethrough formatting.
False | (Default) Turns off strikethrough formatting.

Remarks

The Font object isn't directly available at design time. Instead you set the StrikeThrough property by choosing a control's Font property in the Properties window and clicking the Properties button. In the Font dialog box, select the Strikeout check box. At run time, however, you set StrikeThrough directly by specifying its setting for the Font object.


Style Property

Returns or sets a value indicating the display type and behavior of the control. Read only at run time.

Syntax

object.Style

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The Style property settings for the Checkbox, CommandButton, and OptionButton controls are:

Constant | Value | Description
vbButtonStandard | 0 | (Default) Standard. The control displays as it did in previous versions of Visual Basic. That is, a Checkbox control displays as a checkbox with a label next to it, an OptionButton as an option button with a label next to it, and a CommandButton as standard CommandButton without an associated graphic.
vbButtonGraphical | 1 | Graphical. The control displays in a graphical style. That is, a Checkbox control displays as a CommandButton-like button which can be toggled either up or down, an OptionButton displays as a CommandButton-like button which remains toggled up or down until another OptionButton in its option group is selected, and a CommandButton displays as a standard CommandButton that can also display an associated graphic.

The Style property settings for the ComboBox control are:

Constant | Value | Description
vbComboDropDown | 0 | (Default) Dropdown Combo. Includes a drop-down list and a text box. The user can select from the list or type in the text box.
vbComboSimple | 1 | Simple Combo. Includes a text box and a list, which doesn't drop down. The user can select from the list or type in the text box. The size of a Simple combo box includes both the edit and list portions. By default, a Simple combo box is sized so that none of the list is displayed. Increase the Height property to display more of the list.
vbComboDrop-DownList | 2 | Dropdown List. This style allows selection only from the drop-down list.

The Style property settings for the ListBox control are:

Constant | Value | Description
vbListBoxStandard | 0 | (Default) Standard. The ListBox control displays as it did in previous versions of Visual Basic; That is, as a list of text items.
vbListBoxCheckbox | 1 | CheckBox. The ListBox control displays with a checkbox next to each text item. Multiple items in the ListBox can be selected by selecting the checkbox beside them.

Remarks

For the ComboBox control, follow these guidelines in deciding which setting to choose:

  • Use setting 0 (Dropdown Combo) or setting 1 (Simple Combo) to give the user a list of choices. Either style enables the user to enter a choice in the text box. Setting 0 saves space on the form because the list portion closes when the user selects an item.

  • Use setting 2 (Dropdown List) to display a fixed list of choices from which the user can select one. The list portion closes when the user selects an item.


SummaryCommandName Property

Returns or sets the name of the summary Recordset when the DECommand object is grouped.

Syntax

object.SummaryCommandName [=string]

The SummaryCommandName property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | A string expression that specifies the name given to the summary Recordset.

Remarks

This property is used when defining a group-based Command hierarchy. The name must be unique among all DECommand and DEConnection objects within the DataEnvironment object.


SupportsMnemonics Property

Returns a boolean value stating whether the control’s container handles access keys for the control.

Syntax

object.SupportsMnemonics

The SupportsMnemonics property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Settings

The possible boolean return values from the SupportsMnemonics property are:

Setting | Description
True | The container for the control does handle access keys.
False | The container for the control does not handle access keys. If the container does not implement this ambient property, this will be the default value.

Remarks

Most containers of controls are capable of handling all the processing of access keys for the controls contained within the container. This includes figuring out which control is to be given a particular access key. If a container is not capable of processing access keys, it is indicated with this SupportsMnemonics property, and the control can take action, such as not displaying the underlined character as an indication of keyboard accelerators.


TabIndex Property

Returns or sets the tab order of most objects within their parent form.

Syntax

object.TabIndex [= index]

The TabIndex property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
index | An integer from 0 to (n–1), where n is the number of controls on the form that have a TabIndex property. Assigning a TabIndex value of less than 0 generates an error.

Remarks

By default, Visual Basic assigns a tab order to controls as you draw them on a form, with the exception of the Menu, Timer, Data, Image, Line and Shape controls, which are not included in the tab order. At run time, invisible or disabled controls and controls that can't receive the focus (Frame and Label controls) remain in the tab order but are skipped during tabbing.

Each new control is placed last in the tab order. If you change the value of a control's TabIndex property to adjust the default tab order, Visual Basic automatically renumbers the TabIndex of other controls to reflect insertions and deletions. You can make changes at design time using the Properties window or at run time in code

The TabIndex property isn't affected by the ZOrder method.

Note A control's tab order doesn't affect its associated access key. If you press the access key for a Frame or Label control, the focus moves to the next control in the tab order that can receive the focus.

When loading forms saved as ASCII text, controls with a TabIndex property that aren't listed in the form description are automatically assigned a TabIndex value. In subsequently loaded controls, if existing TabIndex values conflict with earlier assigned values, the controls are automatically assigned new values.

When you delete one or more controls, you can use the Undo command to restore the controls and all their properties except for the TabIndex property, which can't be restored. TabIndex is reset to the end of the tab order when you use Undo.


TabIndex Property Example

This example reverses the tab order of a group of buttons by changing the TabIndex property of a command button array. To try this example, paste the code into the Declarations section of a form that contains four CommandButton controls. Set the Name property to CommandX for each button to create the control array, and then press F5 and click the form to reverse the tab order of the buttons.

Private Sub Form_Click ()
   Dim I, X   ' Declare variables.
   ' Reverse tab order by setting start value of X.
   If CommandX(0).TabIndex = 0 Then X = 4 Else X = 1
      For I = 0 To 3
         CommandX(I).Caption = X   ' Set caption.
         CommandX(I).TabIndex = X - 1   ' Set tab order.
         If CommandX(0).TabIndex = 3 Then
            X = X - 1   ' Decrement X.
         Else
            X = X + 1   ' Increment X.
         End If
      Next I
End Sub


TabOrder (TabOrder.vbp)

The TabOrder sample application uses the Visual Basic 5.0 extensibility model, as well as traditional Visual Basic techniques, to reset the tab order of a given form. Many times when creating forms in Visual Basic, the controls end up in an odd tab order. The TabOrder application allows you to reset the tab order to top to bottom, or left to right order. You can also move items in the TabOrder's list up or down, then apply the changes to the form. For more information, see , "How to Build an Add-In," in "Extending the Visual Basic Environment Using Add-Ins," of the Component Tools Guide.

File | Description
Tab.bmp | Bitmap for the TabOrder application.
Tab.ico | Icon for the TabOrder application.
TabOrder.rc | Resource file for the TabOrder application.
TaOrder.cls | Class file for the TabOrder application.
TabOrder.frx | Binary data for the TabOrder.frm file.
Taborder.frm | The main for for the application.
Taborder.bas | Code module for the application.
Taborder.vbp | The project file for the application.

To Run

From the Visual Basic File menu, choose Open Project and select the Taborder.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


TabStop Property

Returns or sets a value indicating whether a user can use the TAB key to give the focus to an object.

Syntax

object.TabStop [= boolean]

The TabStop property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression specifying whether the object is a tab stop, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default) Designates the object as a tab stop.
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.

Remarks

This property enables you to add or remove a control from the tab order on a form. For example, if you're using a PictureBox control to draw a graphic, set its TabStop property to False, so the user can't tab to the PictureBox.


Tag Property

Returns or sets an expression that stores any extra data needed for your program. Unlike other properties, the value of the Tag property isn't used by Visual Basic; you can use this property to identify objects.

Syntax

object.Tag [= expression]

The Tag property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
expression | A string expression identifying the object. The default is a zero-length string ("").

Remarks

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing side effects. The Tag property is useful when you need to check the identity of a control or MDIForm object that is passed as a variable to a procedure.

Tip When you create a new instance of a form, assign a unique value to the Tag property.


Tag Property Example

This example displays a unique icon for each control being dragged. To try this example, paste the code into the Declarations section of a form that contains three PictureBox controls. Set the DragMode property to 1 for Picture1 and Picture2, and then press F5. Use the mouse to drag Picture1 or Picture2 over Picture3 controls.

Private Sub Form_Load ()
  Picture1.Tag = "ICONS\ARROWS\POINT03.ICO"
  Picture2.Tag = "ICONS\ARROWS\POINT04.ICO"
End Sub

Private Sub Picture3_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
   If State = vbEnter Then
      ' Select based on each PictureBox’s Name property.
      Select Case Source.Name
      Case "Picture1"
         ' Load icon for Picture1.
         Source.DragIcon = LoadPicture(Picture1.Tag)        Case "Picture2"
         ' Load icon for Picture2.
         Source.DragIcon = LoadPicture(Picture2.Tag)
      End Select
   ElseIf State = vbLeave Then
      ' When source isn't over Picture3, unload icon.
      Source.DragIcon = LoadPicture ()
   End If
End Sub


Target Property

Returns the Target parameter that was passed to AsyncRead.

Syntax

object.Target

The Target property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Remarks

The Target property returns a string that is the same value as the first parameter passed to the AsyncRead method, usually a URL.


TaskVisible Property

Returns or sets a value that determines if the application appears in the Windows task list.

Syntax

object.TaskVisible [= boolean]

The TaskVisible property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A boolean expression that determines if the application appears in the task list, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default) The application appears in the Windows task list.
False | The application does not appear in the Windows task list.

Remarks

The TaskVisible property can only be set to False in applications that do not display an interface, such as ActiveX components that do not contain or display Form objects. While the application displays an interface, the TaskVisible property is automatically set to True.


Template Property

Returns or sets the HTML template to use in exporting a report.

Syntax

object.Template [=string]

The Template property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
string | Optional. The header and/or footer code to be used.

Remarks

If no template is specified when invoking the ExportReport method, a default template appropriate to the report type will be used. Four default types are provided:

  • HTML template

  • UTF-8 encoded HTML

  • Text

  • Unicode text

You can print the default templates for use as a starting point in creating your own template by using the code below:

   Dim i As Integer
   For i = 1 To rptNwind.ExportFormats.Count
      Debug.Print "Template " & i
      Debug.Print rptNwind.ExportFormats(i).Template
      Debug.Print
   Next i

You can create your own templates using HTML tags such as <HTML>, <HEAD>, <TITLE>, <BODY> and their requisite closing tags. To specify where the body of the report should be placed, use the Visual Basic constant rptTagBody. For example, the code fragment below places the body of the report between the <BODY> tags:

Dim strTemplateBody As String
strTemplateBody = _
"<BODY>" & vbCrLf & _
rptTagBody & vbCrLf & _
"</BODY>"

Similarly, you can use the constant rptTagTitle to place the title (as determined by the Title property) anywhere in the template. The fragment below places the title just above the body:

Dim strTemplateBodyAndTitle As String
strTemplateBodyAndTitle = _
rptTagTitle & vbCrLf & _
"<BODY>" & vbCrLf & _
rptTagBody & vbCrLf & _
"</BODY>"

Accordingly, the default template for Text export consists simply of the rptTagBody constant. Thus you could create a simple text template that prefaces the report with the author's name, followed by the rptTagBody constant, as shown in the example below:

   Dim strTemplate As String
   strTemplate = _
   "Author: John Smith" & vbCrLf & _
   rptTagBody


Add Method, ExportFormats Collection, Template Property Example

This example creates a template, adds an ExportFormat object to the ExportFormats collection using the new template, and exports the report using the ExportFormat object.

Private Sub ExportDailyReport()
   DataReport1.Title = "Daily Report" ' This title appears in the report.
   Dim strTemplate As String
   ' Create the template.
   strTemplate = _
   "<HTML>" & vbCrLf & _
   "<HEAD>" & vbCrLf & _
   "<TITLE>" & "MyCompany: " & rptTagTitle & _
   "</TITLE>" & vbCrLf & _
   "<BODY>" & vbCrLf & _
   rptTagBody & vbCrLf & _
   "<BODY>" & vbCrLf & _
   "</HTML>"

   ' Add a new ExportFormat object using the template.
   DataReport1.ExportFormats.Add _
   Key:="DailyReport", _
   FormatType:=rptFmtHTML, _
   FileFormatString:="Daily Report (*.htm)", _
   FileFilter:="*.HTM", _
   Template:=strTemplate

   ' Export the report using the new ExportFormat object.
   DataReport1.ExportReport _
   FormatIndexOrKey:="DailyReport", _
   FileName:="C:\Temp\DailyRpt", _
   Overwrite:=True, _
   ShowDialog:=False, _
   Range:=rptRangeFromTo, _
   Pagefrom:=1, _
   Pageto:=10
End Sub


Text Property

  • ComboBox control (Style property set to 0 [Dropdown Combo] or to 1 [Simple Combo]) and TextBox control — returns or sets the text contained in the edit area.

  • ComboBox control (Style property set to 2 [Dropdown List]) and ListBox control — returns the selected item in the list box; the value returned is always equivalent to the value returned by the expression List(ListIndex). Read-only at design time; read-only at run time.

Syntax

object.Text [= string]

The Text property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | A string expression specifying text.

Remarks

At design time only, the defaults for the Text property are:

  • ComboBox and TextBox controls — the control's Name property.

  • ListBox control — a zero-length string ("").

For a ComboBox with the Style property set to 0 (Dropdown Combo) or to 1 (Simple Combo) or for a TextBox, this property is useful for reading the actual string contained in the edit area of the control. For a ComboBox or ListBox control with the Style property set to 2 (Dropdown List), you can use the Text property to determine the currently selected item.

The Text setting for a TextBox control is limited to 2048 characters unless the MultiLine property is True, in which case the limit is about 32K.


TextAlign Property

Returns an enumerated value of type TextAlignChoices stating what kind of text alignment the container would like the control to do.

Syntax

object.TextAlign

The TextAlign property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Settings

The possible enumerated return values from the TextAlign property are:

Setting | Description
0-General | General alignment: text to the left, numbers to the right. If the container does not implement this ambient property, this will be the default value.
1-Left | Align to the left.
2-Center | Align in the center.
3-Right | Align to the right.
4-FillJustify | Fill justify.

Remarks

This ambient property is the way that a container communicates to a contained control how to perform justification; this is a hint from the container that the control may or may not choose to follow.


Text Property Example

This example illustrates the Text property. To try this example, paste the code into the Declarations section of a form that contains three TextBox controls and a CommandButton control, and then press F5 and enter text in Text1.

Private Sub Text1_Change ()
   Text2.Text = LCase(Text1.Text)   ' Display text as lowercase.
   Text3.Text = UCase(Text1.Text)   ' Display text as uppercase.
End Sub

Private Sub Command1_Click ()   ' Delete text.
   Text1.Text = ""
End Sub


ThreadID Property

Returns the Win32 ID of the executing thread. (Used for Win32 API calls.)

Syntax

object.ThreadID

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Type

Long


Title Property

Returns or sets the title of the application that is displayed in the Microsoft Windows Task List. If changed at run time, changes aren't saved with the application.

Syntax

object.Title [= value]

The Title property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A string expression specifying the title of the application. The maximum length of value is 40 characters. In DBCS (double-byte character set) systems, this means the maximum length is 40 bytes.

Remarks

This property is available at design time in the dialog box for the Project Properties command on the Project menu.


Title Property (DataReport Object)

Returns or sets the title of the report.

Syntax

object.Title[=string]

The Title property syntax has these parts:

Part | Description
object | Required. An object expression that evaluates to an object in the Applies To list.
string | Optional. The title of the report.

Remarks

The title assigned with the Title property is used in two places:

  1. In a TextBox control with the caption set to %i.

  2. In an exported report—the title is represented by the rptTagTitle constant when creating a template (using the Template property) of the ExportFormat object.


TagPrefix Property

Sets or returns the string used to prefix replacement tagnames in an HTML template. The first character must be alphabetic.

Syntax

object.TagPrefix[=string]

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | Identifies the TagPrefix sequence used to recognize replacement tags within an HTML template.

Remarks

TagPrefix can be set at design time or at run time. The WebClass run time will look for any tag in a template file that begins with the specified prefix. When it finds it, it will fire the ProcessTag event on the WebClass object.


ToolboxBitmap Property

Returns or sets a bitmap that will be used as the picture representation of the control in the toolbox. The size of the space for the bitmap in the toolbox is 16x15 pixels; the bitmap specified by this property will be scaled to these dimensions if necessary. The ToolboxBitmap property is read/write at the control’s authoring time, and not available at the control’s run time.

Remarks

Important Do not assign an icon to the ToolboxBitmap property. Icons do not scale well to Toolbox bitmap size.

Visual Basic automatically uses the class name of the control as the tool tip text when users hover the mouse pointer over the icon in the Toolbox.

Tip When creating bitmaps, remember that for many forms of color-blindness, colors with the same overall level of brightness will appear to be the same. You can avoid this by restricting the bitmap to white, black, and shades of gray, or by careful color selection.


ToolTipText Property

Returns or sets a ToolTip.

Syntax

object.ToolTipText [= string]

The ToolTipText property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
string | A string associated with an object in the Applies To list. that appears in a small rectangle below the object when the user's cursor hovers over the object at run time for about one second.

Remarks

If you use only an image to label an object, you can use this property to explain each object with a few words.

At design time you can set the ToolTipText property string in the control's properties dialog box.

For the Toolbar and TabStrip controls, you must set the ShowTips property to True to display ToolTips.


TopIndex Property

Returns or sets a value that specifies which item in a ComboBox, DirListBox, DriveListBox, FileListBox, or ListBox control is displayed in the topmost position. Not available at design time.

Syntax

object.TopIndex [= value]

The TopIndex property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | The number of the list item that is displayed in the topmost position. The default is 0, or the first item in the list.

Remarks

Use this property to scroll through a control without selecting an item.

If the Columns property is set to 0 for the ListBox control, the item is displayed at the topmost position if there are enough items below it to fill the visible portion of the list.

If the Columns property setting is greater than 0 for the ListBox control, the item's column moves to the leftmost position without changing its position within the column.


TopIndex Property Example

This example fills a ListBox control with names of screen fonts and then scrolls through the ListBox when you click the form. To try this example, paste the code into the Declarations section of a form that contains a ListBox control, and then press F5 and click the form.

Private Sub Form_Load ()
   Dim I   ' Declare variable.
   For I = 0 To Screen.FontCount -1   ' Fill list box with
      List1.AddItem Screen.Fonts(I)   ' screen font names.
   Next I
End Sub

Private Sub Form_Click ()
   Dim X   ' Declare variable.
   X = List1.TopIndex   ' Get current index.
   List1.TopIndex = List1.TopIndex + 5   ' Reset topmost item.
   If List1.TopIndex = X Then List1.TopIndex = 0
End Sub


TrackDefault Property

Returns or sets a value that determines whether the Printer object always points to the same printer or changes the printer it points to if you change the default printer setting in the operating system's Control Panel. Not available at design time.

Syntax

object.TrackDefault [= boolean]

The TrackDefault property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying the printer object points to, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default) The Printer object changes the printer it points to when you change the default printer settings in the operating system's Control Panel.
False | The Printer object continues to point to the same printer even though you change the default printer settings in the operating system's Control Panel.

Remarks

Changing the TrackDefault property setting while a print job is in progress sends an implicit EndPage statement to the Printer object.


TrueValue Property

Sets or returns a value used to format and unformat Boolean True values. Read/write both at design time and run time.

Syntax

object.TrueValue [= value]

The TrueValue property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | Optional Variant. In the Format event, if the data is a Boolean True, value is returned; if TrueValue is empty, then the integer value 0 is returned. In the Unformat event, if TrueValue is empty and the value is 0, or if the data matches value, a Boolean True is written to the database. Defaults to True.

Remarks

Ignored unless the Type property is set to fmtBoolean. The TrueValue property is read each time data is fetched.


TwipsPerPixelX, TwipsPerPixelY Properties

Return the number of twips per pixel for an object measured horizontally (TwipsPerPixelX) or vertically (TwipsPerPixelY).

Syntax

object.TwipsPerPixelX

object.TwipsPerPixelY

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Windows API routines generally require measurements in pixels. You can use these properties to convert measurements quickly without changing an object's ScaleMode property setting.


Type Property (Picture)

Returns the graphic format of a Picture object. Not available at design time; read-only at run time.

Syntax

object.Type

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Values

The return values for the Type property are:

Constant | Value | Description
vbPicTypeNone | 0 | Picture is empty
vbPicTypeBitmap | 1 | Bitmap (.bmpBMP files)
vbPicTypeMetafile | 2 | Metafile (.wmfWMF files)
vbPicTypeIcon | 3 | Icon (.icoICO files)
vbPicTypeEMetafile | 4 | Enhanced Metafile (.emfEMF files)

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.


Type Property (DEDesigner Extensibility)

Returns or sets the data type of the DEField or DEParameter object. This property is read-only for the DEField object and is read-write for the DEParameter object.

Syntax

object.Type [=value]

The Type property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A constant or value that specifies the DEField or DEParameter type.

Remarks

This property corresponds to the ADO Field or Parameter Type properties.


Type Property

Sets or returns the type of formatting applied by the StdDataFormat object. Based on this setting, other properties of the object are used to format the value. Read/write both at design time and run time.

Syntax

object.Type = formattype

The Type property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
formattype | Required enumerated integer. Specifies the type of formatting desired, as described in Settings.

Settings

The settings for formattype are:

Constant | Setting | Description
fmtGeneral | 0 | No formatting is applied to the value.
fmtCustom | 1 | The format string contained in the Format property is used to format and unformat the value.
fmtPicture | 2 | The value is treated as a picture. A binary object read from the database is translated into a picture object, and written back to the database as a binary object.
fmtObject | 3 | The value is treated as an object. The StdDataFormat object expects to retrieve a CLSID from the database. The CLSID is used to instantiate the object, which is returned from the StdDataFormat object. The CLSID is then read from the object being formatted when the value is returned to the database.
fmtCheckbox | 4 | This setting is used to bind a check box to a database field. The database value is treated as the check box Value property. Return values are specified in the table under Remarks. The formatted values are only meaningful for a check box control whose Value property is of type OLE_TRISTATE. For general Boolean types, use fmtBoolean.
fmtBoolean | 5 | The value is treated as a Boolean value. When this type is chosen the TrueValue and FalseValue properties, and, depending on the type of database, the NullValue property, are used to determine how the value should be formatted. If none of those properties are set, the default behavior is to return the logical value from the database.

Remarks

This table lists return values associated with the fmtCheckbox setting, as described above.

Database Value | Formatted Value
Logical False | 0
Logical True | 1
Null | 2

To reset the Type property at run time you must unbind, set the property, and then rebind.


Type, Width Properties Example

This example reads the setting of the Type and Width properties of a Picture object in a PictureBox control. To try this example, paste the code into the Declarations section of a form that contains a PictureBox whose Picture property is set to an icon, and then press F5 and click the form.

Private Sub Form_Click()
   If Picture1.Picture.Type = vbPicTypeIcon Then
      Print "The graphic in the picture box is an icon."
   Else
      Print "The Picture property isn't set to an icon."
   End If
   Print "Width of the graphic in HiMetrics is " & Picture1.Picture.Width
   Print "Width of picture box itself in twips is " & Picture1.Width
End Sub


UBound Property

Returns the highest ordinal value of a control in a control array.

Syntax

object.UBound

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

UBound is equal to the Index property value of the last control in the array.


UIDead Property

Returns a boolean value indicating whether the control should be responsive to the user or not.

Syntax

object.UIDead

The UIDead property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Settings

The possible boolean return values from the UIDead property are:

Setting | Description
True | The control should not respond to the user.
False | The control should respond to the user. If the container does not implement this ambient property, this will be the default value.

Remarks

This property is typically used to indicate that the container is in break mode: during this mode, the control should not respond to any user input. That is, the control should ignore mouse clicks and keystrokes, and not change the mouse cursor even when the mouse is over the control window. A container such as a Visual Basic form would set this flag to TRUE when the programmer stops the program during execution — the container is not in design mode, yet not in run mode either; Visual Basic simply wants the controls to be inoperative.


UIDefault Property

Returns or sets the UIDefault attribute of a Member object.

Syntax

object.UIDefault

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


UnattendedApp Property

Returns a value that determines if an application will run without any user interface.

Syntax

object.UnattendedApp= boolean

The UnattendedApp property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that specifies if the application will run without any user interface.

Settings

The settings for boolean are:

Constant | Value | Description
True | -1 | The application has no user interface.
False | 0 | The application has a user interface.


Underline Property

Returns or sets the font style of the Font object to either underlined or nonunderlined.

Syntax

object.Underline [= boolean]

The Underline property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying the font style, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | Turns on underline formatting.
False | (Default) Turns off underline formatting.

Remarks

The Font object isn't directly available at design time. Instead you set the Underline property by selecting a control's Font property in the Properties window and clicking the Properties button. In the Font dialog box, select the Underline check box. At run time, however, you set Underline directly by specifying its setting for the Font object.


UpdateMode Property

Returns or sets the update mode of the collection.

Syntax

object.UpdateMode [= integer]

The UpdateMode property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
integer | A value or constant that specifies the update mode, as shown in Settings.

Settings

The settings for integer are:

Constant | Value | Description
vbUsePropertyAttributes | 0 | The recordset updates according to the settings found in the Data Binding pane of the Property Attributes dialog box.
vbUpdateWhenPropertyChanges | 1 | The recordset updates when the property's value changes.
vbUpdateWhenRowChanges | 2 | The recordset updates only when the user leaves the row.

Remarks

Whether or not a data source is updateable depends on the data provider. For example, if the data source is an ADO Recordset opened with its LockType property set to adLockReadOnly, it cannot be updated.


UpdateOptions Property

Returns or sets a value specifying how an object is updated when linked data is modified.

Syntax

object.UpdateOptions [ = number]

The UpdateOptions property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A integer specifying how an object is updated, as described in Settings.

Settings

The settings for number are:

Constant | Value | Description
vbOLEAutomatic | 0 | (Default) Automatic. The object is updated each time the linked data changes.
vbOLEFrozen | 1 | Frozen. The object is updated whenever the user saves the linked data from within the application in which it was created.
vbOLEManual | 2 | Manual. The object is updated only by using the Update method.

Remarks

This property is useful for linked objects where other users or applications can access and modify the linked data.

When an object's data is changed, the Updated event is invoked.


UseMaskColor Property

Returns or sets a value that determines whether the color assigned in the MaskColor property is used as a “mask”. (That is, used to create transparent regions.)

Syntax

object.UseMaskColor [= boolean]

The UseMaskColor property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression that specifies whether the color assigned to the MaskColor property is used as a mask.

Settings

The settings for boolean are:

Setting | Description
True | The color assigned to the MaskColor property is used as a mask, creating a transparent region wherever that color is.
False | (Default) The color assigned to the MaskColor property is ignored, and the color remains opaque.


UseMnemonic Property

Returns or sets a value that specifies whether an ampersand (&) included in the text of the Caption property of the Label control defines an access key.

Syntax

object.UseMnemonic [= boolean]

The UseMnemonic property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying whether the Label control enables an access key, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default) Any ampersand appearing in the text of the Caption property causes the character following the ampersand to become an access key. The ampersand itself isn't displayed in the interface of the Label control.
False | Any ampersand appearing in the text of the Caption property is displayed as an ampersand in the interface of the Label control.

Remarks

At run time, pressing ALT+ the access key defined in the Label control's Caption property moves focus to the control that follows the Label control in the tab order.


UseMnemonic Property Example

This example reads the setting of the UseMnemonic property of a Label control. To try this example, paste the code into the Declarations section of a form that contains a Label, and then press F5 and click the form.

Private Sub Form_Click()
   If Label1.UseMnemonic And InStr(Label1, "&") Then
      MsgBox "The label has an access key character."
   ElseIf Label1.UseMnemonic And Not InStr(Label1, "&") Then
      MsgBox "The label supports an access key character but doesn't have an ampersand."
   Else
      MsgBox "The label doesn't support an access key character."
   End If
End Sub


UserMode Property

Returns a boolean value indicating whether the control is being used by a form designer or a form user.

Syntax

object.UserMode

The UserMode property syntax has this part:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.

Settings

The possible boolean return values from the UserMode property are:

Setting | Description
True | The control is currently being used by a form user. If the container does not implement this ambient property, this will be the default value. In Visual Basic, this is Run Mode.
False | The control is currently being used by a form designer (the developer). In Visual Basic, this is Design Mode.


Value Property

  • CheckBox and OptionButton controls — returns or sets the state of the control.

  • CommandButton control — returns or sets a value indicating whether the button is chosen; not available at design time.

  • Field object — returns or sets the content of a field; not available at design time.

  • HScrollBar and VScrollBar controls (horizontal and vertical scroll bars) — returns or sets the current position of the scroll bar, whose return value is always between the values for the Max and Min properties, inclusive.

Syntax

object.Value [= value]

The Value property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | Value specifying the state, content, or position of a control, as described in Settings.

Settings

The settings for value are:

  • CheckBox control — 0 is Unchecked (default), 1 is Checked, and 2 is Grayed (dimmed).

  • CommandButton control — True indicates the button is chosen; False (default) indicates the button isn't chosen. Setting the Value property to True in code invokes the button's Click event.

  • Field object — restricted only by the Field data types.

  • HScrollBar and VScrollBar controls — set values between –32,768 and 32,767 to position the scroll box.

  • OptionButton control — True indicates the button is selected; False (default) indicates the button isn't selected.

Remarks

A default property of an object is assumed, and doesn't need to be specified in code. For example, Field is the default property of any Recordset, and Value is the default property of a Field object. This makes the two statements below equivalent:

Dn.Fields("PubID").Value = X
Dn.("PubID") = X

The first statement specifies the default properties; the second statement assumes them.


Value Property (DEDesigner Extensibility)

Returns or sets the value of the DEParameter object. The DataEnvironment object uses this value when executing the DECommand object, unless a value is specified at run time.

Syntax

object.Value [=value]

The Value property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
value | A variant expression that specifies the value of the DEParameter object.

Remarks

This property corresponds to the ADO Parameter Value property.


Value Property

Value Property (Format Objects)

Sets or returns the value of the StdDataValue object. Read/write at run time only.

Syntax

object.Value [= value]

The Value property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
value | Optional Variant. The value formatted by the StdDataFormat object.

Remarks

The setting or return value evaluates to a value appropriate for the Type property of the StdDataFormat object.


Value Property Example

This example displays an HScrollBar (horizontal scroll bar) control's numeric value in a TextBox control. To try this example, paste the code into the Declarations section of a form that has a TextBox control and an HScrollBar control. Press F5 to run the program, and then click the scroll bar.

Private Sub Form_Load ()
   HScroll1.Min = 0   ' Initialize scroll bar.
   HScroll1.Max = 1000
   HScroll1.LargeChange = 100
   HScroll1.SmallChange = 1
End Sub

Private Sub HScroll1_Change ()
   Text1.Text = Format (HScroll1.Value)
End Sub


VBMail (VBMail.vbp)

This sample program demonstrates the use of the MAPI controls by sending and receiving electronic mail. It uses the messaging application programming interface (MAPI) controls: MAPI messages and MAPI session.

Note To run this sample, you need a MAPI-compliant messaging system. If you are using Windows 95, you will need Microsoft Exchange.

Background

The MAPI session control establishes a MAPI session and signs off from a MAPI session. The MAPI messages control allows you to perform a variety of messaging systems functions after a messaging session has been established. These functions include accessing, downloading, and sending messages, displaying the details and address book dialog boxes, accessing data attachments, resolving recipient names during addressing, and performing compose, reply, reply-all, forward, and deleting actions on messages.

File | Description
Maillst.frm | Form for displaying the list of mail messages.
Mailst.frx | Contains binary data for the sample.
Mailoptf.frm | Form for setting options.
Mailsup.bas | Module of support procedures for the example.
MsgView.frm | Form in which a viewed message is displayed.
Newmsg.frm | Form for creating a new message.
Vbmail.frm | The main form.
Vbmail.vbp | The project file for this sample application.

To Run

From the Visual Basic File menu, choose Open Project and select the VBMAIL.VBP file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


VBTerm (VBTerm.vbp)

VBTerm is a terminal emulation program using the MSComm control. The sample demonstrates how to use the MSComm control with a serial port.

Background

The MSComm control allows you to open a serial port, change its settings, send and receive data through the port, and monitor and set many of the different data lines. Its dual-method access allows for both polling and event-driven communications.

File | Description
Cansend.frm | Dialog box used during file transfer.
Termset.frm | Form used to change the serial port settings.
Termset.frx | Binary portion of TERMSET.FRM.
Vbterm.frm | The main form.
Vbterm.frx | Binary portion of VBTERM.FRM.
Vbterm.glo | Public declarations.
Vbterm.vbp | The project file for the sample application.

To Run

From the Visual Basic File menu, choose Open Project and select the VBTerm.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


VCR (Vcr.vbp)

This sample application demonstrates how Visual Basic classes can be modeled after real-world objects such as a VCR.

Background

This sample is comprised of a main form used to represent a VCR, and two supporting classes representing the tape transport and recorder objects. For more information, see "Programming Fundamentals," in the Programmer's Guide.

File | Description
Recorder.cls | Class module for recorder object.
Set.frm | Modal form for setting recorder properties.
Tape.cls | Class module for tape transport object.
Vcr.bas | Module with shared code.
Vcr.frm | Main form for application.
Vcr.frx | Binary data file for the VCR.frm file.
Vcr.vbp | The VCR project file.

To Run

From the Visual Basic File menu, choose Open Project and select the Vcr.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


Verb Property

Returns or sets a value specifying an operation to perform when an object is activated using the Action property.

Note The Verb property is included for compatibility with the Action property in earlier versions. For current functionality, use the DoVerb method.

Syntax

object.Verb [= number]

The Verb property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A value that specifies the operation to perform.

Remarks

Each object can support its own set of verbs. Use the ObjectVerbs and ObjectVerbsCount properties to access the list of verbs supported by an object. Set Verb = 1 to specify the first verb in the list, set Verb = 2 to specify the second verb in the list, and so on.

Set AutoActivate to 2 (Double-Click) to automatically activate an object when it's double-clicked by the user.

Set AutoVerbMenu = True to display a pop-up menu containing the object's verbs when the user clicks the object with the right mouse button.


Version Property (DEDesigner Extensibility)

Returns the current version number of the Data Environment designer. Read-only.

Syntax

object.Version [=string]

The Version property syntax has these parts:

Part | Description
object | An object expression that evaluates to an item in the Applies To list.
string | The version of the current Data Environment designer.

Remarks

For this release, the Version property returns a value of "1.0".


ViewportHeight, ViewportLeft, ViewportTop, ViewportWidth Properties

Returns the current height, left, top, or width value of the Viewport.

Syntax

object.ViewportHeight

object.ViewportLeft

object.ViewportTop

object.ViewportWidth

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Type

Single

Remarks

The application used to view the ActiveX document controls the size of the Viewport. However, you can use the MinHeight and MinWidth properties to resize the UserDocument. For example, the code below resizes a PictureBox control according to the ViewportHeight and ViewportWidth properties.

Private Sub UserDocument_Resize()
   Picture1.Width = UserDocument.ViewportWidth - _
      Picture1.Left
   Picture1.Height = UserDocument.ViewportHeight - _
      Picture1.Top
End Sub


VisData (Visdata.vbp)

This sample program demonstrates various programming techniques used to access data through the Data Access Object (DAO) layer built into the Visual Basic Professional Edition.

Note To access ODBC data sources with this sample, you must first install ODBC using the ODBC setup program provided with Visual Basic, Professional Edition.

VisData behaves like a general purpose database utility, capable of the following functions:

Database and table creation.

  • Table modification (adding and deleting fields and indexes).

  • Data browsing/modifying using the three recordset types (table, dynaset, and snapshot) and three form types (single record, data control, and data grid).

  • Property browsing on all objects.

  • Form demonstrating the new data-bound list and data-bound combo box controls.

  • Import/export to all supported data types.

  • Direct SQL statement execution for any SQL supported functions such as Insert, Update, Delete, Drop, Create, Dump, and so forth.

  • AdHoc Query builder that helps users unfamiliar with SQL to create complex queries with Where clauses, Joins, Order By, and Group By expressions while limiting output to selected columns.

  • Transaction processing.

  • Copying table structures and data to the same or different database.

  • Support of Jet MDB, Dbase III and IV, FoxPro 2.x, Paradox 3.x and 4.x, Btrieve, Text, Excel, and SQL Server, both DDL and DML.

  • QueryDef creation, modification, and execution.

  • JET security creation/modification.

  • Relation/referential Integrity creation and modification.

  • Management of attached tables.

  • Use as an add-in to Visual Basic (see VISDATA.TXT).

The code contains comments to help explain the use of the various methods in the data access layer. Code and forms may be copied from this application to other applications with minimal modification.

File | Description
Aboutbox.frm | Standard About box for the application.
Addfield.frm | Form to add fields to tables.
Addindex.frm | Form used to add indexes to Tables.
Attach.frm | Attached table list.
Cpystru.frm | Form to copy table structures.
Database.frm | Form to select a database.
Dataform.frm | Data control form.
Datagrid.frm | Form used to display data in a data-bound grid control.
Datatype.frm | Data type selector for import/export utility.
Dbpwd.frm | Form to enter a password.
Dcprop.frm | Data control property form.
Dfd.frm | Data Form Designer add-in form.
Dynasnap.frm | Form to display data in single-record mode.
Errors.frm | Errors collection form.
Expname.frm | Export name prompt.
Find.frm | Form used to find records in a Dynaset.
Grpsusrs.frm | Jet security form.
Imptbls.frm | Import tables list.
Join.frm | Form used to add joins to the Query Builder.
Loginfrm.frm | Jet WorkSpace logon dialog box.
Newattch.frm | New attachment form.
Newpw.frm | New password dialog.
Newug.frm | New User/Group dialog.
Odbclogn.frm | ODBC logon form.
Property.frm | Property browser.
Query.frm | Form used to build queries.
Replace.frm | Form to perform global replace operations on a table.
Seek.frm | Form used to get input for the Seek function.
Sql.frm | Form to enter and execute SQL statements.
Tableobj.frm | Form used to display data in a Table object.
Tblstru.frm | Form to display and modify table structures.
Vbimex.frm | Import/export form.
Vdclass.cls | Class module for VisData.
Vdmdi.frm | Main MDI form for the application.
Visdata.bas | Support functions for the application.
Visdata.vbp | Project file for the application.
Zoom.frm | Form to zoom in on character data.
Vb5.hlp | VisData Help File.
*.frx files | Contains binary data for the associated .frm File.
*.ico files | Supplied for modification by user.

To Run

On the File menu, click Open Project, and select the Visdata.vbp file, which is located in the Samples directory.

If you want to open a local database, you simply need to choose the type of database, and a File Open dialog box will be displayed with the file type set to the requested data file type.

If you choose ODBC on the Open Database submenu, you will then see the Open DataBase form. Since you probably have no servers entered, you will need to enter a name for an existing SQL server on your network. If you already know the user ID and password, you can add them as well. The Database name is optional. Once you have entered this data, choose OK, and you should be able to log on to the server. You may get some more dialogs in the process. Answer any questions you can and ask the SQL administrator for help if you run into problems or don't know some of the parameters.

Once a database is open, double-clicking a table name will open the table in the selected form type and recordset type. Use the Query Builder to create dynasets with selected data from one or more tables at a time.

The table-type Recordset is always updatable. The dynaset-type Recordset will be updatable in most cases except on ODBC with no unique index, certain multiple table joins, and other SQL Select statements, such as count(*), max(), and so forth. The snapshot-type Recordset is never updatable.


Visible Property

Returns or sets a value indicating whether an object is visible or hidden.

Syntax

object.Visible [= boolean]

The Visible property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A Boolean expression specifying whether the object is visible or hidden.

Settings

The settings for boolean are:

Setting | Description
True | (Default) Object is visible.
False | Object is hidden.

Remarks

To hide an object at startup, set the Visible property to False at design time. Setting this property in code enables you to hide and later redisplay a control at run time in response to a particular event.

Note Using the Show or Hide method on a form is the same as setting the form's Visible property in code to True or False, respectively.


Visible Property Example

This example creates animation using two PictureBox controls. To try this example, paste the code into the Declarations section of a form that contains two icon-sized PictureBox controls. Set the Name property to FileCab for both PictureBox controls to create an array, and then press F5 and click the picture to view the animation.

Private Sub Form_Load ()
   Dim I   ' Declare variable.
   FileCab(0).BorderStyle = 0   ' Set BorderStyle.
   FileCab(1).BorderStyle = 0
   ' Load icons into picture boxes.
   FileCab(1).Picture = LoadPicture("ICONS\OFFICE\FILES03B.ICO")
   FileCab(0).Picture = LoadPicture("ICONS\OFFICE\FILES03A.ICO")
   For I = 0 To 1
      FileCab(I).Move 400, 400   ' Place graphics at same spot.
   Next I
   FileCab(1).Visible = False   ' Set to invisible.
   FileCab(0).Visible = True   ' Set to visible.
End Sub

Private Sub FileCab_Click (Index As Integer)
   Dim I   ' Declare variable.
   For I = 0 To 1
      ' Switch the visibility for both graphics.
      FileCab(I).Visible = Not FileCab(I).Visible
   Next I
End Sub


Weight Property

Returns or sets the weight of the characters that make up a Font object. The weight refers to the thickness of the characters, or the “boldness factor”. The higher the value, the bolder the character.

Syntax

object.Weight [= number]

The Weight property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression specifying the weight of the font.

Remarks

The Font object isn't directly available at design time. You set the Weight property of the Font object by selecting a control's Font property in the Properties window and clicking the Properties button. You implicitly set the Weight property by selecting an item from the Font Style box in the Font dialog box. The Regular and Italic settings have a Weight value of 400 (the default), and the Bold and Bold Italic settings have a Weight value of 700. At run time, however, you set Weight directly by specifying its setting for the Font object.

If you set a Font object's Weight to a value other than 400 or 700 at run time, Visual Basic converts your value to either 400 or 700, depending on which value is closest to the value you set. The precise ranges are: Weight > 400 and < 551 converts to 400; Weight > 550 converts to 700.


WhatsThisButton Property

Returns or sets a value that determines whether the What's This button appears in the title bar of a Form object. Read-only at run time.

Syntax

object.WhatsThisButton

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The settings for the WhatsThisButton property are:

Setting | Description
True | Turns display of the What's This Help button on.
False | (Default) Turns display of the What's This Help button off.

Remarks

The WhatsThisHelp property must be True for the WhatsThisButton property to be True. In addition, the following properties must also be set as shown:

  • ControlBox property = True

  • BorderStyle property = Fixed Single or Sizable

  • MinButton and MaxButton = False

    – Or –

  • BorderStyle property = Fixed Dialog


WhatsThisHelp Property

Returns or sets a value that determines whether context-sensitive Help uses the What's This pop-up provided by Windows 95 Help or the main Help window. Read-only at run time.

Syntax

object.WhatsThisHelp [= boolean]

The WhatsThisHelp property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
boolean | A value that determines if Help uses the What's This pop-up, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | The application uses one of the What's This access techniques to start Windows Help and load a topic identified by the WhatsThisHelpID property.
False | (Default) The application uses the F1 key to start Windows Help and load the topic identified by the HelpContextID property.

Remarks

There are three access techniques for providing What's This Help in an application. The WhatsThisHelp property must be set to True for any of these techniques to work.

  • Providing a What's This button in the title bar of the form using the WhatsThisButton property. The mouse pointer changes into the What's This state (arrow with question mark). The topic displayed is identified by the WhatsThisHelpID property of the control clicked by the user.

  • Invoking the WhatsThisMode method of a form. This produces the same behavior as clicking the What's This button without using a button. For example, you can invoke this method from a command on a menu in the menu bar of your application.

  • Invoking the ShowWhatsThis method for a particular control. The topic displayed is identified by the WhatsThisHelpID property of the control.


WhatsThisHelpID Property

Returns or sets an associated context number for an object. Use to provide context-sensitive Help for your application using the What's This pop-up in Windows 95 Help.

Syntax

object.WhatsThisHelpID [= number]

The WhatsThisHelpID property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression specifying a Help context number, as described in Settings.

Settings

The settings for number are:

Setting | Description
0 | (Default) No context number specified.
>0 | An integer specifying the valid context number for the What's This topic associated with the object.

Remarks

Windows 95 uses the What's This button in the upper-right corner of the window to start Windows Help and load a topic identified by the WhatsThisHelpID property.


Windowless Property

Returns or sets a value that defines whether a UserControl is assigned a window handle (hWnd) at run time.

Syntax

object.Windowless [= boolean]

The Windowless property syntax has these parts:

Part | Description
object | A UserControl object.
boolean | Determines whether a UserControl's hWnd property returns a valid hWnd.

Settings

The settings for Windowless are:

Setting | Description
True | The UserControl isn’t assigned an hWnd at run time.
False | (Default) The UserControl is assigned an hWnd at run time.

Remarks

You can use the Windowless property to reduce the resource usage of your controls. By default, each instance of a UserControl object is assigned a window handle (referenced in the hWnd property) which consumes system resources. If the Windowless property is set to True, the hWnd property will always return 0.

In general, you should consider setting the Windowless property to True unless you need to access API calls which require an hWnd parameter or unless your control will act as a control container.

This property can only be set at design time.

Note Not all containers support Windowless controls. If a Windowless UserControl is sited on a container that doesn’t support it, it will be assigned an hWnd and the Windowless property will be ignored.


WindowList Property

Returns or sets a value that determines whether a Menu object maintains a list of the current MDI child windows in an MDIForm object. Read only at run time.

Syntax

object.WindowList

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The WindowList property settings are:

Setting | Description
True | The Menu object maintains a list of open windows and displays a check mark next to the active window. Users can click a window name to activate that window.
False | (Default) The Menu doesn't maintain a list of open windows.

Remarks

Many multiple-document interface (MDI) applications, such as Microsoft Excel and Microsoft Word for Windows, have a Window menu containing a list of open MDI child windows. This property enables you to add this functionality to your application.

Only one Menu object on a form can have its WindowList property set to True.

When you select the WindowList check box in the Menu Editor for a Menu object, the list of open MDI child windows for the menu you're creating is displayed.


WindowList Property Example

This example creates some menu commands, illustrates the WindowList menu functionality, and shows how to enable your users to add new forms to a multiple-document interface (MDI) application. To try this example, create an MDIForm object with the Add MDI Form command on the Project menu. On Form1, set the MDIChild property to True, and create a menu named File. Select the WindowList box for the File menu. On your File menu, create a New command, set its Name property to FileMenu, and set its Index property to 0 to create a control array. Paste the code into the Declarations section of the form, and then press F5 to run the program. Choosing the New command on the File menu creates new MDI child forms. Their names are listed at the bottom of the File menu.

Private Sub Form_Load ()
   FileMenu(0).Caption = "&New"   ' Set access key in caption.
   Load FileMenu(1)   ' Create new menu item.
   FileMenu(1).Caption = "-"   ' Set separator.
   Load FileMenu(2)   ' Create new menu item.
   FileMenu(2).Caption = "E&xit"   ' Set caption and access key.
End Sub

Private Sub FileMenu_Click (Index As Integer)
   Select Case Index
      Case 0   ' Select New command.
         Dim NewForm As New Form1   ' Create a duplicate of Form1.
         ' Load NewForm and set a unique caption.
         NewForm.Caption = "Untitled" & Forms.Count
      Case 2   ' Select Exit command.
         End   ' End the program.
   End Select
End Sub


WindowState Property

Returns or sets a value indicating the visual state of a form window at run time.

Syntax

object.WindowState [= value]

The WindowState property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | An integer specifying the state of the object, as described in Settings.

Settings

The settings for value are:

Constant | Value | Description
vbNormal | 0 | (Default) Normal.
vbMinimized | 1 | Minimized (minimized to an icon)
vbMaximized | 2 | Maximized (enlarged to maximum size)

Remarks

Before a form is displayed, the WindowState property is always set to Normal (0), regardless of its initial setting. This is reflected in the Height, Left, ScaleHeight, ScaleWidth, Top, and Width property settings. If a form is hidden after it's been shown, these properties reflect the previous state until the form is shown again, regardless of any changes made to the WindowState property in the meantime.


WindowState Property Example

This example hides a dialog box (Form2) when the parent form (Form1) is minimized and redisplays the dialog box when the parent form is returned to either an original or maximized state. To try this example, paste the code into the Declarations section of Form1 of an application that contains two forms. Press F5 to start the example. Move Form1 so you can see both forms, and then minimize or maximize the form and observe the behavior of Form2.

Private Sub Form_Load ()
   Form2.Show   ' Show Form2.
End Sub

Private Sub Form_Resize ()
   ' If parent form is minimized...
   If Form1.WindowState = vbMinimized Then
 ' ...hide Form2.
      Form2.Visible = False
   ' If parent form isn't minimized...
 Else
      ' ...restore Form2.
  Form2.Visible = True
   End If
End Sub


WordWrap Property

Returns or sets a value indicating whether a Label control with its AutoSize property set to True expands vertically or horizontally to fit the text specified in its Caption property.

Syntax

object.WordWrap [= boolean]

The WordWrap property syntax has these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Boolean | A Boolean expression specifying whether the Label expands to fit the text, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | The text wraps; the Label control expands or contracts vertically to fit the text and the size of the font. The horizontal size doesn't change.
False | (Default) The text doesn't wrap; the Label expands or contracts horizontally to fit the length of the text and vertically to fit the size of the font and the number of lines.

Remarks

Use this property to determine how a Label control displays its contents. For example, a graph that changes dynamically might have a Label containing text that also changes. To maintain a constant horizontal size for the Label and allow for increasing or decreasing text, set the WordWrap and AutoSize properties to True.

If you want a Label control to expand only horizontally, set WordWrap to False. If you don't want the Label to change size, set AutoSize to False.

Note If AutoSize is set to False, the text always wraps, regardless of the size of the Label control or the setting of the WordWrap property. This may obscure some text because the Label doesn't expand in any direction.

If both AutoSize and WordWrap are set to True, text will wrap without increasing the size of the Label control, unless a single word is entered that is larger than the width of the Label. In that case, the AutoSize property takes priority and the width of the Label increases to accommodate the long word.


WordWrap Property Example

This example puts text into two Label controls and uses the WordWrap property to illustrate their different behavior. To try this example, paste the code into the Declarations section of a form that contains two Label controls, and then press F5 and click the form to toggle the WordWrap property setting.

Private Sub Form_Load ()
   Dim Author1, Author2, Quote1, Quote2   ' Declare variables.
   Label1.AutoSize = True   ' Set AutoSize.
   Label2.AutoSize = True
   Label1.WordWrap = True   ' Set WordWrap.
   Quote1 = "I couldn't wait for success, so I went on without it."
   Author1 = "  - Jonathan Winters"
   Quote2 = "Logic is a system whereby one may go wrong with confidence."
   Author2 = "  - Charles Kettering"
   Label1.Caption = Quote1 & Chr(10) & Author1
   Label2.Caption = Quote2 & Chr(10) & Author2
End Sub

Private Sub Form_Click ()
   Label1.Width = 1440   ' Set width to 1 inch in twips.
   Label2.Width = 1440
   Label1.WordWrap = Not Label1.WordWrap ' Toggle WordWrap property.
   Label2.WordWrap = Not Label2.WordWrap
End Sub


X1, Y1, X2, Y2 Properties

Return or set the coordinates of the starting point (X1, Y1) and ending point (X2, Y2) of a Line control. The horizontal coordinates are X1 and X2; the vertical coordinates are Y1 and Y2.

Syntax

object.X1 [= value]

object.Y1 [= value]

object.X2 [= value]

object.Y2 [= value]

The X1, Y1, X2, and Y2 property syntaxes have these parts:

Part | Description
Object | An object expression that evaluates to an object in the Applies To list.
Value | A numeric expression specifying a coordinate.

Remarks

Use these properties to dynamically extend a Line control from one point to another at run time. For example, you can show the relationships of items in one list to items in another list or connect points on a map.


{bmr copyprnt.mrb}X1, Y1, X2, Y2 Properties Example

X1, Y1, X2, Y2 Properties Example

This example displays an animated line that walks down the form when you click the form. To try this example, paste the code into the Declarations section of a form that contains a Timer control and a Line control, and then press F5 and click the form.

Private Sub Form_Load ()
   Timer1.Interval = 100   ' Set Timer interval.
   ' Position the line near the upper-left corner.
 ' Set Line1's properties.
   With Line1
  .X1 = 100
    .Y1 = 100
    .X2 = 500
    .Y2 = 300
 End With
 Timer1.Enabled = False
End Sub

Private Sub Form_Click ()
   Timer1.Enabled = True   ' Start the timer.
End Sub

Private Sub Timer1_Timer ()
   Static Odd   ' Declare variable.
   If Odd Then
      Line1.X2 = Line1.X2 + 250
      Line1.Y2 = Line1.Y2 + 600
   Else
      Line1.X1 = Line1.X1 + 250
      Line1.Y1 = Line1.Y1 + 600
   End If
   Odd = Not Odd   ' Toggle the value.
   ' If the line is off the form, start over.
   If Line1.Y1 > ScaleHeight Then
      Timer1.Enabled = False   ' Wait for another click.
     With Line1
   .X1 = 100
       .Y1 = 100
     .X2 = 500
     .Y2 = 300
  End With
      Odd = False
   End If
End Sub


Zoom Property

Returns or sets the percentage by which printed output is to be scaled up or down. Not available at design time.

Syntax

object.Zoom [= number]

The Zoom property syntax has these parts:

Part | Description
object | An object expression that evaluates to an object in the Applies To list.
number | A numeric expression that evaluates to the percentage by which printed output is to be scaled. The default is 0, which specifies that the printed page appears at its normal size.

Remarks

The Zoom property setting scales the size of the physical page up or down, by a factor of Zoom/100, to the apparent size of the printed output. For example, a letter-size page printed with Zoom set to 50 contains as much data as a page of the size 17 by 22 inches because the printed text and graphics are scaled to one-half their original height and width.

Note The effect of the properties of the Printer object depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different property settings may all have the same effect. Settings outside the accepted range may or may not produce an error. For more information, see the manufacturer's documentation for the specific driver.


Add-In Manager Dialog Box

Allows you to register an add-in, load or unload it, and set its load behavior. To open the Add-In Manager, choose Add-In Manager from the Tools menu.

Dialog Box Options

Add-Ins List

  • Available Add-Ins — Lists available add-ins.

  • Load Behavior — Displays the load behavior for the selected add-in.

Description

Displays a description of what the add-in does.

Load Behavior

  • Loaded/Unloaded — Loads or unloads the selected add-in.

  • Load On Startup — Loads selected add-in on startup of development environment.

  • Command Line — Loads the selected add-in when the development environment is started from the command prompt or from a script.

OK

Updates the load behavior of selected add-ins.

Cancel

Cancels all updates made in session.


References Dialog Box

Allows you to select another application's objects that you want available in your code by setting a reference to that application's object library.

Dialog Box Options

Available References

Lists the references available to your project.

  • After you set a reference to an object library by selecting the check box next to its name, you can find a specific object and its methods and properties in the Object Browser.

  • If you are not using any objects in a referenced library, you should clear the check box for that reference to minimize the number of object references Visual Basic must resolve, thus reducing the time it takes your project to compile. You can't remove a reference for an item that is used in your project.

  • If you remove a reference to an object that your are currently using in your project, you will receive an error the next time you refer to that object.

  • References not in use are listed alphabetically.

    Note You can't remove the "Visual Basic For Applications" and "Visual Basic objects and procedures" references, because they are necessary for running Visual Basic.

Priority Buttons

Moves references up, [image], and down, [image], on the list. When you refer to an object in code, Visual Basic searches each referenced object selected in the References dialog box in the order the referenced objects are displayed. If two referenced objects use the same name, Visual Basic uses the definition provided by the referenced object listed higher in the Available References box.

Result

Displays the name and path of the reference selected in the Available References box, as well as the language version.

Browse

Displays the Add Reference dialog box so that you can search other directories for and add references to the Available Resources box for the following types:

  • Type Libraries(*.olb, *.tlb, *.dll)

  • Executable Files (*.exe, *.dll)

  • ActiveX Controls (*.ocx)

  • All Files (*.*)

    The Add References dialog box is the Open common dialog box.


Add Watch Dialog Box

Use to enter a watch expression. The expression can be a variable, a property, a function call, or any other valid Basic expression. Watch expressions are updated in the Watch window each time you enter break mode or after execution of each statement in the Immediate window.

You can drag selected expressions from the Code window into the Watch window.

Important When selecting a context for a watch expression, use the narrowest scope that fits your needs. Selecting all procedures or all modules could slow down execution considerably, since the expression is evaluated after execution of each statement. Selecting a specific procedure for a context affects execution only while the procedure is in the list of active procedure calls, which you can see by choosing the Call Stack command on the View menu.

Dialog Box Options

Expression

Displays the selected expression by default. The expression is a variable, a property, a function call, or any other valid expression. You may enter a different expression to evaluate.

Context

Sets the scope of the variables watched in the expression.

  • Procedure — Displays the procedure name where the selected term resides (default). Defines the procedure(s) in which the expression is evaluated. You may select all procedures or a specific procedure context in which to evaluate the variable.

  • Module — Displays the module name where the selected term resides (default). You may select all modules or a specific module context in which to evaluate the variable.

  • Project — Displays the name of the current project. Expressions can't be evaluated in a context outside of the current project.

Watch Type

Determines how Visual Basic responds to the watch expression.

  • Watch Expression — Displays the watch expression and its value in the Watch window. When you enter break mode, the value of the watch expression is automatically updated.

  • Break When Value Is True — Execution automatically enters break mode when the expression evaluates to true or is any nonzero value (not valid for string expressions).

  • Break When Value Changes — Execution automatically enters break mode when the value of expression changes within the specified context.


Advanced Options Tab

Advanced Tab (Options Dialog Box)

Allows you to specify the settings for various advanced features as they apply to the current Visual Basic project.

Tab Options

Background Project Load

Determines whether code is loaded in the background, returning control to the developer more quickly.

Notify when changing shared project items

Determines whether you will be notified when you change a shared project item such as a form or module and try to save it.

Several projects can share the same items. Shared items are loaded into memory and each project has its own copy. If you change a shared item in one project, the other projects retain the copy of the item that was loaded until you save the projects. Then, the last project you save determines what the shared file is. When this option is selected, you are asked if you want to synchronize all of the copies of the item before you save.

SDI Development Environment

When selected changes the development environment from a multiple document interface (MDI) to a single document interface (SDI). When you select this option, the SDI appears every time you restart Visual Basic until you clear this option.


Calls Dialog Box

Displays a list of currently active procedure calls during break mode. When executing code in a procedure, that procedure is added to a list of active procedure calls. Each time a procedure calls another procedure, it is added to the list. Called procedures are removed from the list when execution returns to the calling procedure. Procedures called from the Immediate window are also added to the calls list.

Dialog Box Options

Project Module Function

Lists the procedures.

Show

Moves the insertion point to the location where the call was made and turns on the Call Stack indicator, [image].


Code Window

Use the Code window to write, display, and edit Visual Basic code. You can open as many Code windows as you have modules, so you can easily view the code in different forms or modules, and copy and paste between them.

You can open a Code window from:

  • The Project window, by selecting a form or module, and choosing the View Code button.

  • A Form window, by double-clicking a control or form, choosing Code from the View menu, or pressing F7.

You can drag selected text to:

  • A different location in the current Code window.

  • Another Code window.

  • The Immediate and Watch windows.

  • The Recycle Bin.

Window Elements

Object Box

Displays the name of the selected object. Click the arrow to the right of the list box to display a list of all objects associated with the form.

Procedures/Events Box

Lists all the events recognized by Visual Basic for a form or control displayed in the Object box. When you select an event, the event procedure associated with that event name is displayed in the Code window.

If (General) is displayed in the Object box, the Procedure box lists any declarations and all of the general procedures that have been created for the form. If you are editing module code, the Procedure box lists all of the general procedures in the module. In either case, the procedure you select in the Procedure box is displayed in the Code window.

All the procedures in a module appear in a single, scrollable list that is sorted alphabetically by name. Selecting a procedure using the drop down list boxes at the top of the Code window moves the cursor to the first line of code in the procedure you select.

Split Bar

Dragging this bar down, splits the Code window into two horizontal panes, each of which scrolls separately. You can then view different parts of your code at the same time. The information that appears in the Object box and Procedures/Events box applies to the code in the pane that has the focus. Dragging the bar to the top or the bottom of the window or double-clicking the bar closes a pane.

Margin Indicator Bar

A gray area on the left side of the Code window where margin indicators are displayed.

Procedure View Icon

Displays the selected procedure. Only one procedure at a time is displayed in the Code window.

Full Module View Icon

Displays the entire code in the module.


Color Palette

Changes the colors of a form or control and sets up a custom color scheme.

The Color Palette consists of:

Displays the currently selected foreground and background colors for the form or control.

Displays the currently selected foreground and background colors for any text in the form or control.

Note If Microsoft Windows doesn't display the text and background colors that you've selected, it may be because one of the colors you've selected is dithered (a color comprised of up to three different colored pixels). When displaying text in Microsoft Windows, the text and the area immediately behind it must be solid colors. If you choose a dithered color for either the text or the background color, the nearest solid color is used.

Displays a set of colors.

Uses the colors specified in the Control Panel.

Displays or sets custom colors.

Displays the Define Color dialog box so you can create custom colors.

Note You can also set the colors for forms and controls with the BackColor or ForeColor property.


Debug Menu

Step Into

Step Over

Step Out

Run To Cursor

Add Watch

Edit Watch

Quick Watch

Toggle Breakpoint

Clear All Breakpoints

Set Next Statement

Show Next Statement


Data Environment Designer

The Data Environment designer provides an interactive, design time environment for creating programmatic run-time data access. At design time, you set property values for Connection and Command objects, write code to respond to ActiveX® Data Object (ADO) events, execute commands, and create aggregates and hierarchies. You can also drag Data Environment objects onto forms or reports to create data-bound controls.

Shortcut Menus

You can access a shortcut menu by right-clicking any object within the Data Environment designer.

DataEnvironment Object Shortcut Menu

The DataEnvironment object shortcut menu contains the following items:

Expand All

Expands the Outline view of the Data Environment designer, showing all Connection and Command objects within the current DataEnvironment object.

Collapse All

Collapses the Outline view of the Data Environment designer.

Arrange by Object

Displays all objects within the Data Environment designer arranged by the categories of Connection and Command.

Arrange by Connection

Displays the objects grouped by connection, with all the Command objects listed beneath the Connection object to which they are associated.

Add Connection

Adds a new Connection object to the Data Environment designer.

Add Command

Adds a new Command object to the Data Environment designer.

Insert Stored Procedures

Accesses the Insert Stored Procedures dialog box. From this dialog box, you can create one or more Command objects from a list of stored procedures that are available in each Connection object.

View Code

Accesses the Code Editor window for the current DataEnvironment object.

Show Fields

When selected, the Field objects appear beneath their associated Command objects in the Data Environment Outline view. (Default)

Options

Accesses the Data Environment Options dialog box. From this dialog box, you can change the global settings of the Data Environment, such as field mapping settings and whether warning messages display.

Command Object Shortcut Menu

The Command object shortcut menu contains the following items:

Expand All

Expands the Outline view of the current Command object, showing all Field and Parameter objects.

Note If Show Fields is not selected on the General tab of the Options dialog box, no Field objects display.

Collapse All

Collapses the Outline view of the current Command object, hiding all Field and Parameter objects.

Delete

Deletes the currently selected Command object. Since the deletion permanently removes the object from the DataEnvironment object a confirmation message box appears, if specified. Once the deletion is confirmed, the Command object is removed from the DataEnvironment object.

Rename

Renames a Command object. When a Command object is renamed, its link to the Connection object and other Command objects is maintained.

Note Each object within the Data Environment designer must have a unique name. For example, if you are creating a Command object based on a customers' table, a logical name would be "Customers."

Refresh

Refreshes a Command object, rebuilding all its stored meta-data, such as Field and Parameter objects. Any changes to the table or stored procedure's definition is reflected in the Command object after the refresh.

Caution User-defined property settings are lost during the refresh. For Fields, the Control and Caption properties are reset to their defaults. For Parameters, the Name, Direction, DataType, Precision, Scale, Size, and HostDataType properties are reset.

Add Child Command

Adds a child Command object to the current Command object.

Use the Relation tab of the Command Properties dialog box to specify the parameters that relate these two Command objects.

View Code

Accesses the Code Editor window for the currently selected Command object.

Debug

Uses the T-SQL Debugger to debug a stored procedure.

Design

Accesses the Structured Query Language (SQL) query designer for a Command object when the command source is text.

Properties

Accesses the Command Properties dialog box, from which you can specify general, parameter, relation, grouping, aggregate, and advanced management information for the current Command object.

Hierarchy Info

Accesses the Hierarchy Information dialog box, which enables you to view the Shape command and ADO hierarchy information for the current Command object. This is disabled if the Command object is not in a relation hierarchy.

Connection Object Shortcut Menu

The Connection object shortcut menu contains the following items:

Expand All

Expands the Outline view of the current Connection object, showing all associated Command objects.

Collapse All

Collapses the Outline view of the Connection object, hiding all Command objects within the current Connection object.

Delete

Deletes the currently selected Connection object. Since the deletion permanently removes the object from the DataEnvironment object a confirmation message box appears, if specified. Once the deletion is confirmed, the Connection object is removed from the DataEnvironment object.

Rename

Renames a Connection object. When a Connection object is renamed, any Command objects associated with it are automatically updated.

Note Each object within the Data Environment designer must have a unique name. For example, if you are creating a connection based on the Northwind database, a logical name would be "Northwind."

Refresh

Refreshing a Connection object clears the internal cache of the list tables and stored procedures associated with the connection. After a Connection object is refreshed, this list is rebuilt the next time you drop down a list of tables or stored procedures.

Add Command

Adds a Command object to the DataEnvironment object and associates it with the current Connection object. The Command Properties dialog box automatically appears.

Insert Stored Procedures

When clicked, the Insert Stored Procedures dialog box appears. From this dialog box, you can insert one or more Command objects from a list of stored procedures that are available from each Connection object.

View Code

Accesses the Code Editor window for the currently selected Connection object.

Properties

In Visual Basic, accesses the Data Link Properties dialog box, from which you can specify provider, connection, advanced, and view all initialization properties for the current Connection object.

In Visual InterDev, accesses the Connection Properties dialog box, from which you can specify general, authentication, and miscellaneous information for the current Connection object.

Field Object Shortcut Menu

The Field object shortcut menu contains the following items:

Properties

Accesses the Field Properties dialog box, from which you can view general information, or set the Caption and Control properties for the current Field object.

View Code

Accesses the Code Editor window for the currently selected Field object.


Editor Format Tab (Options Dialog Box)

Specifies the appearance of your Visual Basic code.

Tab Options

Code Colors

Determines the foreground and background colors used for the type of text selected in the list box.

  • Text List — Lists the text items that have customizable colors.

  • Foreground — Specifies the foreground color for the text selected in the Color Text List.

  • Background — Specifies the background color for text selected in the Color Text List.

  • Indicator — Specifies the margin indicator color.

Font

Specifies the font used for all code.

Size

Specifies the size of the font used for code.

Margin Indicator Bar

Makes the margin indicator bar visible or not visible.

Sample

Displays sample text for the font, size, and color settings.


Edit Watch Dialog Box

Use to delete or edit the context or type of a watch expression.

Important When selecting a context for a watch expression, use the narrowest scope that fits your needs. Selecting all procedures or all modules could slow down execution considerably, since the expression is evaluated after execution of each statement. Selecting a specific procedure for a context affects execution only while the procedure is in the list of active procedure calls.

Dialog Box Options

Expression

Displays the selected expression by default. The expression is a variable, a property, a function call, or any other valid expression. You may enter a different expression to evaluate.

Context

Sets the scope of the variables watched in the expression.

  • Procedure — Displays the procedure name where the selected term resides (default). Defines the procedure(s) in which the expression is evaluated. You may select all procedures or a specific procedure context in which to evaluate the variable.

  • Module — Displays the module name where the selected term resides (default). You may select all modules or a specific module context in which to evaluate the variable.

  • Project — Displays the name of the current project. Expressions can't be evaluated in a context outside of the current project.

Watch Type

Determines how Visual Basic responds to the watch expression.

  • Watch Expression — Displays the watch expression and its value in the Watch window. When you enter break mode, the value of the watch expression is automatically updated.

  • Break When Value Is True — Execution automatically enters break mode when the expression evaluates to true or is any nonzero value (not valid for string expressions).

  • Break When Value Changes — Execution automatically enters break mode when the value of expression changes within the specified context.

Delete

Deletes the watch expression.


Environment Options Tab

Environment Tab (Options Dialog Box)

Specifies the attributes of your Visual Basic development environment.

Changes made in this dialog box are saved in the registry file, and are loaded every time you restart Visual Basic.

Tab Options

When Visual Basic starts

  • Prompt for project — Asks you for the project you want to open each time you start Visual Basic.

  • Create default project — Creates a default executable (EXE) project that opens each time you start Visual Basic.

When a program starts

  • Save Changes — Automatically saves the changes without prompting you when you make changes to a project and then press F5 to run it or choose the Start command from the Run menu. If you have a new file, the Save As common dialog box appears so you can give a name and location for your project.

  • Prompt To Save Changes — Always displays a dialog box asking if you want to save the changes to your project when you press F5 to run it or choose the Start command from the Run menu. If you select Yes, the Save As common dialog box appears so you can give a name and location for your project. If you select No, Visual Basic runs the project using the memory image, but does not save any changes.

  • Don't Save Changes — When you run your project, Visual Basic runs the memory version and does not save the changes.

Show Templates For:

Allows you to determine which templates you want visible in the Add <item> dialog box when you add an item to a project. If cleared, a blank form appears when you choose the Add <item> command.

  • Forms

  • MDI Forms

  • Modules

  • Class Modules

  • User Controls

  • Property Pages

  • User Documents

Templates Directory

Lists the location of the template files.


Editor Options Tab

Editor Tab (Options Dialog Box)

Specifies the code window and project window settings.

Tab Options

Code Settings

  • Auto Syntax Check — Determines whether Visual Basic should automatically verify correct syntax after you enter a line of code.

  • Require Variable Declaration — Determines whether explicit variable declarations are required in modules. Selecting this adds the Option Explicit statement to general declarations in any new module.

  • Auto List Members — Displays a box that displays information that would logically complete the statement at the current insertion point.

  • Auto Quick Info — Displays information about functions and their parameters.

  • Auto Data Tips — In the Code window while in Break mode, displays the value of the variable or object property over which your cursor is placed. The display is limited to variables and objects that are in the current scope.

    Data Tips are also available in the Immediate window while in Break mode. The values for object properties are displayed regardless of scope if a fully qualified object name is provided.

  • Auto Indent — Allows you to tab the first line of code; all subsequent lines will start at that tab location.

  • Tab Width — Sets the tab width, which can range from 1 to 32 spaces; the default is 4 spaces.

Window Settings

  • Drag-and-Drop Text Editing — Allows you to drag and drop elements within the current code and from the Code window into the Immediate or Watch windows.

  • Default to Full Module View — Sets the default state for new modules to allow you to look at procedures in the Code window either as a single scrollable list or one procedure at a time. It does not change the way currently open modules are viewed.

  • Procedure Separator — Allows you to display or hide separator bars that appear at the end of each procedure in the Code window. Only available if Default to Full Module View is checked.


Form Layout Window

Allows you to visually position your forms at design time.

All forms that are visible in the environment are displayed. When you place your cursor over a form, it changes to a [image]. If you press the mouse button you can position the form where you want it to appear at run time.

When you re-size the Form Layout window, each form is sized relative to the size of your design window. The upper left corner of the client area represents the coordinates – 0,0 – of the desktop. You can change the resolution using the Resolutions Guides command on the shortcut menu.


Form Window

Allows you to create the windows, dialog boxes, and controls in your application. You draw and view controls on a form.

While you are designing a form:

  • Each form window has a Maximize, Minimize, and Close button.

  • You can create either fixed or movable forms. The form you design will have the same features at design time and at run time unless you specify otherwise in the form's properties.

  • Use the buttons in the Toolbox to draw controls on the form.

  • Use the Form Layout Window command from the View menu to preview the layout of your form on a screen.


Immediate Window

Automatically opens in break mode and is empty.

You can:

  • Type or paste a line of code and press ENTER to run it.

  • Copy and paste the code from the Immediate window into the Code window but you cannot save code in the Immediate window.

The Immediate window can be dragged and positioned anywhere on your screen unless you have made it a dockable window from the Docking Tab of the Options dialog box.

You can close the window by clicking the Close box. If the Close box is not visible, double-click the Title bar to make the Close box visible, then click it.

Note In break mode, a statement in the Immediate window is executed in the context or scope that is displayed in the Procedure box. For example, if you type Print variablename, your output is the value of a local variable. This is the same as if the Print method had occurred in the procedure you were executing when the program halted.


Quick Watch Dialog Box

Displays the current value of a selected expression. This functionality is useful when debugging your code if you want to see the current value of a variable, property, or other expression.

Dialog Box Options

Current Context

Lists the names of the project, module, and procedure where the watch expression resides.

Expression

Shows the selected expression.

Value

Shows the value of the selected expression. The current value isn't displayed if the expression context isn't within a procedure listed in the Calls dialog box.

Add

Adds the expression to the Watch window.


Locals Window

Automatically displays all of the declared variables in the current procedure and their values.

When the Locals window is visible, it is automatically updated every time there is a change from Run to Break mode or you navigate in the stack display.

You can:

  • Resize the column headers by dragging the border to the right or the left.

  • Close the window by clicking the Close box. If the Close box is not visible, double-click the Title bar to make the Close box visible, then click it.

Window Elements

Calls Stack Button

Opens the Call Stack dialog box which lists the procedures in the call stack.

Expression

Lists the name of the variables.

The first variable in the list is a special module variable and can be expanded to display all module level variables in the current module. For a class module, the system variable <Me>is defined. For standard modules, the first variable is the <name of the current module>. Global variables and variables in other projects are not accessible from the Locals window.

You cannot edit data in this column.

Value

List the value of the variable.

When you click on a value in the Value column, the cursor changes to an I-beam. You can edit a value and then press ENTER, the UP ARROW key, the DOWN ARROW key, TAB, SHIFT+TAB, or click on the screen to validate the change. If the value is illegal, the Edit field remains active and the value is highlighted. A message box describing the error also appears. Cancel a change by pressing ESC.

All numeric variables must have a value listed. String variables can have an empty Value list.

Variables that contain subvariables can be expanded and collapsed. Collapsed variables do not display a value but each subvariable does. The expand icon, [image] and the collapse icon, [image] appear to the left of the variable.

Type

Lists the variable type. You cannot edit data in this column.


Member Options Dialog Box

Allows you to add Help information or comments about the procedures, that you define in your project.

Dialog Box Options

Member Name

Displays the name of the item selected in the Classes or the Members of list.

Description

Allows you to specify a string that shows up in the Details pane of the Object Browser.

Help File

Displays the Help file associated with the item listed in the Member Name box. This is set in the Help File Name box in the General tab of the Project Properties dialog box.

Help Context ID

Assigns a unique numeric value for the context ID. This value is used to find the appropriate Help topic in the file listed in the Help File box when the user presses F1 or the [image] button while looking at the procedure in the Object Browser.


Menu Bar

Lists the menus that you can use in the active window.

The Visual Basic menu bar contains the names of the menus you can use in the active window. You can modify the menu bar using the Commands tab of the Customize dialog box.

Note You cannot delete the menu bar.


Menu Editor Dialog Box

Allows you to create custom menus for your application and to define their properties.

Dialog Box Options

Caption

Allows you to enter the menu or command name that you want to appear on your menu bar or in a menu.

If you want to create a separator bar in your menu, type a single hyphen (-) in the Caption box.

To give the user keyboard access to a menu item, insert an ampersand (&) before a letter. At run time, this letter is underlined (the ampersand is not visible), and the user can access the menu or command by pressing ALT and the letter. If you need an ampersand to show in the menu, put two consecutive ampersands in the caption.

Name

Allows you to enter a control name for the menu item. A control name is an identifier used only to access the menu item in code; it doesn't appear in a menu.

Index

Allows you to assign a numeric value that determines the control's position within a control array. This position isn't related to the screen position.

Shortcut

Allows you to select a shortcut key for each command.

HelpContextID

Allows you to assign a unique numeric value for the context ID. This value is used to find the appropriate Help topic in the Help file identified by the HelpFile property.

NegotiatePosition

Allows you to select the menu's NegotiatePosition property. This property determines whether and how the menu appears in a container form.

Checked

Allows you to have a check mark appear initially at the left of a menu item. It is generally used to indicate whether a toggle option is turned on or off.

Enabled

Allows you to select whether you want the menu item to respond to events, or clear if you want the item to be unavailable and appear dimmed.

Visible

Allows you to have the menu item appear on the menu.

WindowList

Determines if the menu control contains a list of open MDI child forms in an MDI application.

Right Arrow

Moves the selected menu down one level each time you click it. You can create up to four levels of submenus.

Left Arrow

Moves the selected menu up one level each time you click it. You can create up to four levels of submenus.

Up Arrow

Moves the selected menu item up one position within the same menu level each time you click it.

Down Arrow

Moves the selected menu item down one position within the same menu level each time you click it.

Menu List

A list box that displays a hierarchical list of menu items. Submenu items are indented to indicate their hierarchical position or level.

Next

Moves selection to the next line.

Insert

Inserts a line in the list box above the currently selected line

Delete

Deletes the currently selected line.

OK

Closes the Menu Editor and applies all changes to the last form you selected. The menu is available at design time, but selecting a menu at design time opens the Code window for that menu's Click event rather than executing any event code.

Cancel

Closes the Menu Editor and cancels all changes.


Object Browser

Displays the classes, properties, methods, events, and constants available from object libraries and the procedures in your project. You can use it to find and use objects you create, as well as objects from other applications.

You can get Help for the Object Browser by searching for Object Browser in Help.

Window Elements Project/Library Box

Displays the currently referenced libraries for the active project. You can add libraries in the References dialog box. <All Libraries> allows all of the libraries to be displayed at one time.

Search Text Box

Contains the string that you want to use in your search. You can type or choose the string you want. The Search Text box contains the last 4 search strings that you entered until you close the project. You can use the standard Visual Basic wildcards when typing a string.

If you want to search for a whole word, you can use the Find Whole Word Only command from the shortcut menu.

Go Back Button

Allows you to go back to the previous selection in the Classes and Members of lists. Each time you click it you move back one selection until all of your choices are exhausted.

Go Forward Button

Allows you to repeat your original selections in the Classes and Members of lists each time you click it, until you exhaust the list of selections.

Copy to Clipboard Button

Copies the current selection in the Members of list or the Details pane text to the Clipboard. You can then paste the selection into your code.

View Definition Button

Moves the cursor to the place in the Code window where the selection in the Members of list or the Classes list is defined.

Help Button

Displays the online Help topic for the item selected in the Classes or the Members of list. You can also use F1.

Search Button

Initiates a search of the libraries for the class or property, method, event or constant that matches the string you typed in the Search Text box, and opens the Search Results pane with the appropriate list of information.

Show/Hide Search Results Button

Opens or hides the Search Results pane. The Search Results pane changes to show the search results from the project or library chosen in the Project/Library list. Search results are listed alphabetically from A to Z.

Search Results List

Displays the library, class, and member that corresponds to the items that contain your search string. The Search Results pane changes when you change the selection in the Project/Library box.

Classes List

Displays all of the available classes in the library or project selected in the Project/Libraries box. If there is code written for a class, that class appears in bold. The list always begins with <globals>, a list of globally accessible members.

If you select a Class and do not specify a member, you will get the default member if one is available. The default member is identified by an asterisk (*) or by the default icon specific to the member.

Members of List

Displays the elements of the class selected in the Classes pane by group and then alphabetically within each group. Methods, properties, events, or constants that have code written for them appear bold. You can change the order of this list with the Group Members command on the Object Browser shortcut menu.

Details Pane

Shows the definition of the member. The Details pane contains a jump to the class or library to which the element belongs. Some members have jumps to their parent class. For example, if the text in the Details pane states that Command1 is declared as a command button type, clicking on command button takes you to the Command Button class.

You can copy or drag text from the Details pane to the Code window.

Split Bar

Splits the panes so that you can adjust their size. There are splits between the:

  • Classes box and the Members of box.

  • Search Results list and the Classes and Members of boxes.

  • Classes and Members of boxes and the Details pane.


Project Explorer

Displays a hierarchical list of the projects and all of the items contained in a project.

Window Elements

View Code

Displays the Code window so you can write and edit code associated with the selected item.

View Object

Displays the Object window for the selected item, an existingform, module, ActiveX object, or user control

Toggle Folders

Hides and shows the object folders while still showing the individual items contained within them.

List window

Lists the all loaded projects and the items included in each project.

  • Project.

    The project and items contained within it.

    • Forms

      All .frm files associated with the project.

    • Modules

      All .bas modules for the project.

    • Class Modules

      All .cls files for the project.

    • User Controls

      All user controls for the project.

    • User Documents

      All document objects, .dob files, in the project.

    • Property Pages

      All property pages, .pag files, in the project.

    • ActiveX Designers

      All designers, .dsr files, in the project.

    • Related Documents

      Lists all documents to which you want a pointer. The path to the document is stored rather than the document itself. When you click View Object, Visual Basic searches the registry for the document type and executes the appropriate open command. You can place any valid document type in the project.

    • Resources

      Lists all of the resources you have in your project.

Note A check mark to the left of a filename in the Project Explorer indicates that the file is checked out of a version control project, and currently has read/write status. The check mark is only displayed if you are connected to a version control program, such as Microsoft Visual SourceSafe, which is included with the Enterprise Edition of Visual Basic.


Properties Window

Lists the design-time properties for selected objects and their current settings. You can change these properties at design time. When you select multiple controls, the Properties window contains a list of the properties common to all the selected controls.

Window Elements

Object Box

Lists the currently selected object. Only objects from the active form are visible. If you select multiple objects, the properties common to the objects and their settings, based on the first object selected, appear on the Properties List tabs.

Properties List Tabs

  • Alphabetic Tab — Alphabetically lists all properties for the selected object that can be changed at design time, as well as their current settings. You can change the property setting by selecting the property name and typing or selecting the new setting.

  • Categorized Tab — Lists all properties for the selected object by category. For example, BackColor, Caption, and ForeColor are in the Appearance category. You can collapse the list so that you see the categories or you can expand a category to see the properties. When you expand or collapse the list, you see a plus (+) icon or minus (-) icon to the left of the category name.

Description Pane

Shows the property type and a short description of the property. You can turn the description of the property off and on using the Toggle Status command on the shortcut menu. You can move through the list of descriptions by pressing the ARROW keys.


Toolbox

Displays the standard Visual Basic controls plus any ActiveX controls and insertable objects you have added to your project. You can:

  • Display ToolTips for the Toolbox buttons by selecting the Show ToolTips option in the General tab of the Options dialog box.

  • Customize the Toolbox by adding tabs to it.

    When you add a tab, a Pointer is always available on it.

  • Customize the General tab or a custom tab by adding controls using the Components command from the Project menu.

Standard Toolbox Controls

Pointer

The only item in the Toolbox that doesn't draw a control. When you select the pointer, you can only resize or move a control that has already been drawn on a form.

PictureBox

Displays graphical images (either decorative or active), as a container that receives output from graphics methods, or as a container for other controls.

Label

Allows you to have text that you don't want the user to change, such as a caption under a graphic.

TextBox

Holds text that the user can either enter or change.

Frame

Allows you to create a graphical or functional grouping for controls. To group controls, draw the Frame first, and then draw controls inside the frame.

CommandButton

Creates a button the user can choose to carry out a command.

CheckBox

Creates a box that the user can easily choose to indicate if something is true or false, or to display multiple choices when the user can choose more than one.

OptionButton

Allows you to display multiple choices from which the user can choose only one.

ComboBox

Allows you to draw a combination list box and text box. The user can either choose an item from the list or enter a value in the text box.

ListBox

Used to display a list of items from which the user can choose one. The list can be scrolled if it has more items than can be displayed at one time.

HScrollBar (horizontal scroll bar)

Provides a graphical tool for quickly navigating through a long list of items or a large amount of information, for indicating the current position on a scale, or as an input device or indicator of speed or quantity.

VScrollBar (vertical scroll bar)

Provides a graphical tool for quickly navigating through a long list of items or a large amount of information, for indicating the current position on a scale, or as an input device or indicator of speed or quantity.

Timer

Generates timer events at set intervals. This control is invisible at run time.

DriveListBox

Displays valid disk drives.

DirListBox (directory list box)

Displays directories and paths.

FileListBox

Displays a list of files.

Shape

Allows you to draw a variety of shapes on your form at design time. You can choose a rectangle, rounded rectangle, square, rounded square, oval, or circle.

Line

Used to draw a variety of line styles on your form at design time.

Image

Displays a graphical image from a bitmap, icon, or metafile on your form. Images displayed in an Image control can only be decorative and use fewer resources than a PictureBox.

Data

Provides access to data in databases through bound controls on your form.

OLE

Allows you to link and embed objects from other applications in your Visual Basic application.


Watch Window

Appears automatically when watch expressions are defined in the project.

You can:

  • Change the size of the column headers by dragging its border to the right to make it larger or to the left to make it smaller.

  • Drag a selected variable to the Immediate window or the Watch window.

  • Close the window by clicking the Close box. If the Close box is not visible, double-click the Title bar to make the Close box visible, then click it.

Window Elements

Expression

Lists the watch expression with the Watch icon, [image] on the left.

Value

List the value of the expression at the time of the transition to break mode.

You can edit a value and then press ENTER, the UP ARROW key, the DOWN ARROW key, TAB, SHIFT+TAB, or click somewhere on the screen to validate the change. If the value is illegal, the Edit field remains active and the value is highlighted. A message box describing the error also appears. Cancel a change by pressing ESC.

Type

Lists the expression type.

Context

Lists the context of the watch expression.

If the context of the expression isn't in scope when going to break mode, the current value isn't displayed.

You can close the window by clicking the Close box. If the Close box is not visible, double-click the Title bar to make the Close box visible, then click it.


Webclass Designer

Allows you to design a webclass that responds to user requests from the browser. Using the designer, you can:

  • Define the contents of the webclass. A webclass contains webitems, which are the HTML pages and other items that the webclass can send to the browser in response to a user request.

  • Add events to the webitems in the webclass.

  • Write code for each event in the webclass.

There are two panels in the Webclass designer: the Treeview panel and the Detail panel.

Treeview Panel

The Treeview panel displays each webitem and connected event in the webclass. There are two kinds of webitems:

  • HTML Template WebItems — HTML files that can be sent to the browser in response to a request

  • Custom WebItems — programmatic resources that contain related event procedures you want the webclass to be able to access at run time.

Detail Panel

The Detail panel displays information about the currently selected item in the treeview. The view varies depending on what type of item you have selected.

  • If you select the webclass, the Detail panel shows the Template and Custom WebItems folders.

  • If you select the HTML Template WebItems folder, the Detail panel shows the name and location of each template associated with the webclass.

  • If you select the Custom WebItems folder, the Detail panel shows the name of each custom webitem in the webclass.

  • If you select a template file, the Detail panel shows the attributes of HTML tags in the template that can be treated as events. You must connect these attributes before they can be programmed.

  • If you select a custom webitem, the Detail panel shows any custom events that have been linked to that webitem, or is blank if there are no custom events.


AXData (AXData.vbg)

The AXData sample demonstrates how to create ActiveX components that can act as data sources for other controls or objects. It includes a UserControl that mimics the ADOData control, plus an ActiveX DLL data source that demontrates the use of an OLE DB Simple Provider. For step-by-step instructions on creating this sample, see "Creating Data Sources," in Creating ActiveX Components.

File | Description
MyDataControl.vbp | Project file for the ActiveX data source control.
MyData.ctl | User control for the MyDataControl project.
DataSourceTest.vbp | Test project for demonstrating ActiveX data sources.
DataSourceTest.frm | Form for the DataSourceTest project.
MyDataComponent.vbp | Project file for the ActiveX data source DLL.
MyOSPObject.cls | Class to implement an OLE DB Simple Provider.
MyDataSource.cls | Class to act as a data source for the MyDataComponent project.
Customer.txt | Data file for the OLE DB Simple Provider.

To Run

From the Visual Basic File menu, choose Open Project and select the AXData.vbg file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


Callback Sample Application (Clbk_Svr.vbp and Clbk_Cli.vbp), Enterprise Edition

This sample demonstrates the use of an ActiveX object pointer being passed to an external (and optionally remote) ActiveX server component. The server then periodically calls a method on this object pointer. This has the effect of a server-initiated callback to the client, which can be a much better application model than the polling a client application might have to do otherwise to find the status of a server. Although this demo simply returns the time to the client, it could just as easily return data, news, or other information it has been told the client wants to know. The benefit here is that the server does all the work looking for data the client might need and the client does other work, only being interrupted when the server actually has something that interests it.

The server in this project uses a visible form purely for demonstration purposes. There is no functional need for the server to have any UI, though state information presented through a UI can help with debugging or run-time monitoring needs. (Note, state monitoring requirements could also be addressed by providing a status method on the server that could be queried by a monitor application.)

File | Description
Clbk_cli.vbp | Client component project file.
Clbk_cli.frm | Client main form.
Clbk_cli.bas | Client main/global utility module.
Clbk_cli.cls | Client class module.
Clbk_svr.vbp | Server component project file.
Clbk_svr.frm | Server status indicator form.
Clbk_svr.bas | Server main/global utility module.
Clbk_svr.cls | Server class module.
Callback.txt | A text file containing a project overview and description.

To Run

From the Visual Basic File menu, choose Open Project and select the Clbk_svr.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the server project.

Once running, this project temporarily registers its classes in the system registry. You can then start a second instance of Visual Basic to run Clbk_cli.vbp, the client that uses the class modules defined in Clbk_svr.vbp.

Note The Automation server can be run on the same machine as the client, or it can be run on a remote machine to benefit from distributed processing power and support multi-user access. The Automation server does not need to be recompiled or changed in any way to support this location independence.


Coffee (Coffee2.vbp, CoffWat2.vbp, MTCoffee.vbp, XTimers.vbp)

Coffee consists of a client, CoffWat2, and two ActiveX components (OLE servers), Coffee2 and MTCoffee. Together, these three projects demonstrate:

  • Asynchronous notifications using events (Coffee2).

  • Asynchronous notifications using call-back methods (Coffee2).

  • Multithreading (MTCoffee).

XTimers.vbp is a helper project that provides a code-only timer used by Coffee2 and MTCoffee.

This is an expanded version of the project developed in the step-by-step procedures in "Creating an ActiveX Exe Component," of Creating ActiveX Components. For more information on asynchronous notifications and multithreading, see ."

File | Description
CoffWat2.vbp | The CoffeeWatch client project.
CWMod1.bas | Startup code for the project.
CWForm1.frm | The client’s main form.
ICoffNot.cls | The ICoffeeNotify interface used for call-back methods..
CWNotMe.cls | NotifyMe object implements the ICoffeeNotify interface, so it can receive call-backs.
CWThread.frm | Client form for demonstrating multithreading.
CWCofTrk.cls | The CoffeeTracker object is used to wait for completion events from the multithreaded Coffee object.
AboutCof.txt | A copy of this document, demonstrating the ability to store related documents in a project.
Coffee2.vbp | The Coffee2 component project.
Co2Cmon.cls | The CoffeeMonitor class used to demonstrate asynchronous notifications using events.
Co2Conn.cls | The Connector class that enables multiple clients to share a CoffeeMonitor object.
Co2CMon2.cls | The CoffeeMonitor2 class used to demonstrate asynchronous notifications using call-back methods.
Co2Conn2.cls | The Connector2 class that enables multiple clients to share a CoffeeMonitor2 object.
Co2Mod1.bas | Holds a reference to the shared CoffeeMonitor and CoffeeMonitor2 objects.
MTCoffee.vbp | The MTCoffee component project.
MTCoffee.cls | The multithreaded Coffee object.
MTCMod1.bas | A standard module for demonstrating instancing of global data.
XTimers.vbp | The call-back timer project.
XTimer.cls | The XTimer object.
XTimerS.bas | Support module for XTimer.

To Run

Although there's not a lot of code in it, this is a complex sample to run, because it demonstrates out-of-process components. For debugging, an out-of-process component must be run in a separate copy of Visual Basic.

In addition, the sample demonstrates features — multithreading and code-only timers — that either cannot be demonstrated in, or are dangerous to run in, the development environment.

  1. Load XTimers.vbp into Visual Basic. On the File menu, select Make XTimers.dll to make the project into a .dll file.

    DO NOT run XTimers in the development environment at this time. XTimers must be compiled because it uses Windows APIs for a code-only timer object.

  2. Load MTCoffee into Visual Basic. On the Project menu, select References to open the References dialog box. Select XTimers and click OK, to set a reference to the compiled DLL.

  3. On the File menu, select Make MTCoffee.exe to make the project into an .exe file.

    DO NOT run MTCoffee in the development environment at this time. You need to make the project into an executable because the development environment can’t support multiple threads of execution — if you run MTCoffee within Visual Basic, it won’t display multithreading behavior.

  4. Load Coffee2.vbp into Visual Basic. On the Project menu, select References to open the References dialog box. Select XTimers and click OK, to set a reference to the compiled DLL.

  5. Press CRTL+F5 to run the Coffee2 project.

    Use CRTL+F5 instead F5 of when running an out-of-process component project, to ensure that all compile errors are caught before the component is supplying objects to the client. (See "Creating an ActiveX Exe Component" in Component Tools Guide.)

  6. Start another instance of Visual Basic, and load CoffWat2.vbp. On the Project menu, select References to open the References dialog box. Select Coffee2 (make sure you get the entry for Coffee2.vbp) and MTCoffee (make sure you get the entry for MTCoffee.exe), and then click OK, to set references to the components.

  7. Press F5 to run the project.

After running the sample application and observing the behavior of MTCoffee when it allocates a separate thread for each Coffee object, you may find it instructive to recompile MTCoffee after changing the threading to a round-robin thread pool. (You can find this option in the Unattended Execution box, on the General tab of the Project Properties dialog box.) When using a round-robin thread pool, you can observe blocking and global data sharing between objects on the same thread.

You can also compile Coffee2.exe and CoffWat2.exe, and run multiple clients, to observe sharing of the asynchronous notification objects CoffeeMonitor and CoffeeMonitor2. With multiple clients, the round-robin thread pool means blocking and data sharing between objects in use by different clients.

To understand what's going on in this sample, see "Building Code Components," in Creating ActiveX Components.


Control Plus (CtlPlus.vbp)

CtlPlus demonstrates a number of features of Visual Basic-authored ActiveX Controls.

This is an expanded version of the project developed in the step-by-step procedures in "Creating an ActiveX Control," in Creating ActiveX Components. For more information control creation, see "Building ActiveX Controls," in Creating ActiveX Components.

File | Description
CtlPlus.vbg | The program group.
CtlPlus.vbp | The control component project.
CPShapeL.ctl | The ShapeLabel control.
CPSLGen.pag | The General property page tab for ShapeLabel.
TestCtlP | The test program.
TCPForm1.frm | The test form for displaying ShapeLabel.

To Run

From the Visual Basic File menu, choose Open Project and select the program group, CtlPlus.vbg file, which is listed in the Samples directory.

Open Form1 in TestCtlP, to view the design-time behavior of ShapeLabel.

Press CTRL+F5 or choose Start With Full Compile from the Run menu to run the program group, and view the control's run-time behavior.


Dataware (Dataware.vbp)

The Dataware (Dataware.vbp) sample demonstrates how to create classes that can act as sources or consumers of data. For more information, see "Creating Data-Aware Classes" in "Programming with Objects"," in the Visual Basic Programmers Guide.

File | Description
Dataware.vbp | Main project for the sample application.
MySource.cls | Data source class.
MyCons.cls | Data consumer class.
Dataform.frm | Form to display the output of the source and consumer classes.

From the Visual Basic File menu, choose Open Project and select the Dataware.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


DhShowMe (DhShowMe.vbp)

DhShowMe (DhShowMe.vbp), Professional and Enterprise Editions

The DHTML ShowMe (DhShowMe.vbp) sample application demonstrates how you can use features of dynamic HTML to create special effects in your DHTML applications. See "Developing DHTML Applications," in the Building Internet Applications book of the Component Tools Guide for more information on the concepts in this sample.

File | Description
DhShowMe.vbp | Main project for the sample application.
DhShowMe.dll | The compiled code for the project.
DhShowMe.exp | The exports file generated when the project is compiled and linked.
EventBub.dsr | Designer file for the event bubbling page.
EventBub.htm | HTML file used as the source for the application's event bubbling page at design time. After compilation, this file is no longer referenced.
Layout.dsr | Designer file for the dynamic layout page.
Layout.htm | HTML file used as the source for the application's dynamic layout page at design time. After compilation, this file is no longer referenced.
List.dsr | Designer file for the dynamic list contents page.
List.htm | HTML file used as the source for the application's dynamic list contents page at design time. After compilation, this file is no longer referenced.
Project1.Eventbub.html | Compiled version of the event bubbling page.
Project1.Layout.html | Compiled version of the dynamic layout page.
Project1.Lists.html | Compiled version of the dynamic list contents page.
Project1.Start.html | Compiled version of the start page.
Project1.Styles.html | Compiled version of the dynamic styles page.
Project1.Text.html | Compiled version of the dynamic text page.
Start.dsr | Designer file for the application's start page.
Start.htm | HTML file used as the source for the application's start page at design time. After compilation, this file is no longer referenced.
Styles.dsr | Designer file for the dynamic styles page.
Styles.htm | HTML file used as the source for the application's dynamic styles page at design time. After compilation, this file is no longer referenced.
Text.dsr | Designer file for the dynamic text page.
Text.htm | HTML file used as the source for the application's dynamic text page at design time. After compilation, this file is no longer referenced.

To Run

From the Visual Basic File menu, choose Open Project and select the DhShowMe.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.

To View at Design Time

In order to view the application at design time, you may need to reset the SourceFile property for each .dsr file to indicate the location to which you installed the design time .htm files, if your directory structure is different than the directory structure used for the original file. For example, if you installed the samples onto drive D: in a subdirectory called \mydocuments\samples\vb\, you would edit the SourceFile property for the event bubbling page to be "d:\mydocuments\samples\vb\eventbub.htm."

Note This restriction applies to design time only. The path of the SourceFile property has no effect on running the previously-compiled application. You only need to reset this property if you cannot view the pages at design time, or if you recompile the project.


Hello World Remote Automation Sample Application (Helo_Svr.vbp and Helo_Cli.vbp), Enterprise Edition

This 6-line Hello World sample demonstrates one of the simplest possible examples of Remote Automation and DCOM. The application runs on both a single machine and in a 2-machine distributed configuration without needing to be recompiled.

The server in this project uses a visible form purely for demonstration purposes. There is no functional need for the server to have any UI, though state information presented through a UI can help with debugging or run-time monitoring needs. (Note, state monitoring requirements could also be addressed by providing a status method on the server that could be queried by a monitor application.)

File | Description
Helo_cli.vbp | Client component project file.
Helo_cli.frm | Client main form.
Helo_svr.vbp | Server component project file.
Helo_svr.frm | Server status indicator form.
Helo_svr.cls | Server class module.

To Run

From the Visual Basic File menu, choose Open Project and select the Helo_svr.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the server project.

Once running, this project temporarily registers its classes in the system registry. You can then start a second instance of Visual Basic to run Helo_cli.vbp, the client that uses the class modules defined in Helo_svr.vbp.

Note The Automation server can be run on the same machine as the client, or it can be run on a remote machine to benefit from distributed processing power and support multi-user access. The Automation server does not need to be recompiled or changed in any way to support this location independence.


Interface Sample Application (Intr_Svr.vbp and Intr_Cli.vbp), Enterprise Edition

This sample demonstrates a way to make more efficient user of COM's apartment model resource allocation algorithm when the context of an entire project needs to be preserved for a specific client.

The server in this project does not have a form module, and as such, will not be visible on the machine it is running on. (When a client has an active reference to it, however, it can be seen in the running task list.)

File | Description
Intr_cli.vbp | Client component project file.
Intr_cli.frm | Client main form.
Intr_svr.bas | Server main/global utility module.
Intr_svr.cls | A public interface class module that clients use to access the private classes of this component.
Getdate.cls | A private class that returns the current date.
Gettime.cls | A private class that returns the current time.
Intrface.txt | A text file with a project overview and description.

To Run

From the Visual Basic File menu, choose Open Project and select the Intr_svr.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the server project.

Once running, this project temporarily registers its classes in the system registry. You can then start a second instance of Visual Basic to run Intr_cli.vbp, the client that uses the class modules defined in Intr_svr.vbp.

Note The Automation server can be run on the same machine as the client, or it can be run on a remote machine to benefit from distributed processing power and support multi-user access. The Automation server does not need to be recompiled or changed in any way to support this location independence.


Passthrough Server Sample Application (Pass_Svr.vbp and Pass_Cli.vbp), Enterprise Edition

This sample application is an example of a simple pass-through server. It has one method called RunServer, which takes a ProgID parameter of the server that is to be started. The server specified by the ProgID is run on the same machine that the pass-through server is running on. If the server specified by ProgID is an in-process server, it is run in the same process space as the pass-through server.

RunServer returns the handle of the started server so that the client can talk directly to the requested server. Because the pass-through server is a single-use server, every client that uses it will get its own instance of the pass-through server, along with its own process space and thread of execution.

By using the pass-through server, client applications can create their own independent execution context on a remote server and then start and stop in-process servers within that context as needed. Because in-process servers can be started very quickly and because they are run within the pass-through server's process space, this is a much more efficient execution model than solely using out-of-process servers.

The server in this project uses a visible form purely for demonstration purposes. There is no functional need for the server to have any UI, though state information presented through a UI can help with debugging or run-time monitoring needs. (State monitoring requirements can also be addressed by providing a status method on the server that can be queried by a monitor application.)

File | Description
Pass_cli.vbp | Client component project file.
Pass_cli.frm | Client main form.
Pass_svr.vbp | Server component project file.
Pass_svr.frm | Server status indicator form.
Pass_svr.bas | Server main/global utility module.
Pass_svr.cls | Server class module.
Passthru.txt | A text file containing a project overview and description.

To Run

From the Visual Basic File menu, choose Open Project and select the Pass_svr.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the server project.

Once running, this project temporarily registers its classes in the system registry. You can then start a second instance of Visual Basic to run Pass_cli.vbp, the client that uses the class modules defined in Pass_svr.vbp.

Note The Automation server can be run on the same machine as the client, or it can be run on a remote machine to benefit from distributed processing power and support multi-user access. The Automation server does not need to be recompiled or changed in any way to support this location independence.


Pool Manager Sample Application (Pmgr_Svr.vp and Pmgr_Cli.vbp), Enterprise Edition

This sample app is an example of a simple pool manager that could be used to maintain open instances of Automation servers for client applications. Using this scheme, client applications ask the pool manager for a pointer to an object they want to use. The pool manager checks the pool, and either grants or denies the request. This approach has a number of benefits:

  • It avoids the lengthy Automation server creation costs associated with each client request. This is because the pool is typically created before a client needs a server.

  • Based on the frequency of client requests, the potential number of clients, and the duration of server tasks, a pool size can be created (or even adjusted as demand dictates at various times) that is significantly smaller than a one-to-one allocation scheme for clients and servers. For example: if the number of clients is 60, the average frequency of requests is one per minute per client, and the average duration of a server task is one second. A linear allocation plan would suggest that one server is needed to meet the needs of 60 clients. Realistically, requests will not be perfectly spaced; therefore, a reasonable level of redundancy, for instance a pool size of 5 Automation servers, could be used to meet the normal needs of the 60 clients.

  • It limits the number of servers that can be created of a specific type to a threshold that has been determined by the server administrator. This can be a very useful tuning parameter, and can also be useful in preventing the server from being abused by a peak request of a low priority server.

The server in this project uses a visible form purely for demonstration purposes. There is no functional need for the server to have any UI, though state information presented through a UI can help with debugging or run-time monitoring needs. (State monitoring requirements can also be addressed by providing a status method on the server that can be queried by a monitor application.)

File | Description
Pmgr_cli.vbp | Client component project file.
Pmgr_cli.frm | Client main form.
Pmgr_svr.vbp | Server component project file.
Pmgr_svr.frm | Server status indicator form.
Pmgr_svr.bas | Server main/global utility module.
Pmgr_svr.cls | Server class module.
Poolmngr.txt | A text file containing a project overview and description.

To Run

From the Visual Basic File menu, choose Open Project and select the Pmgr_svr.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the server project.

Once running, this project temporarily registers its classes in the system registry. You can then start a second instance of Visual Basic to run Pmgr_cli.vbp, the client that uses the class modules defined in Pmgr_svr.vbp.

Note The Automation server can be run on the same machine as the client, or it can be run on a remote machine to benefit from distributed processing power and support multi-user access. The Automation server does not need to be recompiled or changed in any way to support this location independence.


Programming with Objects (ProgWOb.vbp)

ProgWOb.vbp demonstrates concepts from "Programming with Objects," in the Visual Basic Programmer’s Guide, including creating collection classes, events, the Implements statement, polymorphism, and Friend procedures.

File | Description
ProgWOb.vbp | The project.
PWOMain.frm | The main form, from which you can select demos.
PWOFrien.frm | First demo: Using Friend procedures to pass user-defined types between objects.
PWOTestC.cls | Defines the TestClass object used to demonstrate Friend procedures.
PWOFrien.bas | Defines the user-defined type passed between TestClass objects.
PWOCYOCC.frm | Second demo: From this form you can run the three code examples from Creating Your Own Collection Classes.
PWOEmpl.cls | Employee class used by all three examples.
PWOStraw.frm | House of Straw example: Using a public Collection object.
PWOSBus1.cls | SmallBusiness1 class used in House of Straw example.
PWOStick.frm | House of Sticks example: Using a private Collection object.
PWOSBus2.cls | SmallBusiness2 class used in House of Sticks example.
PWOBrick.frm | House of Bricks example: Creating your own collection class.
PWOEmpls.cls | Employees collection class used in House of Bricks example. Can be used with For Each.
PWOSBus3.cls | SmallBusiness3 class used in House of Bricks example.
PWOEvent.frm | Third demo: Shows two things: (1) an object performing a long task can raise events to notify the caller of its progress, and (2) events can be broadcast to multiple receivers.
PWOWidg | Widget object uses events to notify caller of progress during a long task.
PWOEvRec.frm | Receiver form handles an event, and shows what happens when ByRef arguments of an event are modified by receivers.
PWOImple | Fourth demo: Shows how polymorphism allows early binding with multiple classes of objects, and illustrates the performance impact.
PWOIShap | Defines the IShape interface implemented by all other classes in the demo.
PWOPoly | Polygon is a very crude object for drawing polygons. Implements IShape for drawing.
PWORect | Rectangle object implements IShape for drawing. It also implements the Polygon interface, and uses an inner Polygon object to store its data.
PWOTrngl | Triangle object implements IShape and Polygon. It delegates to an inner Polygon object for both IShape and most Polygon functions.

To Run

From the Visual Basic File menu, choose Open Project and select the ProgWOb.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


PropBag (PropBag.vbp)

PropBag (PropBag.vbp), Professional and Enterprise Editions

The PropBag sample application demonstrates how to store state values between HTML pages in a DHTML application. See "Developing DHTML Applications," in the Building Internet Applications book of the Component Tools Guide for more information on the concepts in this sample.

File | Description
PropBag.vbp | Main project for the sample application.
DHTMLPage1.dsr | Designer for the first page in the application. In this application, there is no design-time HTML file because the source HTML is stored within the .dsr file until the project is compiled.
DHTMLPage2.dsr | Designer for the second page in the application. In this application, there is no design-time HTML file because the source HTML is stored within the .dsr file until the project is compiled.
DHTMLPage1.dsx | Binary version of DHTMLPage1.dsr.
DHTMLPage2.dsx | Binary version of DHTMLPage2.dsr.
Module1.bas | Module that contains the GetProperty and PutProperty functions used to store state information between pages.
PropBag.DHTMLPage1.htm | Compiled version of the HTML page for the first page in the application.
PropBag.DHTMLPage2.htm | Compiled version of the HTML page for the second page in the application.
PropBag.dll | The compiled code for the project.
PropBag.exp | The exports file generated when the project is compiled and linked.
PropBag.lib | The static import library generated when the project is compiled and linked.

To Run

From the Visual Basic File menu, choose Open Project and select the PropBag.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the application.


Webclass Demo Application (wcdemo.vbp), Professional and Enterprise Edition

The Webclass Demo (wcdemo.vbp) sample application demonstrates key concepts involved in building an IIS application. See "Developing IIS Applications," in the Building Internet Applications book of the Component Tools Guide for more information on the concepts in this sample.

File | Description
Explorer.bmp | An image file that is added to the start page for the application in response to a webclass event.
Page11.htm | The HTML page that acts as the basis for the webclass's template.
Wcdemo.vbp | Main project for the sample application.
Wcdemo_WebClass1.asp | The Active Server Page that hosts the webclass on the server, generates its run-time component, and launches the first event in its lifecycle.
Webclass1.dsr | Designer for the webclass in the application. The designer contains information about the templates, events, and event procedures associated with the application.
Webclass1.dsx | A binary version of the application's designer.

To Run

From the Visual Basic File menu, choose Open Project and select the wcdemo.vbp file. Compile, then press F5 or choose Start from the Run menu to run the project.


Load Statement

Loads a form or control into memory.

Syntax

Load object

The object placeholder is the name of a Form object, MDIForm object, or control array element to load.

Remarks

You don't need to use the Load statement with forms unless you want to load a form without displaying it. Any reference to a form (except in a Set or If...TypeOf statement) automatically loads it if it's not already loaded. For example, the Show method loads a form before displaying it. Once the form is loaded, its properties and controls can be altered by the application, whether or not the form is actually visible. Under some circumstances, you may want to load all your forms during initialization and display them later as they're needed.

When Visual Basic loads a Form object, it sets form properties to their initial values and then performs the Load event procedure. When an application starts, Visual Basic automatically loads and displays the application's startup form.

If you load a Form whose MDIChild property is set to True (in other words, the child form) before loading an MDIForm, the MDIForm is automatically loaded before the child form. MDI child forms cannot be hidden, and thus are immediately visible after the Form_Load event procedure ends.

The standard dialog boxes produced by Visual Basic functions such as MsgBox and InputBox do not need to be loaded, shown, or unloaded, but can simply be invoked directly.


Load Statement Example

This example uses the Load statement to load a Form object. To try this example, paste the code into the Declarations section of a Form object, and then run the example and click the Form object.

Private Sub Form_Click ()
   Dim Answer, Msg as String   ' Declare variable.
   Unload Form1   ' Unload form.
   Msg = "Form1 has been unloaded. Choose Yes to load and "
   Msg = Msg & "display the form. Choose No to load the form "
   Msg = Msg & "and leave it invisible."
   Answer = MsgBox(Msg, vbYesNo)   ' Get user response.
   If Answer = vbYes Then   ' Evaluate answer.
      Show   ' If Yes, show form.
   Else
      Load Form1   ' If No, just load it.
      Msg = "Form1 is now loaded. Choose OK to display it."
      MsgBox Msg   ' Display message.
      Show   ' Show form.
   End If
End Sub


SavePicture Statement

Saves a graphic from the Picture or Image property of an object or control (if one is associated with it) to a file.

Syntax

SavePicture picture, stringexpression

The SavePicture statement syntax has these parts:

Part | Description
picture | Picture or Image control from which the graphics file is to be created.
stringexpression | Filename of the graphics file to save.

Remarks

If a graphic was loaded from a file to the Picture property of an object, either at design time or at run time, and it’s a bitmap, icon, metafile, or enhanced metafile, it's saved using the same format as the original file. If it is a GIF or JPEG file, it is saved as a bitmap file.

Graphics in an Image property are always saved as bitmap (.bmp) files regardless of their original format.


SavePicture Statement Example

This example uses the SavePicture statement to save a graphic drawn into a Form object’s Picture property. To try this example, paste the code into the Declarations section of a Form object, and then run the example and click the Form object.

Private Sub Form_Click ()
   ' Declare variables.
   Dim CX, CY, Limit, Radius   as Integer, Msg as String
   ScaleMode = vbPixels   ' Set scale to pixels.
   AutoRedraw = True ' Turn on AutoRedraw.
   Width = Height   ' Change width to match height.
   CX = ScaleWidth / 2   ' Set X position.
   CY = ScaleHeight / 2   ' Set Y position.
   Limit = CX   ' Limit size of circles.
   For Radius = 0 To Limit   ' Set radius.
      Circle (CX, CY), Radius, RGB(Rnd * 255, Rnd * 255, Rnd * 255)
      DoEvents   ' Yield for other processing.
   Next Radius
   Msg = "Choose OK to save the graphics from this form "
   Msg = Msg & "to a bitmap file."
   MsgBox Msg
   SavePicture Image, "TEST.BMP"   ' Save picture to file.
End Sub


Unload Statement

Unloads a form or control from memory.

Syntax

Unload object

The object placeholder is the name of a Form object or control array element to unload.

Remarks

Unloading a form or control may be necessary or expedient in some cases where the memory used is needed for something else, or when you need to reset properties to their original values.

Before a form is unloaded, the Query_Unload event procedure occurs, followed by the Form_Unload event procedure. Setting the cancel argument to True in either of these events prevents the form from being unloaded. For MDIForm objects, the MDIForm object's Query_Unload event procedure occurs, followed by the Query_Unload event procedure and Form_Unload event procedure for each MDI child form, and finally the MDIForm object's Form_Unload event procedure.

When a form is unloaded, all controls placed on the form at run time are no longer accessible. Controls placed on the form at design time remain intact; however, any run-time changes to those controls and their properties are lost when the form is reloaded. All changes to form properties are also lost. Accessing any controls on the form causes it to be reloaded.

Note When a form is unloaded, only the displayed component is unloaded. The code associated with the form module remains in memory.

Only control array elements added to a form at run time can be unloaded with the Unload statement. The properties of unloaded controls are reinitialized when the controls are reloaded.


Unload Statement Example

This example uses the Unload statement to unload a Form object. To try this example, paste the code into the Declarations section of a Form object, and then run the example and click the Form object.

Private Sub Form_Click ()
   Dim Answer, Msg   ' Declare variable.
   Unload Form1   ' Unload form.
   Msg = "Form1 has been unloaded. Choose Yes to load and "
   Msg = Msg & "display the form. Choose No to load the form "
   Msg = Msg & "and leave it invisible."
   Answer = MsgBox(Msg, vbYesNo)   ' Get user response.
   If Answer = vbYes Then   ' Evaluate answer.
      Show   ' If Yes, show form.
   Else
      Load Form1   ' If No, just load it.
      Msg = "Form1 is now loaded. Choose OK to display it."
      MsgBox Msg   ' Display message.
      Show   ' Show form.
   End If
End Sub


Add-In Toolbar

A toolbar on which to place add-ins and Wizards for quick and easy user access. To start an add-in or Wizard, simply click its icon on the toolbar.

The add-ins and Wizards placed on the Add-In toolbar are not activated until their button is clicked. The Add-In toolbar eliminates the need for activating the add-in through the Add-In Manager dialog box.

You can add Wizards and add-ins to the Add-In toolbar through the Add/Remove Toolbar Items (+/-) button. When you click this button, you get the following dialog box:

To add an add-in or Wizard to the list of available add-ins, click the Browse button. Point to an add-in or Wizard's .Exe or .Dll file in the dialog box, then click Open. It should appear in the Available Add-Ins list. It will not show up on the Add-In toolbar, however, unless its box is checked in the Available Add-Ins list.

The OK button closes the Add/Remove Toolbar Items dialog box and updates the Add-In toolbar with the checked items.

The Cancel button closes the Add/Remove Toolbar Items dialog box and ignores any changes made when it was opened.

When you click the Delete button, the currently selected add-in or Wizard is removed from the Available Add-Ins list. Note that this does not remove the add-in or Wizard from the system, nor its reference in the Add-In Manager dialog box. The Delete button removes only the entry in the Add-In toolbar Available Add-Ins list.


Data Environment Toolbar Buttons

The following table describes the toolbar icons of the Project – DataEnvironment window.

Toolbar of the Project – DataEnvironment window

Icon | Control | Description
Add Connection | Adds a new Connection object to the DataEnvironment object.
Add Command | Adds a new Command object to the DataEnvironment object.
Insert Stored Procedures | Accesses the Insert Stored Procedures dialog box. From this dialog box, you can create one or more Command objects from a list of stored procedures that are available in a particular connection.
Add Child Command | Adds a Child Command to the currently selected Command object.
Delete | Deletes the currently selected Command or Connection object.
Refresh Refreshes the currently selected Command or Connection object. The Refresh functionality differs when performed on Connection and Command objects, as follows:
  • Refreshing a Connection object closes the connection, if it was open, and then reopens it. The connection information — a list of tables, stored procedures, views, or synonyms — is also refreshed.

  • Refreshing a Command object refreshes all its stored meta-data, such as field and parameter information. Any changes to the table or stored procedure's definition is reflected in the Command object after the refresh.

    Caution All user-defined property settings are lost during the refresh. For Field objects, the Caption and Control properties are reset to their defaults. For Parameter objects, the Name, Direction, DataType, HostDataType, Precision, Scale, Size, and Value properties are reset.
Design | Accesses the Query designer for a Command object when the command source is text.
Properties | Accesses the Properties dialog box for the selected Command, Connection, or Field object.
View Code | Accesses the Code Editor window, in which you can write code.
Options | Accesses the Options dialog box.
Arrange by Connections | Displays the objects grouped by connection, with all the Command objects listed beneath the Connection object to which they are associated.
Arrange by Objects | Groups objects of the same type together. This enables you to quickly locate specific objects within a DataEnvironment object.

Outline View Icons and the Status Bar Display

The following table defines each icon that displays in the Data Environment Outline view and describes their corresponding status bar displays.

Icon | Object | Description of Status Bar Display
 | Aggregate | Specifies the object type, data type, and field name of the Command object aggregate.
 | Command | The description in the status bar varies depending on the ObjectType and ActiveConnection set.
 | based on SQL | Command based on user-defined SQL from the connection.
 | based on Stored Procedure | Command object based on a stored procedure.
 | based on Synonym | Command object based on a synonym.
 | based on Table | Command object based on a table.
 | based on Views | Command object based on a view.
 | Command or Connections Folder | Specifies either the total number of Command or Connection objects in the DataEnvironment object.
 | Connection | Information about the connection, including whether it is open (connected).
 | DataEnvironment | Specifies the total number of Command and Connection objects contained in the DataEnvironment object.
 | Field | The data type and size of the Field object.


Visual Data Manager (VisData)

VisData is an application that was created using Visual Basic 5.0. A built version of VisData is used as an add-in accessible from the Add-Ins menu. In the Professional and Enterprise editions the source code for VisData is available in the samples directory.

Note VisData is accessed by choosing the Visual Data Manager command on the Add-Ins menu.

This Help file includes information on the VisData interface: menu items, dialogs, and forms. It also contains a topic about VisData as a sample. It is recommended that you browse this Help file often to gain the most use of VisData.

Menus

File Menu

Utility Menu

Window Menu

Forms and Dialog Boxes

VisData As a Sample


Add Field Dialog Box (VisData)

Adds a field to the current table.

In the Database form, select a table, and click the Right mouse button. Then, in the Table Structure dialog box, click the Add Field button to display the Add Field dialog box.

Dialog Box Options

Name

Allows you to type the name of the field you want to add.

OrdinalPosition

Allows you to determine the relative position of the field.

Type

Lets you determine the operational or data type of the field.

ValidationText

Lets you add the text of the message that your application displays if a user tries to enter an invalid value for a field.

Size

Lets you determine the maximum size, in bytes, of the field.

FixedField — If selected, creates a field with a fixed size.

VariableField — If selected, allows the user to modify the size of the field by dragging its borders.

ValidationRule

Lets you determine what data is valid in a field as it is added.

DefaultValue

Lets you determine the default value for the field.

AutoIncrField

Automatically adds the next field if you are at the end of the table.

AllowZeroLength

Allows you to have a zero-length string as a valid setting.

Required

Indicates if the field requires a non- Null value.

Add

Appends the current Field definition to the current table.

Close

Closes the form when you are finished adding fields.

Note All items, such as ValidationText and Ordinal Position, are Field properties, and are described in detail in the Visual Basic Help file. Those that do not apply are not available.


Add Index Dialog Box (VisData)

Adds an index to the current table.

To display this dialog box, in the Database form, select a table, click the right mouse button, and then choose Design. Then, in the Table Structure dialog box, click the Add Index button.

Dialog Box Options

Name

Allows you to type the name of the index.

Indexed Fields

Lists the indexes in the field selected in the Available Fields box.

Available Fields

Lists the fields in the current table.

Primary

If selected, indicates this is the primary index for the table.

Unique

If selected, indicates that the index entry is unique.

IgnoreNulls

If selected, indicates that fields with Null values are not included in the index.

OK

Appends the current Index definition to the current table.

Close

Closes the form when you are finished adding indexes.

Note Items, such as IgnoreNulls and Unique, are Index properties. They are described in detail in the Visual Basic Help file. Those that do not apply are not available.


Copy Structure Command (VisData)

Copy Structure Command (VisData Shortcut Menu)

Displays the Copy Table(s) dialog box in which you select a table structure to copy.

To display the Copy Table(s) dialog box, in the Database form, select a table and then click the right mouse button. Choose the Copy Structure command on the shortcut menu.

Dialog Box Options

Tables List

Lists tables from which you can select one to copy.

Target Database

Lists databases from which you can select the database to which you want to copy the table(s). If the current database is entered, you will be prompted to enter a new name for the table.

Target Connect String

Sets the target database’s Connect property. Only needed for non-MDB database types.

Copy Indexes

Copies the indexes for the selected table.

Copy Data

Copies the data for the selected table.


Data Control Form (VisData)

You can display this form by selecting the Use Data Control button on the toolbar. Then, click the Open button on the Database window.

Form Options

Add

Adds a new record to the current recordset.

Update

Updates the current record with new data entered in the bound controls.

Delete

Deletes the current record.

Find

Displays an input box where you can enter an expression to perform a search on a dynaset-type and snapshot-type recordset and a search on a table-type recordset.

Refresh

Refreshes the Data control.

Close

Closes and unloads the form.

Field Names

Displays the name of each field in the current recordset.

Field Value

Displays and allows modification of the data in the current field.

Data Control

Displays the current record position. Clicking the right mouse button allows you to change the properties of the Data control and its recordset to test different characteristics of various combinations of settings in the Data Control Properties dialog box.


Data Control Properties Dialog Box (VisData)

Allows you to view and modify the Data control properties for the current form.

To display this dialog box, click the right mouse button over the Data control on the current form.

This dialog box is useful for experimenting with various combinations of settings for the parent form’s Data control and its related objects, including the Database and Recordset objects. It is the only place in VisData where you can set any of the various attributes, such as AppendOnly and ForwardOnly, of a recordset.

Dialog Box Options

Database Properties

Sets properties directly related to the database associated to the Data control on the parent form.

Recordset Properties

Sets properties directly related to the recordset associated to the Data control on the parent form.

Data Control Properties

Sets properties directly related to the Data control on the parent form.

OK

Resets the Data control’s recordset with the new values entered.

Cancel

Closes the dialog box without placing the Data control on the parent form.


Data Form Designer Dialog Box (VisData)

Creates data forms and adds them to the current Visual Basic project.

This is an Add-In utility that adds forms to the current Visual Basic project. It is useful for creating forms for browsing and modifying data from a simple table to a complex query. It is only available when VisData has been opened using the Visual Data Manager command on the Visual Basic Add-Ins menu.

Dialog Box Options

Form Name

Sets the name of the form to add to the Visual Basic project.

RecordSource

Selects the record source for which you will create the form. The user can select an existing table or query from the list or enter a new SQL statement.

Available Fields

Lists the fields in the table or query selected or entered into the RecordSource box.

Moves the selected fields from the Available Fields list to the Included Fields list.

Moves all of the fields in the Available Fields list to the Included Fields list.

Moves all of the fields from the Included Fields list to the Available Fields list.

Moves the selected fields from the Included Fields list to the Available Fields list.

Included Fields

Lists the fields to include on the form. Reorder the list by dragging and dropping items at different locations in the list.

Up and Down Arrow Buttons

Move the selection up or down one line each time you click it.

Build the Form

Builds the form.


Data Grid Form (VisData)

A simple form with a toolbar at the top, a DataGrid control in the middle, and a Data control at the bottom. It is useful for experimenting with the DataGrid control quickly and easily.

To display the Data Grid form, select the Data Grid Form Type on the toolbar, and click the Open button on the Table form.

Form Items

Refresh

Refreshes the Data control.

Sort

Enables you to sort the current recordset.

Filter

Enables you to place a filter on the current recordset.

Close

Closes and unloads the form.

Note The other items are properties of the DataGrid control, and are described in the Visual Basic Help file.


Data Source Type Selection Dialog Box (VisData)

Enables selection of a data source type for import and export.

This dialog box is displayed during the import and export commands so that you may select the data source type to import to or export from.


Dynaset/Snapshot Form (VisData)

A form that demonstrates the use of a scroll bar for record positioning in a dynaset- or snapshot-type recordset.

A convenient feature of this form is the zoom ability on text and memo type fields. By double-clicking the field name of the data, you load the Zoom dialog box and enable much easier viewing and modification of large chunks of text.

You can display the dialog box by selecting Dynaset or Snapshot as the Recordset type on the toolbar, and then opening the Table form from the Database form.

Form Items

Add

Adds a new record to the current recordset.

Edit

Places the current record in edit mode.

Delete

Deletes the current record.

Close

Closes the current record.

Sort

Sorts the current recordset.

Filter

Places a filter on the current recordset.

Move

Displays the Move dialog box where you can indicate how many rows you want to move the record forward or backward in the recordset.

Find

Displays the Find dialog box where you can enter information to perform a search on the current recordset.


Export Name Dialog Box (VisData)

Allows you to select the name of the data source you want to export..


Close Database Command (VisData File Menu)

Closes all forms that contain data from the current database.

This command is called internally by VisData when you choose the Open Database command from the VisData File menu.


Compact MDB Command (VisData File Menu)

Compact MDB Commands (VisData File Menu)

Compacts a Jet .mdb file and creates an encrypted or decrypted file. If you choose the same name for the destination file as the source, the source will be overwritten with the new file.

7.0 MDB

Creates a Microsoft Access version 7.0 .mdb file with the same encryption status as the one you’re compacting.

2.0 MDB

Creates a Microsoft Access version 2.0 .mdb file with the same encryption status as the one you’re compacting.


Errors Command (VisData File Menu)

Displays a form with a list box containing the current Errors collection of the DBEngine object.

The form can be left open, minimized, or closed at any time, but it must be refreshed with the Refresh button when new errors occur.


New Database Command (VisData File Menu)

Creates a new database for the database type selected from the menu.

If you choose | Creates a
Microsoft Access | Microsoft Access (version 2.0 or 7.0) .mdb
Dbase | Dbase (version 5.0, IV, or III) database.
FoxPro | FoxPro (version 3.0, 2.6, 2.5, or 2.0) database.
Paradox | Paradox (version 5.0, 4.x, or 3.x) database.
ODBC | New ODBC data source.
Text Files | Directory where the table files are stored.


Open Database Command (VisData File Menu)

Opens a database of the selected type.

In most cases, you should create an .mdb file and attach tables from other data source types. However, it is necessary and useful to open a database directly to perform DDL (Data Definition Language) operations and to experiment with performance.

If you choose ODBC, a dialog box is displayed that lists the parameters needed to open an ODBC data source. If the source you select does not exist, it can be created from this dialog using the Register command.


Repair MDB Command (VisData File Menu)

Displays a dialog box that allows you to select a corrupt .mdb file to repair. You cannot repair the current database because if it is open, it must not be corrupt.


Workspace Command (VisData File Menu)

Displays the Login dialog box where you can log into a new workspace.

It allows you to log on as a different user so that you can test security, set passwords for new users, and set up the System.mda file within the same VisData session. If possible, the current database will be reopened from the new workspace with the newly entered user name and password.


Find Dialog Box (VisData)

Searches the dynaset or snapshot-type recordset for a specified expression.

This dialog is a simple expression builder used by the Dynaset/Snapshot form. Each Dynaset/Snapshot form loaded has its own instance of a Find form so that the same expression may be modified until the desired record is found.

Dialog Box Options

Field

Selects the field to use for the search.

Operator

Selects the operator to use in the expression.

Expression

Sets the value to find.

OK

Executes the search.

Cancel

Closes the form without executing the search.


Forms and Dialog Boxes (VisData)

Forms

Data ControlForm

Data GridForm

DatabaseForm

Dynaset/SnapshotForm

Errors CollectionForm

Main MDIForm

SQL StatementForm

TableForm

Dialog Boxes

Add Field DialogBox

Add Index DialogBox

Copy Table Structure DialogBox

Data Control Properties DialogBox

Data FormDesigner

Data Source Type Selection DialogBox

Export Name DialogBox

Find DialogBox

Global Replace DialogBox

Groups/Users/Permissions DialogBox

Import Tables DialogBox

Import/Export DialogBox

Join DialogBox

Login DialogBox

New Attachment DialogBox

New User/New Group DialogBox

Open ODBC Data Source DialogBox

Query Builder DialogBox

Seek Parameters DialogBox

Set Password DialogBox

Table Structure DialogBox

Zoom DialogBox


Import Tables Dialog Box (VisData)

Displays a list of all of the tables in the selected database and prompts you to select the table(s) to import. You can only import one table at a time.


Attachments Command (Utility Menu)

Attachments Command (VisData Utility Menu)

Lists all of the attached tables and their respective connect strings in the current .mdb file.

Dialog Box Options

New

Loads the New Attachment dialog box.

ReAttach

Updates the connection information on the selected items when you select multiple tables.

Note Clicking the right mouse button over any attached table displays its properties.


Groups/Users Command (VisData Utility Menu)

Allows you to view and modify groups, users, permissions, and owners.

Dialog Box Options

Users

Displays items in the Users and Groups Belonged To boxes.

Groups

Displays items in the Groups and Members boxes.

New

Adds a new user or group with the New User/New Group dialog box.

Delete

Removes the currently selected user or group.

Groups Belonged To

Lists the groups to which a selected User belongs.

Members List

Lists the members of the selected group.

Set/Clear Password

Sets your password or clears another user’s password. If the selected user name matches the name in the Users box, displays the Set Password dialog box.

Tables/Queries

Lists the tables and queries for the current database.

Owner

Sets the owner of any table or query in the Tables/Queries box.

Permissions

Assigns permissions to the current user or group. You can select the Read Design, Modify Design, Administer, Read Data, Update Data, Insert Data, and Delete Data check boxes. Multiple tables or queries can be selected in the Tables/Queries box to assign permissions for more than one item at a time.


SYSTEM.MD? Command (VisData Utility Menu)

Makes an entry in the Registry. It enables you to create different System.mda files and set up the security for each one from the same application.


Join Dialog Box (VisData)

Allows you to add joins to the Query Builder. You can display this dialog box by clicking Set Table Joins button in the Query Builder dialog box available from the VisData Utility menu.

It prompts you to select a pair of tables and the field to join. It simply saves you the time of entering the table1.field1=tablel2.field2 syntax in the query. To achieve more complex queries, it is recommended you use Microsoft Access because its graphical query builder is more powerful.

Dialog Box Options

Table Lists

Lists tables from which you can select the pair of tables to join.

Add Join to Query

Adds the selected join to the query in the Query Builder.

Clear All Joins

Clears the list in Query Builder.


Login Dialog Box (VisData)

Allows you to log on as a different user.

Use when:

  • The initial CreateWorkspace call fails due to an invalid logon (The user administrator must have a password).

  • You choose Workspace from the File menu.

You must enter a valid user name and password combination or choose Cancel. If you cancel the opening instance of this dialog, VisData will close. If you cancel after choosing Workspace from the File menu, you will remain logged on.


Main MDI Form (VisData)

Consists of a menu, a toolbar, a child window area, and a status bar.

Form Items

Recordset Type

Sets the type of recordset to open when another command executes the OpenRecordset method. This can be a dynaset-, snapshot-, or table-type recordset.

Form Type

Sets the type of form to open when another command needs a form to display a recordset. It can contain a Data control, no Data control, or a DataGrid control.

Begin Transaction

Executes a new transaction.

Rollback

Ends the current transaction and restores the databases to the state they were in when the current transaction began.

CommitTrans

Ends the current transaction and saves the changes.

User

Displays the current user’s name.


File Menu (VisData)

Open Database

New

Close

Import/Export

Workspace

Errors

Compact MDB

Repair MDB

File 1, 2, 3, 4

Exit


New Attachment Dialog Box (VisData)

Allows you to add an attached table to the current database. You can display this dialog box by clicking the New button on the Attachments dialog box available by using the Attachments command on the Utility menu.

Dialog Box Options

Attachment Name

Sets the name of the attachment in the current database.

Database Name

Sets the database name of the table to attach.

Connect String

Sets the Database Connect of the table to attach.

Table to Attach

Sets the name of the table to attach. This box is filled with tables if the Attachment Name, Database name, and Connect String are properly entered.

Save Password

Sets whether to save the password with the attachment.

Open Exclusive

Sets whether to open the attachment exclusively.

Attach

Executes the code to create the new attachment.

Close

Closes the form when you are finished adding new attachments.


New User/New Group Dialog Box (VisData)

Allows you to add a new group or user.

You can display this dialog box by clicking the New button on the Groups/Users/Permissions dialog box available by choosing Groups/Users command from the Utility menu.

Dialog Box Options

Name

Sets the name of the group or user to add.

PIN

Sets the (Personal Identification Number) PIN of the group or user to add. Required. The PIN must be at least four characters long.

OK

Appends the new group or user.

Cancel

Closes the dialog box without adding the new group or user.


Open ODBC Data Source Dialog Box (VisData)

Opens an ODBC data source with the user-supplied parameters.

Dialog Box Options

DSN ( Data Source Name) Lists all of the currently registered data sources found in the ODBC.INI file in the Windows directory or the Windows NT registry. It is filled by using the ODBC API call GetDataSource. This is the DSN clause in the connect string.

Database

Lists the database that will be opened. If omitted, the default database for the specified user is opened. This is the DATABASE or DBQ clause in the connect string.

UID (User ID)

Lists User ID clause in the connect string.

PWD (Password)

Lists the Password clause in the connect string.

Driver

Lists all of the installed ODBC drivers on the system. Use it to select a driver for a DSN-Less connection or to register a new datasource.

Server

Allows you to fill in the name of the server when creating a DSN-Less connection.

Register

Allows you to add a new Data Source Name (DSN).


Query Builder Command (VisData Utility Menu)

An expression builder with all of the components needed to make simple to very complex SQL queries. You can use this dialog box to build, view, execute, and save SQL queries.

Most of the dialog items are self-explanatory so only a few are described below.

Dialog Box Options

List Possible Values

Adds all unique values for the chosen field into the drop-down list.

Set Table Joins

Displays the Join Dialog box so that you may more easily add a join to the current query.

Run

Opens a recordset using the SQL statement you entered.

Show

Displays the SQL statement you entered.

Copy

Copies the SQL query to the SQL Statement window.

Save

Creates a new query with the settings you define.


Seek Parameters Dialog Box (VisData)

Invokes a Seek method on the current Table form using the current index.

Note It does not handle compound indexes so it is only effective when the index contains a single column.

Dialog Box Options

Operator

Lists the first argument of the search.

= — Equal to.

>= — Greater than or equal to.

<= — Less than or equal to.

> — Greater than.

< — Less than.

Value

Lists the value to on which to search.


Set Password Dialog Box (VisData)

Allows you to change the password of the current user.

It is a standard Old, New, Confirm Password dialog box.


SQL Statement Form (VisData)

Enables you to execute any valid SQL statement and save it as a query, or update the currently selected query’s SQL property.

You can view the SQL statement from a query in the Database window by selecting it, clicking the right mouse button, and then choosing Design.

Use the SQL Statement window to enter, modify, execute, and save SQL statements.

Form Items

Execute SQL

Executes the SQL statement. This is the default button and will be invoked if you press ENTER while the form is active.

Note To put a carriage return into the SQL statement, press CTRL+ENTER.

Clear SQL

Clears the SQL Statement text box. It does not copy the contents onto the Clipboard.

Save SQL

Saves the SQL statement. This command will prompt you to overwrite the SQL statement in a query if one is selected in the QueryDefs list on the Table form, or it will prompt you for a new name if you chose No to the above prompt or there is no query currently selected.


Table Form (VisData)

A form that has command buttons that look like the standard Data control, that you can use to perform moves on the table-type recordset.

A nice feature of this form is the ability to zoom on text and memo type fields. This is executed by double-clicking the field name of the data to zoom in. It loads the Zoom dialog box and allows easier viewing and modification of large chunks of text.

Table-type recordsets are ordered by the currently selected Index so there is a box containing all available Indexes that may be selected to establish the desired order and search.

Form Items

Add

Adds a new record to the current recordset.

Edit

Places the current record in edit mode.

Update

Updates the current record with new data entered in the controls.

Cancel

Cancels the add operation.

Seek

Displays the Seek dialog box, where you can search on the current table-type recordset.

Del

Deletes the current record.

Filter

Places a filter on the current table-type recordset and loads the newly filtered recordset into a Dynaset/Snapshot form.

Index

Selects the current Index to order by and to search on.


Database Form (VisData)

Displays in a tree all the objects in a database. It contains a shortcut menu accessible from the right mouse button.

Form Items

New

Loads the Table form for tables and the Query Builder form for queries.

Open

Opens a recordset for tables and row-returning queries or executes action queries. Recordsets are of the recordset type, Form type selected on the Main MDI form toolbar.

Design

Loads the Table form for tables and then copies the SQL contents of the query to the SQL Statement form.

List Double-Click

Executes the Open command on the selected query or table.

List Right Click

Displays a shortcut menu with commands to display the object properties, rename the object, delete the object, load the Copy Table Structure dialog box, and remove all records from a table.


Table Structure Dialog Box (VisData)

Displays all of the properties of the fields and indexes contained in the current table.

Some of the properties are read-write. If they are read-only, they are not accessible by the mouse or keyboard.

Use this dialog box to create, view, and modify table structures.

Some of the dialog items are self-explanatory and the others are described below:

Dialog Box Options

Table Name

Displays the name of the table.

Field List

Displays a list of the fields.

Name

Allows you to type the name of the field you want to add.

Type

Lets you determine the operational or data type of the field.

Size

Lets you determine the maximum size, in bytes, of the field.

FixedLength

If selected, allows you to have a field with a fixed size.

VariableLength

If selected, allows you to have a field whose length you can adjust.

AutoIncrement

If selected, automatically updates the next row or column.

AllowZeroLength

Allows you to have a zero-length string as a valid setting.

Required

Indicates if the field requires a non- Null value.

OrdinalPosition

Allows you to determine the relative position of the field.

ValidationText

Lets you add the text of the message that your application displays if a user tries to enter an invalid value for a field.

ValidationRule

Lets you determine what data is valid in a field as it is added.

DefaultValue

Lets you determine the default value for the field.

Add Field

Displays the Add Field dialog box.

Remove Field

Removes the selected field (Only available with Jet database engine Tables).

Index List

Lists the available indexes.

Name

Allows you to type the name of the index.

Primary

If selected, indicates this is the primary index for the table.

Unique

If selected, indicates that the index entry is unique.

Foreign

If checked, indicates that the index represents a foreign key in the table.

IgnoreNulls

If selected, indicates that fields with Null values are not included in the index.

Required

Indicates whether the index requires a non- Null value.

Add Index

Displays the Add Index dialog box.

Remove Index

Removes the selected index.

Build the Table

Appends the new table to the current database.

Print Structure

Prints the table structure (not available on new TableDef objects).


Import/Export Command (VisData File Menu)

Allows you to import tables from other databases or export tables and SQL query results to another database.

Dialog Box Options

Import

Loads subsequent dialogs from which you can choose the data type and table that you can import from another database.

Export Table(s)

Exports all tables selected in the table box.

Export SQL Results

Exports the results from the current SQL query in the SQL Statement window.

List

Lists the available tables.


Include System Tables Command (VisData Preferences Command)

Allows you to include or exclude the system tables present in .mdb databases as well as system objects in servers, such as a SQL Server.

This command tests if a TableDef is a system object by reading the Attributes property and masking out the dbSystemObject value.


Global Replace Command (VisData Utility Menu)

Allows you to create an SQL update statement to update a column in all of the records in a selected table that satisfy the conditions you define.

Dialog Box Options

Table List

Lists the tables from which you can select a table to update.

Field List

Lists the fields in the selected table from which you can select a field (column) to update.

Replace With

Sets the replacement value for the column data. Single quotation marks will be added for you if the field type is Text.

Criteria

Sets the criteria for the records you want to select and update (leave blank for all rows).


Window Menu (VisData)

Arranges or activates windows.

Use the items on this menu to arrange all of the child windows or icons, or to make a specific child window active.

Commands

Tile

Tiles the open windows so that you can see them all at one time.

Cascade

Arranges the windows in a step-like manner with their title bar visible so you can click the window you want.

Arrange Icons

Arranges the icons so that all are visible.

Windows Lists the open windows.


Zoom Dialog Box (VisData)

Allows you to view and modify text and memo data.

This is an expanded view of a text or memo field. You can display this dialog box from the Dynaset/Snapshot, Table, and Data Control forms by double-clicking a field or by pressing F4. If the recordset is not updatable or is not in edit mode, you will only be able to view the data. If it is updatable, you can make and save changes.

Dialog Box Options

Save

Saves the new text in the field.

Close without Changes

Cancels any changes made to the data.


Line 'item1': Cannot load control 'item2'

An ActiveX control could not be created during the load of a Form, User Control, User Document, or Property Page from a text file. The control may be missing or corrupted. Reinstall the control and try again or check with the control's vendor for more information. This message is written to the error log file.