Learn the most popular programming language of the most popular Operating System: Windows

Ad

Understanding the Concept of a Visual Basic Project

Every Visual Basic application is defined and saved as a project.  Each project, in turn, consists of a collection of files.  These files can include modules, insertable objects, and a single resource file.  Projects themselves are tracked by a project file, which has a .VBP extension.

Form modules, as discussed earlier are first seen as a windows with a caption, but little else.  From modules contain coded instructions called procedures for the form itself and for the controls and insertable objects placed on the form.  Other modules include standard modules and class modules.  You will learn the differences among these types of modules as you progress.

The tools of the toolbox represent controls and insertable objects.  The toolbox can be made visible or invisible by choosing View, Toolbox.  When visible, the toolbox contains a set of icons – each representing a standard or a custom control.  A Visual Basic project always includes a set of standard controls and can also include custom controls.  Each custom control has an .OCX extension.  In this section you are asked to write some beginning Visual Baisc procedures for forms.  In “Adding Controls and Event Procedures to Form Modules,” you will add procedures for stand controls.

Projects can also include a resource file, which can contain either binary data, such as images and sounds, or string data.  Resource files need to be created by a Windows resource compiler (typically a C or C++ language compiler), or you can use the resource compiler bundled with Visual Basic.

The Files that Make Up a Stanbdard EXE Project

In working with Visual Basic, you are asked to work with different types of files.  Each file type is given a unique file extension, which enables you to identify it.  Visual Basic contains over two dozen types of files, each of which has a different extension.  The Table below shows eight common file types contained within a project, their extensions, and their meanings.

Table 2.1 Common File Types
Type of File Extension Extension
Standard Module .BAS Each coded module is saved as a file
Class Module .CLS Each class module is saved as a file
Form Module .FRM Each form is saved as a file
Binary .FRX Each Icon or Picture property value is saved by Visual Basic in .FRX form
Log .LOG A file for logging load errors.
Resource .RES A project can have a single resource file for storing binary and string data
Project .VBP Each project is saved as a file.
Workspace .VBW Each workspace for a project is saved as a file.

This file notation is used throughout.  When you save a form, it is saved with a .FRM extension, and all event procedures written for that form are also saved in the .FRM file.  Because procedures are not saved as separate files with their own unique extension, they become bound to forms.  When you write and save a coded standard module, it is saved with a .BAS extension.  Coded modules are thus different from event procedures written for forms.  Coded modules are not bound to forms.

The Project Window (Project Explorer) in the Visual Basic Design Environment

Whenever you begin a Visual Basic program, you begin a new project.  Each project can contain several forms, several standard and class coded modules, and custom controls.  The Project window displays a list of all modules assigned to a project.  Whenever you begin a new project, a default Project window is created (see Fiigure 2.1) .  If the window fails to appear or is hidden, choose View, Project Explorer; press Ctrl+R; or click the Project Explorer icon.  In addition, your environment can be set to remove the docking of the Project Explorer.  This setting is controlled by choosing Tools, Options, clicking the Docking tab, and turning off the Project Explorer and Object browser selections.

Figure 2.1: This Project window reveals that Project1 contains a forms folder that is limited to a single form.

Figure 2.1 illustrates a Project window that contains three small icons on the left-hand side.  The leftmost icon enables you to view code, while the middle one enables you to view the underlying object (which in this case is the form).  Forms, the third icon, is important when projects become large and contain several forms or when projects are combined.  With large projects, all forms are placed in one folder, and all modules are placed in a second.  Toggling forms enables you to show or hide all forms for a project that are contained in the Forms folder.

Share:

No comments:

Post a Comment

Trending

Popular Posts

Search This Blog

Powered by Blogger.

Featured Post

Coded Statements and Methods

In the preceding procedure , you wrote several coded instructions, which introduced two different programming statements and a method: the D...

Recent Posts