Skip to main content.

Web Based Programming Tutorials

Homepage | Forum - Join the forum to discuss anything related to programming! | Programming Resources

Web Database Developer's Guide with Visual Basic 5

World Wide Web Database Developer's Guide with Visual Basic 5


Features New to Visual Basic 5

This appendix introduces some of the important new features in Visual Basic 5 not specific to Internet database development. You can become more familiar with the features mentioned here by reading other Sams books that concentrate on Visual Basic, such as Teach Yourself Visual Basic 4 in 21 Days or Visual Basic 5.0 Unleashed or the documentation that ships with Visual Basic. This appendix covers topics such as the redesigned development environment and the WinSock ActiveX control.

An Improved Environment

One of the most obvious enhancements to Visual Basic 5 is the new development environment. Long-term plans for the Visual Basic 5 environment is to use the Developer Studio environment used in other Microsoft development products, such as Visual J++ and Visual C++. Of course, you still can use the old familiar Visual Basic development environment referred to as the SDI Development option, but take my advice: Use the new interface shown in Figure A.1. It is much more functional.

FIGURE A.1. The Visual Basic Developer Studio environment.

Coding in Visual Basic 5 has been enhanced and made simpler with features such as the Auto Statement Builder. This feature displays a drop-down box listing all the valid properties and methods when you reference an object or ActiveX control in the Code window. After you select the proper method or property (by pressing the spacebar), the selected method or property name is placed in your code. The Auto Quick Information feature feature provides you with the proper function and method syntax as you code. When you create procedures and functions in forms and modules, you now can assign a description to the procedure or function by using the Procedure Attributes dialog boxes:Procedure Attributes dialog box shown in Figure A.2. Descriptions that you add by using this dialog box are displayed when you view the module or form with the Object Browser; this capability enables you to determine functionality without reviewing the code and searching for comments.

FIGURE A.2. The Procedure Attributes dialog box.

Visual Basic 5.0:debugger
(Visual Basic 5.0)

The Visual Basic 5 debugger has been improved in many ways. Breakpoint lines now appear in red, and a stop sign icon appears in the left margin of the Code window to make these lines easier to find. As you step through the code using the debugger, you will notice that the current line of code that is about to be executed is shown in yellow; a yellow-arrow icon appears in the left margin of the Code window to make it easier for you to see what line of code you are on. The standard Debug window has been replaced by a dockable immediate window, watches, and--my favorite--the local window. The local window tracks the values for all the local variables in a function or procedure without requiring you to type them in or add them. Forms and ActiveX controls also appear in the local window. This window enables you to expand the form or control and to view the current property settings. You now can add watch variables by dragging the variable or object from the Code window to the Watch window. Figure A.3 shows some of the many improved debugging features.

FIGURE A.3.VB 5 Debugging Features dialog boxDebugging Features dialog boxdialog boxes:Debugging Features.

NOTE: The Enterprise Edition of Visual Basic 5, adds a SQL Server stored-procedure debuggerVisual Basic 5.0:SQL SspdSQL Sspd. The debugger allows you to debug SQL Server stored procedures in the same manner that you debug Visual Basic 5 code. You can single step through the stored procedure, set breakpoints, and examine the values of variables.

Project enhancements have been added to Visual Basic 5, such as the capability to work with multiple projects in the same session. The Project dialog boxdialog boxes:ProjectProject dialog box also has been added to improve the project-creation process. This dialog box appears when you start Visual Basic 5 or a new project. You then can select from existing projects or create a new project. Your project choices follow:

Selecting a project type creates a new project of the selected type with the required objects for the project. When you select Standard Exe, for example, the project created contains a single form. If you select ActiveX Control, the new project contains a single UserControl object. You can choose Application Wizard to generate a fully functional application that you easily can modify or enhance. Figure A.4 shows the introductory Application Wizard dialog box. (You'll take a look at other Visual Basic wizards in the next section, "More Wizards.")

FIGURE A.4.The first Application Wizard dialog box.

Many new file types have been added to Visual Basic 5. Table A.1 lists these file types and their new extensions.)

Table A.1. Visual Basic 5 File Types.

