Features of the Visual Basic Control Creation Edition

Microsoft Corporation

November 1996

Contents

Introduction
Integrated Development Environment
ActiveX Control Creation Tools
Extensibility—ActiveX Controls
Customizable Development Environment

Introduction

Software developers and reviewers need information that answers questions such as "What's new?" or "Why Should I upgrade?". This section is a guide to the new and enhanced programming environment in Microsoft® Visual Basic® version 5.0 Control Creation Edition.

Microsoft Visual Basic Control Creation Edition is not only the fastest and most efficient way to create ActiveX™ Controls, it shares the most widely used programming environment for Windows. Today, there are over three million developers using Visual Basic.

Microsoft Visual Basic Control Creation Edition improves on the development foundation first introduced in previous versions in three key areas:

Integrated Development Environment

Visual Basic for Applications is a shared component. Specifically, it is a common development environment consisting of a forms package (which is a host of ActiveX components), a code editor, and a debugger. Visual Basic Control Creation Edition and many other Microsoft products such as Microsoft Excel, Access, Word, PowerPoint, and Project share this common development environment. Collectively, these products represent hundreds of ActiveX components that can be easily tailored to solve specific business problems.

As a result of the recent Microsoft announcement to license the Visual Basic for Applications environment to third parties, the programmer's reach extends even farther. Programmers can now look forward to being able to program products from Adobe Systems, Inc.; Autodesk, Inc.; Visio Corporation; SAP AG; and many more.

The Visual Basic for Applications environment includes the Visual Basic for Applications language engine, a powerful editor, an Object Browser, and debugging tools.

The IDE of Visual Basic for Applications is a substantially improved programming environment. The new IDE provides:

Figure 1. Visual Basic for Applications 5.0 editor

Code Window

Drag and Drop has been implemented throughout the editing environment.

Developers can drag and drop code and variables:

Project Explorer

Figure 2. Project Explorer

Visual Basic 5.0 now has the ability to load several projects at once. This is extremely useful for designing and debugging reusable ActiveX controls because both the control project and the host project can be simultaneously loaded. By placing a breakpoint in the source code of the control, the programmer can debug an application line by line, starting in the host application, stepping into the source code of the control, and stepping back out to the host again.

The Project Explorer displays, in an outline view, project components for all loaded projects (for example, ActiveX controls, forms, classes, modules, and resource files) associated with each currently open project. Each project appears as a new root in the outline control. This enables easy switching between different documents' projects for developers working on multiple projects simultaneously. A project exists for each open document and template.

For easy managing of a workspace that may have several different projects open, expanding or collapsing a folder shows or hides all open components (forms, code modules, and so forth) within that project.

You can expect to find the following components listed with a given project:

Properties Window

Figure 3. Properties window

The Visual Basic environment has a Properties window that displays properties of user controls, forms, modules, and classes.

There are two tabs: Alphabetic and Categorized. The Alphabetic tab view provides an alphabetical list of properties. In the Categorized tab view, properties are grouped by category, for example color, font, and position. These categories can be expanded or collapsed in the Properties window. An ActiveX control created in the Visual Basic Control Creation Edition can specify the desired category for any custom properties it exposes.

Like most of the operations in the Visual Basic for Applications editor, component type information is used to the programmers advantage extensively. Because ActiveX components are based on the Component Object Model (COM), they all contain type information that describes their interfaces. In other words, any development tool can easily determine all exposed objects, properties, methods, and even version numbers of ActiveX components. Whenever a property is selected in the Property Browser, descriptive functional information is displayed at the bottom of the window.

Debugging Tools

Figure 4. Debug menu

VBA includes new and enhanced debugging tools to help the developer identify compile errors, program logic errors and run-time errors. The debugging tools in VBA include the Locals window, the Watch window, and the Immediate window. The Locals window also includes the Call Stack Browser  which shows the current variable and enables the developer to jump to procedure definitions and references.

The Local Variables window automatically displays all of the declared variables in the current procedure and their values.

The Watch window enables monitoring the value of a particular variable or expression. Code execution may be interrupted when a watch expression's value changes or equals a specified value

The Immediate window that instantly evaluates any Visual Basic expression or statement, such as call to a Sub or Function.

The Call Stack Browser  displays a list of currently active procedure calls during break mode.

To speed the debugging process, code can be dragged and dropped from the editor into the Immediate and Locals windows.

Object Browser

Figure 5. Object Browser

The VBA environment has an improved ActiveX Object Browser. The browser differentiates between built-in properties, custom properties, methods, event handlers, and user-defined procedures, as well as indicates globally accessible members. The browser also shows function-return types, parameter names and types, and user-defined types and constants. Hyperlink jumps to referenced objects enable easy navigation of the object hierarchy. New to the Object Browser is the ability to search for objects and members across type libraries.

IntelliSense Features

Visual Basic for Applications 5.0 brings Office IntelliSense technology to the developer, providing on-the-fly syntax and programming assistance and reference. The developer can choose to turn these automated features off and access them on demand through the VBA menu or with keystroke combinations. The following features are available in the Code window and the Immediate Window:

Complete Word

Completes the word that is being typing once enough letters are entered to make it distinct. Keystroke equivalent: ctrl+alt+a. For example, in the code window, type msg followed by ctrl+alt+a to complete the word MsgBox.

Quick Info

When a procedure or method name is entered (followed by a space or an opening parenthesis), a tip automatically appears beneath the line of code. The tip gives syntax information about the procedure. Keystroke equivalent: ctrl+i.

