Tuesday, 07 September 2010
PicoSearch

Faster code, faster forms

This column appeared in the September 1998 edition of EXE, and was a review of the newly-available Visual Basic 6.


The version 5 release of Visual Basic delivered a few fundamental changes. The new Integrated Development Environment was the most obvious, while the "true" compiler was one of the features that was hitherto the most asked for. There was also direct support for Internet development. To reinforce the strength of the product, the Enterprise Edition also shipped with SQL Server and Transaction Server. These new features gave the product specification quite a leap from version 4.

Version 6 of the product is more of a maturation of the previous release. In this month's column I shall be discussing the new features to be found in the product. This review is based upon release candidate 1 of Visual Studio 6 Enterprise Edition, so while I wouldn't expect any specification changes to creep in at this late stage, you never know what they might drop or throw in at the last minute.

My first observation is that the Visual Studio 6 product is much more of an integrated effort than has previously been the case. After the installation you will find that Visual Studio 6 is now under a single menu group on the Start menu, with one menu entry for each specific language product. Everything else is bundled under a common Tools submenu and, if appropriate, an Enterprise Tools submenu. Because the pre-release software (that I saw) only appeared in the full Visual Studio format I cannot tell how the standalone Visual Basic product will be packaged. However, it's quite apparent that Microsoft will be making a stronger-than-ever effort to get you to buy the full Visual Studio package. The splash screen that is displayed when the IDE loads has been updated to emphasise the fact that it's part of the Visual Studio family. There is also a healthy complement of BackOffice products for the developer to work with.

Despite the many new features one thing that still hasn't changed is the menu editor - it's still the same as in version 1! While the menus that it produces are completely usable it is not possible to directly create Office-style menus. Apparently Microsoft are not prepared to make the relevant libraries redistributable so it's necessary to resort to third party tools to achieve this effect. In next month's column I'll be giving some coverage to this very issue.

General features

Microsoft has, as usual, been promising faster code, faster forms, and even faster natively compiled apps in Visual Basic, and this does appear to be the case. The native code compiler is still the Visual C++ back-end, which itself is currently getting very favourable reviews - even in its beta state - for its performance increases (to the order of a 20% improvement in speed). Performance has also been refined for multi-processor targets.

This new version contains additional string manipulation functions that are really intended for grown-ups. The StrConv function has a new optional parameter that allows you to specify a LocaleID if you don't want to use the default one. A new Filter function returns a subset of a string based upon a filtering criterion. There are also functions to reverse, join, and replace strings, new formatting functions, and a couple of routines that give you the names of a weekday or a month that are derived from a date.

One feature that I really do like is the FileSystemObject that comes with all editions of the product. This option needs to be checked in the References dialog box under the Project menu - it's called the Microsoft Scripting Runtime. Once you've created a new instance of one of these objects you can do all sorts of useful things with folder and file objects, such as create and delete them, and get information about them. For example if you want to be able to delete a folder and not have to worry about writing the logic to traverse the entire subtree and delete everything else first then you can use the DeleteFolder method. To test this I created a directory called c:\Test and then copied the contents of the nearest data CD into it. Because it was a CD all of the files were marked as read only. I ran the following

Dim fso As New FileSystemObject
Fso.DeleteFolder "c:\test", True
Set fso = Nothing

and it worked perfectly (the True parameter is to tell it to ignore any read-only flags).

The manipulation of controls has been improved somewhat. Many of the standard controls now have a Validate event that offers a better degree of control than the LostFocus event. If you set the corresponding CausesValidation property to True then the Validation event is fired when the user attempts to exit the control. The LostFocus event is only fired once the validation has been successful. You can also programmatically add and remove controls to or from a form at runtime.

One feature that was sorely missing from version 5 has now been addressed: namely, user-defined types can be arguments or return types of public properties and methods. Similarly, Functions and property procedures can now return arrays.

I was slightly surprised to find that Visual Studio 6 still displays the Help Workshop in the Tools menu. The newer HTML Help has been in circulation for a little while now and Microsoft has stated that it is the way forward in terms of help technology. However the HTML Help Workshop is on disk 1 so at least it's catered for, it's just not displayed in the Setup program. For new systems I would suggest that it's worth trying to make the effort to get to grips with the new help system if only to keep your skills marketable.

The Application Setup Wizard has been enhanced and updated to become the Package and Deployment Wizard. The approach remains the same - you either want to create a Setup program or an Internet deployment pack. However the files that go to make up the installation pack are now placed in a CAB file as found in Microsoft's commercially available products. One useful addition to the Wizard is that you get an editable mini-explorer view of the menu entry that will be created for the Start menu, so you can configure this accordingly. The backdrop of the resultant setup program is still the gradated blue to black which to me feels old hat now, but overall the Wizard is a useful and worthwhile product. I think that professional developers will still want to turn to a third-party tool (such as InstallShield) for their installation routines.

