Visual Basic 2008 Programming: Business Applications with a Design Perspective
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9
Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Appendix A Appendix B Appendix C Home
Loading
Last change: February 13 2016 18:48:19.

Table of Contents

 Chapter in PDF

Chapter 1: Introduction
Last change: February 13 2016 18:48:20.
<<PreviousNext>>

Characteristics of Visual Basic

The vocabulary and syntax of VB are derived from BASIC; however, VB differs significantly from BASIC in several respects:
VB provides a set of visual objects (recognized as controls) that can be drawn easily onto a window (called a form). These controls eliminate the need to develop the code to construct the visual interface. The layout of the windows that contain the controls can be changed easily by dragging and dropping the controls to a new location, without necessitating a change in the code. The process for program development and revision becomes much easier and requires much less time and effort.
The code structure of VB is object-oriented, whereas that of BASIC is procedure-oriented. In BASIC, there is no object. Its code usually follows the following syntax:

Verb Operand List

For example, to display a line of text in BASIC, such as “Display this line”, the code will look like the following:

Print “Display this line.”

Although some VB code still retains this form, most of its code is structured around objects. The syntax appears as follows:

Object.Method (parameter list)

where the so-called method is the action or activity to be carried out.

To display the same line using VB, you would code the following:

Console.WriteLine("Display this line.")

As you can see, Console is recognized as an object. Its WriteLine method will write the line on the object, which is the console.

Object-oriented coding is easier because the object and the action are identified separately, resulting in a more concise set of vocabulary. In BASIC, you must remember to use Lprint to print on the printer and Print to print onscreen. In VB, you use the same WriteLine method to display (print) on different objects. It is also more consistent with the user’s activity in the GUI environment. For example, when you are editing a document with a word processor, you highlight a block of text (identify the object) and then instruct the computer what to do with it (indicate an action such as cut or paste).

Note that an object-oriented language offers many more advancodees than merely simplified syntax. One significant advancodee is code reusability through inheritance, a feature that allows the programmer to extend the functionality from existing code without having to directly modify the original source code. This feature was not available in the previous versions of VB. VB.NET is a full-fledged object-oriented language that offers many exciting features of modern computer languages.

VB is an event-driven rather than procedure-oriented language. As discussed earlier in this chapter, when a procedure-oriented program runs, it dictates the sequence of operations. This means the programmer must predefine the sequence when developing the program. In addition, changing the sequence of operations requires revising the program. On the other hand, an event-driven program does not dictate the sequence of operations. The user can instruct the computer to perform whatever operations the program is capable of, in any sequence he or she desires. This offers the user flexibility. Any changes in the sequence of operations will not call for revising the program. In this sense, an event-driven program is easier to develop, and requires fewer revisions.

Event-driven programs, however, present the programmer with a different kind of challenge. In many instances, an activity can be carried out only after some prerequisite actions have been taken or data are ready. For example, when the user clicks the Send button in an email application, the target email address, the subject line, and the body of message must all be filled in first. When the user initiates the action, there is no guarantee that the prerequisites have been met. As a programmer, you must find ways to ensure that the prerequisites are there.

Last change: February 13 2016 18:48:21.
<<PreviousNext>>