File Type Extension
Active Designer Binary File .dsx
Active Designer Cache .dca
Active Designer File .dsr
ActiveX Control .ocx
ActiveX Document Binary Form .dox
ActiveX Document Form .dob
Binary Property Page File .pgx
Class .cls
Control Licensing File .vbl
DLL .dll
Executable .exe
Form .frm
Module .bas
Property Page File .pag
Setup Wizard Dependency File .dep
User Control Binary File .ctx
User Control File .ctl
VB Group Project File .vbg
VB Project Workspace File .vbw
VB Setup Wizard Template File .swt

More Wizards

Visual Basic 5 is packed with many wizards to make application development easier and faster. Table A.2 lists the wizards offered in Visual Basic 5.

Table A.2. Visual Basic 5 Wizards.

Wizard Function
ActiveX Control Helps you develop ActiveX controls.
Interface Wizard
ActiveX Control Interface Wizard
ActiveX Document Migrates existing Visual Basic applications
Migration Wizard into ActiveX document objects
ActiveX Document Migration Wizard.
Application Wizard Generates full-blown applications
Application Wizard.
Class Wizard Provides a graphical tool to help you design and maintain classes
Class Wizard.
Data Form Wizard Generates Visual Basic forms that use data-bound controls to add, update, delete, and query information from a database table
Data Form Wizard.
Property Page Wizard Helps developers construct property pages for user-created ActiveX controls
Property Page Wizard.
Setup Wizard Builds installation routines for user applications
Setup Wizard.
Wizard Manager Helps application developers build wizards
Visual Basic 5.0:Wizards
Wizards:Visual Basic 5.0
Wizard Manager.

Visual Basic 5.0 add-ins

Most wizards are delivered as Visual Basic add-ins--applications that integrate into the Visual Basic design environment using the Add-In Manager. After you register a Visual Basic add-in, you can choose it from the Add-Ins menu in the main Visual Basic Development window.

To register a Visual Basic add-in, follow these steps:

1. From the Visual Basic main menu, choose Add-Ins|Add-In Manager. The Add-In Manager dialog box appears, as shown in Figure A.5.

FIGURE A.5.The Add-In Manager dialog box

2. Select the add-in tools you want to integrate into your Visual Basic development environment by clicking in the box to the left of each add-in that you want to enable.

3. Click OK.

The add-ins now are registered and will appear on the Add-Ins menu when you access it.

A Native Code Compiler

One of the most requested features for Visual Basic has been a native code compiler. Previous versions of Visual Basic compiled code into p-code executables. P-code is not compiled to machine instructions (native) and therefore cannot be executed directly. Instead, p-code executables use an interpreter to convert the p-code into machine instructions. Applications created with p-code don't execute as fast as native-compiled applications. Visual Basic 3 and 4 were criticized for not being able to generate native compiled code like some of their competitors. Visual Basic 5 finally delivers a native code-compiler option. You can generate native code executables for faster execution. You still have the option to create p-code executables, however.

NOTE: I'm glad to see that Visual Basic finally has a native code compiler. I find the whole p-code controversy amusing. I recently attended a conference and listened to the masses complain about Visual Basic p-code. In the very next session, I heard the same people praise Java's lack of a native compiler and its p-code virtual machine (VM)! Go figure--must be the Java VM.

New ActiveX Controls

Many of the Visual Basic controls used in previous versions of Visual Basic have been enhanced in Version 5. Table A.3 lists the new controls offered in the Visual Basic 5 toolbox.

Table A.3. Visual Basic 5 Controls.

Control Function
Animation Displays AVI clips.
Animation control
Chart Offers a pivot capability (still provides backward compatibility with the old Chart control).
Chart control
Internet Transfer Enables you to get and retrieve files from FTP and HTTP servers.
Internet Transfer control
ActiveX:controls:Internet Transfer
MsFlexGrid Provides enhanced grid control to give you more individual cell control and data-binding options.
MsFlexGrid control
Visual Basic 5.0:ActiveX controls
Up/Down Enables you to add increment and decrement features to other ActiveX controls by using the up- and down-arrow buttons.
Up/Down control
WebBrowser Adds WWW browser capabilities.
WebBrowser control
WinSock Adds TCP/IP and UDP (User Datagram Protocol) socket capabilities using an ActiveX control.
Visual Basic 5.0:ActiveX controls
WinSock control

