OLE Automation servers make Visual Basic 4.0 a tool for three-tier client/server applications
Steve Gillmor
With release 4.0, Visual Basic developers can create their own OLE components, deploy them via Remote Automation technology, and programmatically control the development environment. Microsoft's new version offers other significant improvements to the existing Standard and Professional Editions, as well as adding an Enterprise Edition for team-based client/server projects. It's a big leap forward.
As Microsoft moves millions of computer users to the 32-bit world of Windows 95 and NT, Visual Basic has been endowed with both 16- and 32-bit versions. Now users can not only create NT and Windows 95 logo-ready applications, but they can use the same Visual Basic for Applications programming language
that was first introduced in Microsoft Excel.
From 16-bit VBXes to 32-bit OCXes
Since version 1.0, Visual Basic has prospered by providing an intuitive development toolkit augmented with third-party Visual Basic custom controls (VBXes). Version 4.0 delivers a migration path from 16-bit VBXes to 16- and 32-bit OLE Controls (OCXes).
The conversion is automatic. Visual Basic checks to see if OCX updates exist when your project is loaded, and it then prompts you with a dialog box to confirm the changes. You can still use VBXes if you like, but only with the 16-bit versions of Visual Basic 4.0 provided in the Professional and Enterprise Editions. The Standard Edition is available only in the 32-bit version. All three editions ship with 10 Windows 95 custom controls.
Integration of the Data Control and the data-aware controls, which began with version 3.0, continues with the new product. The OLE Container Control now is data-bound, as are the grid, list, and combo boxes.
A new 32-bit version of the Jet database engine, which Visual Basic shares with Microsoft Access, adds referential integrity, cascading updates and deletes, programmatic security control for users and groups, multiple workspaces for multiple simultaneous connections, and Rushmore technology for accelerated queries.
Version 3.0 of the Jet engine also marks Microsoft's first steps toward database replication; developers can now convert databases into replicable forms that can be copied and subsequently synchronized. If you have Access for Windows 95, you can synchronize (or merge) one replica with another via the Windows 95 Briefcase.
We were particularly pleased with Visual Basic's leveraging of the Windows 95 environment. For example, you need Windows 95's expanded Resources to load multiple instances of the program, a requirement for developing remote OLE servers on a local machine. Drag-and-drop and right-mouse quick-menu support (both Windows 95 features) quickly become old friends during forms
development.
The Look and Feel of OLE
Like its predecessor, Visual Basic 4.0 lets you control other applications' objects via OLE Automation. You can use the enhanced OLE Container Control to display stored OLE documents, including audio and video clips. Commercial applications, such as Excel, Word, and Visio for Windows, can provide ToolBox icons to represent their OLE document objects.
The Visual Basic editor reflects the expanded integration of OLE Automation. You use the new Object Browser (
see the screen
) to explore the object libraries supplied by OLE-enabled applications. When an OLE server is installed on your system, you can select its object library from a drop-down list that also includes your current project. You then choose a class from the Classes/Module box, which displays the associated methods and properties in the companion window.
You can show or paste syntax templates into your code, jump to context-sensitive help, or simpl
y use the Browser as a quick way to navigate from one spot to another in your project's code. You can also set an option to view either one procedure at a time or all in a scrollable listing.
OLE Automation and Other Developments
Microsoft is midway through the process of migrating the Visual Basic for Applications language across its Office suite; Office 95 now has it in Excel and Project, with Access to receive it soon, and Word and PowerPoint to follow by year's end. VBA has finally arrived, bringing with it optimized OLE tools such as the
With
and
For Each
statements and the
Collection
data type. These constructs make code simpler, faster, and more readable, plus you can use code generated by the Excel macro recorder without modification.
VBA allows conditional compilation both in code and from the command line, making it simple to create common code that can be recompiled for either 16- or 32-bit versions of projects. You can use the new Com
pile on Demand and Background Compile switches to determine whether a project is to be fully compiled before it starts, compiled as needed to speed application start-up, or compiled in the background during idle time. Support has been added for automatic incremental versioning, and you can now edit and store Windows EXE header-file information (e.g., comments and trademarks).
The Professional Edition takes a giant step by offering the ability to create your own OLE Automation servers. Two types are possible: in-process and out-of-process. Both expose methods and properties that can be browsed by any OLE client application. An in-process server is implemented as a DLL and runs in the same process as the client that accesses it.
Out-of-process servers run in their own address space; they require OLE's proxy/stub mechanism to receive parameters from the client and then return them. The Enterprise Edition adds the capability of executing these out-of-process servers remotely over a network (see the si
debar "Executing Remote Objects"). You can move frequently changing code from front-end client machines to a centralized OLE Automation server for easier maintenance, while processor-intensive tasks are executed by powerful remote servers at the back end.
Visual Basic 4.0 is itself an OLE server, exposing its integrated development environment (IDE) to interaction with OLE-compatible applications, including OLE servers that you can now create. This technology opens Visual Basic to a variety of integrated add-ins, including Wizards, template libraries, forms generators, CASE, and team development tools.
A Promising Future
Visual Basic 4.0 continues to expand the horizons for custom applications. Wholesale adoption of OLE Automation throughout the programming system goes hand in hand with Microsoft's Office 95 strategy. Gone are the synchronization issues with Microsoft Access that required reduced-functionality compatibility layers.
The ability to create OLE Automatio
n servers is not matched in OCXes; that task still falls to Microsoft Visual C++ or comparable tools. Visual Basic continues to generate code that requires a run-time interpreter for execution, with a resulting trade-off in performance versus a compiled product. On the other hand, Visual Basic executables remain smaller, because they don't have to add run-time code for each module in a distributed application.
Furthermore, the Remote Automation technology does not constitute true, distributed-component computing. Rather, it supports a new approach to rapid applications development for client/server tools. Because business rules are separated from the front and back ends, the resulting code can be revised, maintained, and reused more easily. And the new OLE-server capability can make users providers -- not just consumers -- of Visual Basic applications and add-ins.
PRODUCT INFORMATION
Visual Basic 4.0 Enterprise Edition.
.........$995
(Standard Edition, $99;
Professional Edition, $499)
Microsoft Corp.
Redmond, WA
(206) 882-8080
(800) 426-9400
fax: (206) 936-7329
screen_link (65 Kbytes)

Visual Basic 4.0's Object Browser displays objects you create, as well as objects from other applications. Here objects are being selected from Visual Basic's own integrated development environment (IDE) library.
Steve Gillmor is director of Southern Digital, Inc., a consulting firm in Charleston, South Carolina. He is coauthor of
Using Visual Basic 3
(Que/Prentice-Hall, 1993). He can b
e reached on the Internet at
sgillmor@aol.com
or on BIX c/o "editors."