Database and BackOffice

This is perhaps the area where the greatest improvements have been made. As has already been widely reported Visual Basic 6 now comes with ADO (ActiveX Data Objects). ADO is the next logical successor to both DAO and RDO although both of these technologies are still present and supported. The strength of ADO is that it provides a common programming model for both local and remote data access. This comes about because it's actually an object wrapper around OLE DB, an architecture that exposes a set of COM interfaces to provide uniform access to data stored in diverse information sources. These sources could be hardware devices, conventional relational databases, or they could be a rich source of data such as an Exchange Server, the forthcoming NT5 directory services, or indeed in some future source of data that has not been invented yet. The point is that it helps to provide a common method of accessing data wherever it is. Many corporate systems that are developed today often have to import data from different sources, often to a central location to simplify the design. With an OLE DB platform you should be able to access multiple diverse data sources from different locations in a tidy and consistent manner.

Several new and enhanced tools beef up the data access side of the product. The Data Environment Designer is an ADO replacement for the UserConnection designer (which is still included). It's purpose is to provide a design time environment that lets you create a data access definition that can be programmatically manipulated at runtime. It provides support for the creation of multiple ADO Connection and Command objects within one DataEnvironment object, thereby supporting connections to multiple data sources.

The Data Report Designer provides the ability to create banded hierarchical reports. Fields can be dragged from a Data Environment Designer and dropped into the report design. When a field is dropped a text box control will automatically be created that is bound to the relevant DataMember and DataField properties. Needless to say the Designer has the facility to publish reports in HTML format as well as directly to the printer. If you choose to use the print option then you can also generate a print preview window beforehand, although this can only work if there is a printer driver already installed because the report engine needs to be able to reference a set of metrics.

Thanks to the careful design that has gone into ADO it is possible to pass RecordSet objects across process and machine boundaries, which is most likely to be used in passing data from one tier of functionality to another. This RecordSet object exists within the full ADO library, but can also be found as a separate component (set the client to reference the Microsoft ActiveX Data Objects RecordSet 2.0 Library). The benefit of also providing a separate implementation is that much of the associated baggage can be discarded. Because the passed object is purely a RecordSet there are no Command, Connection, and Parameter objects and therefore the footprint is as unobtrusive as possible.

Integration with Microsoft Transaction Server (version 2) has been tightened, and there is support for the Microsoft Message Queue technology.

Internet

Although Internet technologies still continue to be implemented ad nauseum throughout everything that Microsoft produces, there are in fact two specific new related features worthy of note here. The first is that a new icon labelled IIS Application is visible in the New Project dialog when Visual Basic 6 is loaded. IIS Applications offer new elements called WebClasses which are units of code that can be run from an Internet server. A WebClass is created with Visual Basic and compiled into a DLL. The DLL is launched at runtime by an Active Server Page (ASP) instance, and the WebClass and the ASP exist in a 1 to 1 relationship for the duration of a single client's connection. WebClasses have been developed by Microsoft to help developers who aren't familiar with HTML to get up and running with Internet server applications. Using Visual Basic as the underlying language lets the developer interface directly with the IIS object model and hence be given the opportunity to write very efficient code. The WebClass, for its part, generates an appropriate stream of HTML derived from the underlying Visual Basic code.

The second item of note is the DHTML Designer. DHTML is still in the process of being agreed upon by the Internet community as a whole, but Microsoft implemented it anyway in Internet Explorer 4. A DHTML based application is created through another new icon in the New Project dialog. Once in the design window a page can be created from scratch, or an existing page can be referenced and modified. DHTML allows you to write Visual Basic code that will result in a local response to user activity on a web page, without the need to pass the information back up to the server for processing.

Documentation

Further evidence of the integration with Visual Studio can be seen in the disappearance of the Books Online application. All of the documentation for each development tool has now been assimilated into the MSDN library. Microsoft Press has announced for September the Visual Basic 6 Reference Library (ISBN 1-57231-864-3) which appears to come as three manuals, and the Visual Basic 6 Programmers Guide (ISBN 1-57231-863-5). Microsoft has also confirmed that they will be producing a Visual Basic 6 title in the Mastering Series.

The Visual Studio 6 product set is due for release on September 2nd 1998 although at the time of writing the pricing had yet to be announced. Visual Basic 6 will come in Learning, Professional and Enterprise editions.

Copyright ©2002 Jon Perkins I, Jon Michael Perkins, hereby assert and give notice of my right under section 77 of the Copyright, Designs, and Patents Act 1988 to be identified as the author of the foregoing article.