Language Features

Many language features and changes have been added to Visual Basic 5. Several important features--such as interfaces, friend functions, and default properties--already have been discussed in Chapters 8, "Using Classes and Objects in Visual Basic 5," and 16, "Creating ActiveX Controls for the Web with VB 5." This section outlines some of the other language enhancements in Visual Basic 5.

The AddressOf Keyword

If you spent any time using previous versions of Visual Basic with the Windows API, you probably noticed that you can't use a Windows API that requires the address of a function. This problem occurred because you could not pass the address of a Visual Basic function or procedure to a Windows API. Visual Basic 5 offers a new keyword called AddressOf that returns the address of the Visual Basic function. The address of the function you want must reside in a .BAS module. When using the AddressOf keyword, you cannot intercept Windows messages in Visual Basic (this is called subclassing).

Optional Arguments and Default Properties

Optional arguments in procedures and functions now can be of any data type (Visual Basic 4 allowed only variant-type optional arguments). The property procedures Let and Get also can have optional arguments. Class modules now can contain a single property that can be designated as the default property.


Several keywords, such as Events and RaiseEvents, have been added to enable you to create and fire your own events. The WithEvents keyword enables your application to handle and respond to events that fire in an ActiveX component.

Enterprise Features

Visual Basic 5 will ship with the following editions:

The Custom Control Edition is for developers that just want to develop ActiveX controls. The Standard Edition includes the basic functionality of Visual Basic but does not include database features. The Professional Edition includes all the standard database features like DAO. The Enterprise Edition of Visual Basic 5 offers several new features that are worth examining, for instance a developer version of Microsoft SQL Server 6.5.

If you work with Visual Basic and SQL Server, you will want to learn how to use the SQL Server stored procedure debuggerSQL SspdVisual Basic 5.0:SQL Sspd. SQL Server does not come with a debugger, and trying to debug a complicated SQL Server stored procedure always has been a problem. The SQL Server debugger integrates directly into the Visual Basic development environment and enables you to go through a stored procedure step by step to view stored procedure variables. The Enterprise Edition also includes Visual Source Safe to manage code revisions and multiple programmers working on the same project. A developer version of the Microsoft Transaction Server is included as well as native support for RISC platforms. One of the most useful features is a set of tools referred to as the Visual Database tools that allows you to create graphical queries and manage SQL Server and Oracle database schema from the Visual Basic developer environment.

An Improved Three-Tier Architecture

You probably have heard about three-tier applications. The classic three-tier model consists of data services, business services (rules), and client services. The goal of the three-tier architecture is to distribute processing and reduce the amount of software distribution and headaches caused when a business rule or new data service is added or changed. Versions prior to Visual Basic 4 were used in two-tier client/server applications; Visual Basic 4 added remote automation, which made three-tier applications possible. In Visual Basic 4, you could create a client front-end application to provide the client services (user request), an OLE Automation server (ActiveX component) using remote automation as business services, and SQL Server as data services. Visual Basic 5 simplifies three-tier applications by providing distributed components that use COM with Windows 95 and Windows NT 4. Remote automation still is available for other Windows platforms such as Windows 3.11 and Windows NT 3.51. Figure A.6 shows the Remote Automation Connection Manager.

FIGURE A.6.The Remote Automation Connection Manager dialog box.

ActiveX Designers

The ActiveX Designers are features new to Visual Basic 5. These designers help automate tasks that normally require a great deal of code. An ActiveX Designer is not a wizard; instead, it is similar to the standard Visual Basic Form Designer. When you add an ActiveX Designer to a project, the ActiveX Designer creates classes in your project. You then can use the classes created by the ActiveX Designer to create objects and invoke the methods of the object. To aid in code modification and speed development, the ActiveX Designer may offer a Design window to provide a graphical interface to the classes and code. You also can add your own properties and methods to the classes. To see an example using the UserConnection ActiveX Designer, refer to Chapter 9, "Visual Basic 5 Data Access Features."