Note   This tip works for built-in language constructs as well as any user-defined functions.

Figure 6. Quick Info

List Properties/Methods

Displays a pop-up menu listing the properties and methods available for the object that precedes the period. Keystroke equivalent: ctrl+j.

Note   This works for any built-in, external, or user-created ActiveX component.

Figure 7. List Properties and Methods

List Constants

Displays a pop-up menu listing the constants that are valid choices for the property typed and that precede the equals sign (=). Keystroke equivalent: ctrl+shift+j.

Note   This works for any built-in, external, or user-created ActiveX component.

Figure 8. List Constants

Data tips

When VBA is in break mode and the cursor is placed over a variable, the value of the variable is displayed in a tooltip-like window.

Figure 9. Data Tips

Note   Expressions can be partially selected when in break mode for immediate evaluation by a data tip.

Figure 10. Data tips for partially selected code fragments

Margin indicators

Developers can set a breakpoint, set the next statement, or set a bookmark by clicking in the margin of the code editor

Figure 11. Margin Indicators

Block comment and uncomment

An Edit toolbar provides quick access to this feature that enables developers to select blocks of code and, with the click of a button, comment out the entire selected block of code.

ActiveX Control Creation Tools

Introduction

Before the Visual Basic Control Creation Edition, ActiveX components could only be created with the C/C++ language. The Visual Basic Control Creation Edition represents a powerful new approach to creating ActiveX controls. Using the same visual metaphor for building controls as it does for applications, the Visual Basic Control Creation Edition allows controls to be created entirely from scratch by modifying existing controls (subclassing) or by assembling multiple controls.

The ability to create new controls from existing controls gives Visual Basic programmers an astonishing head start when developing new, specialized components. Rather than starting from scratch, programmers can use Visual Basic Control Creation Edition to customize any of the 2000 or more commercially available ActiveX controls.

ActiveX controls can be hosted in a wide variety of development tools. In Microsoft Office 97, ActiveX controls can be placed on Microsoft forms or directly on Microsoft Office documents. Using the ActiveX Control Pad, Microsoft Visual InterDev™, or Microsoft ActiveX controls can also be placed on web pages. When ActiveX controls are placed on web pages, they behave like Java applets. Like Java applets, ActiveX controls are automatically downloaded if the user surfing the web page does not already have them on their machine. Likewise, if the user has an outdated control, the newer control will be downloaded automatically.

ActiveX Control Features

When constructing an ActiveX control with the Visual Basic Control Creation Edition there are many new features upon which the developer may draw. These new features are designed for ease of development, high performance, and functionality.

The following list contains some of the new features that ActiveX control developers may take advantage of:

ActiveX Control Wizards

Visual Basic Control Creation Edition comes with two invaluable Wizards that greatly assist the programmer with the creation of ActiveX controls. The ActiveX Control Interface Wizard allows the programmer to define the properties, methods, and events easily for a user created ActiveX control.

Figure 12. The ActiveX Control Interface Wizard

Figure 13. The ActiveX Control Interface Wizard

The Property Page Wizard automatically creates custom property pages for a user-defined control. By creating custom property pages, the author of an ActiveX control can create custom interfaces for the setting of properties.

Figure 14. The Property Page Wizard

Figure 15 is an example of a custom property page for a Calendar control created with Visual Basic Control Creation Edition. Regardless of the development tool hosting this control (Visual Basic 4.0, Visual Basic 5.0, Visual C++, Office 97, or ActiveX Control Pad), right clicking on the control at design time will always display the custom property page. Custom property pages not only make ActiveX controls easier to reuse across different development tools, they also provide a consistent, intuitive interface for the control. Note that the custom property page can also contain a preview of how the control will look after the changes are applied.

Figure 15. An example of a custom property page

Setup Wizard

ActiveX controls, like Java applets, are designed to automatically download themselves to a user’s machine on demand. The process of compressing a control and any other files it may depend on, creating a CAB (cabinet) file, and a working example of an HTML page is entirely handled by the Setup Wizard.

Figure 16. The Setup Wizard

Extensibility—ActiveX Controls

Visual Basic 5.0, along with all Microsoft Office 97 applications, support ActiveX controls, formerly called OLE controls or custom controls. ActiveX controls are prebuilt, reusable software components. Any of these controls can be used as is or can be customized using the Visual Basic Control Creation Edition.

Today, there are over 2000 commercially available ActiveX controls in almost every conceivable category including data access, 3D modeling, multimedia, imaging, manufacturing, real-time data acquisition, charting, reporting, data encryption, data compression, mainframe connectivity, interface design, telephony, fax, voice, and instrumentation.

Toolbox

Figure 17. Toolbox

The toolbox displays all ActiveX controls registered for the current development session. By right clicking on the toolbox, developers can fully customize and organize their controls by whatever category they desire, as well as add and remove controls.

Figure 18. Adding ActiveX controls to the development environment

Customizable Development Environment

The Visual Basic for Applications environment now includes command bars, a new type of menu/toolbar system. This new system offers dockable and floating toolbars that are fully customizable. Developers can modify any built-in menu bar or toolbar and can create and modify custom toolbars, menu bars, and shortcut menus. Because toolbars and menus are included in command bars, developers use the same kind of controls on each one. For example, the docked toolbar shown in the following illustration contains three buttons.

The menu shown in the following illustration contains the same three commands displayed as menu items.

In Visual Basic for Applications , menu bars and toolbars can contain menus. The floating toolbar shown in the following illustration contains three buttons and a menu that contains the same three buttons displayed as menu items.