Introduction to VB6

After you open VB6, a New Project dialog box (Figure 13-2) prompts you to choose a project type. For building COM objects for use with a web application, choose ActiveX DLL and then click Open.

click to expand
Figure 13-2: Visual Basic 6 New Project dialog box

VB6 allows you to create many other types of projects, ranging from executables to ActiveX controls. Most of the project types, such as ActiveX EXE and Standard EXE (executables), are best suited for desktop development. An executable project will be used later in this chapter for generating a test harness for an ActiveX DLL. An ActiveX Control project will generate an ActiveX control that may be deployed to a web browser or used in desktop applications. Due to the constraints of deployment with the VB runtime, ActiveX controls written in VB are not well suited for web deployment, since a restart is often required after installation for the client to use the new Active X control.

Setting Up an ActiveX DLL Project

After you choose to create an ActiveX DLL project, VB6 will create a new project named Project1 and a new class named Class1. If the project were to be compiled immediately, the default name for the DLL would be Project1.dll and the class identifier, or CLSID, that would be used to identify the class in the ASP command Server.CreateObject would be Project1.Class1. The class and the project names, however, should be meaningful rather than these nondescript default names. The class should be named after a real- world entity that is part of the solution that is being built. The project should be named in a way that defines the container or deployment file within which the class will reside.

Note 

All COM Objects made from an Active X DLL project in VB6 have .dll as a file extension.

In this example, suppose the web application is part of a web-based furniture configuration project named ConfigSeat. A chair object was identified in the requirements- gathering effort, and the class being built is to represent the chair that might be part of the software’s business logic. A good name for this class is clsChair. The cls prefix is useful because it identifies the object as a class. The Auto List Members of Visual Basic’s IntelliSense shows the names of the parts of a project and will not distinguish between classes and other types of files that could exist in a given VB project, such as a module. Using the cls prefix will help make the task of identifying the class in the Auto List Members list easier to identify.

To change the default class name, open the Properties window by choosing View | Properties Window, and select the class in the Project Explorer. Change the name Class1 in the Name section to clsChair, as shown in Figure 13-3. (The other properties in the Properties window should remain unedited. Changing the values of these settings requires advanced knowledge of VB ActiveX development and is beyond the scope of this chapter.)


Figure 13-3: Properties window for class clsChair

In addition to the class name change, the project name can also be changed. Right- click the project name in the Project Explorer and choose Properties. In the Project Properties dialog box, under the General tab, is a Project Name text box, in which the default name Project1 should appear. For this example project, ConfigSeat is a good project name. Delete the name Project1 and type ConfigSeat in the text box, as shown in Figure 13-4.

click to expand
Figure 13-4: Project Properties dialog box with the new name ConfigSeat

Many programmers are unaware of the automatic version numbering capabilities offered by VB6. The benefits of this feature are great, and the effort to enable it is minimal. The version number helps to determine which version of the DLL is the latest and provides a unique identifier as to the version of the DLL that should be used. Each time the software is compiled, the version number will be advanced. As is often the case, a COM object will be deployed multiple times to a host. Since you only want one version being used by the software consumers, the version number helps to ensure that there is only one version and that the version used will be the latest version, which has the highest number. If there are no version numbers, the file date is used to determine the newest version. Sometimes there are situations that occur, especially when there are multiple programmers working on a given project, where the host will not use the latest version and the file date is not an accurate identifier of the latest version. To enable automatic versioning, click the Make tab in the Project Properties dialog box. Choose the Auto Increment checkbox. It generates a new version number for the project each time it is compiled. Not checking this box does not cause any failure to occur in the software. Even though the Auto Increment checkbox is not checked by default, it should be checked for every project as a matter of good practice.




IIS 6(c) The Complete Reference
IIS 6: The Complete Reference
ISBN: 0072224959
EAN: 2147483647
Year: 2005
Pages: 193

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net