Visual Basic

views updated May 21 2018

Visual Basic

Visual Basic is one of the most widely used programming languages in the world. The major reason for its popularity is that it allows programmers to create Windows applications quickly and easily.

The origins of Visual Basic are found in a programming language created in 1964 by John Kemeny and Thomas Kurtz. BASIC (Beginners All-purpose Symbolic Instruction Code) was originally an interpreted language that was designed to simplify the programming process and make programming more accessible to the world at large. Using that philosophy, Microsoft integrated a BASIC interpreter into its operating system MS-DOS. Despite its wide distribution and relative simplicity, BASIC was not able to compete with faster, compiled languages such as C or C++. Thus, BASIC was commonly used for trivial or educational purposes, whereas "real" applications were usually developed in other languages.

In the late 1980s, Microsoft Windows and other graphical user interfaces (GUIs) were still in their infancy. Most PCs were still using text-based operating systems. As people began to realize the benefits of graphical operating systems, Microsoft Windows gained popularity. Unfortunately, creating Windows-based programs was exceedingly difficult. Extensive code had to be written to define precisely what the interface would look like as well as how a user would interact with it.

To overcome this problem, Microsoft revived BASIC in 1991 by introducing Visual Basic 1.0. Using BASIC's heritage of simplicity and its general syntax , this new development tool gave programmers an easy way to create Windows applications. In the years since, Microsoft has continued to improve Visual Basic by releasing newer versions. These improvements include not only enhancements to the development environment but also modernization of the core BASIC language as well. These renovations include making BASIC object oriented and fully event driven, and overcoming the limitations of being interpreted, allowing programmers to generate a compiled executable code .

Using Visual Basic

The process of creating a program in Visual Basic can be clearly described in three stages: (1) Draw the interface on the screen by adding controls. (2) Define important characteristics of the controls. (3) Write code to determine how a control will react to user actions.

In the first step, the programmer creates the interface using an on-screen drawing tool. Windows controls, such as buttons and input boxes, are added to a workspace using an application similar to Paint (the standard Windows drawing utility). Almost all of the standard Windows interface components are available by default. More advanced controls, such as status bars, can also be added. The arrows in Figure 1 show the results of adding two text labels and a button to the workspace.

Every control has a set of characteristics that make it unique. For example, buttons have properties such as name (how the program will refer to it) and caption (the text that will be used to label it). In the second step, the programmer sets the initial values for the control in order to customize the appearance and behavior of the controls. As seen in Figure 2 (see page 210), the text on the button has been changed to "Click Me" by altering a property of the button.

In addition to the properties, every type of control has different ways that the user can interact with it. For example, buttons are clicked, or text is entered into an input box. These are known as events. Whenever an event occurs, the program must respond appropriately. The programmer is responsible for empowering the controls by providing a specific set of instructions regarding how the system should respond to the events. This usually comes in the form of doing some calculation and then updating the properties of other controls on the screen to reflect the current state of the system. Figure 3 shows some actual code. In the example, when the button is pressed, the program produces a label that keeps track of the number of times the button is pressed.

At this stage, the program must be run to evaluate that it is working properly. Figure 4 shows a screen shot of the program after the button has been pressed three times. While testing the program, the programmer has the ability to examine the inner workings of the program and even change the program while it is running. After the programmer is certain that the application functions properly, Visual Basic compiles the code into a working executable program that can be distributed to other users.

In addition to creating new programs and applications, Microsoft has also extended portions of Visual Basic to existing applications. Large-scale, popular applications like Microsoft Word, Excel, and Access contain a limited subset of Visual Basic capabilities known as Visual Basic for Applications (VBA). Often used as a macro-language, VBA can be used to control parts of existing applications. This is a very useful feature for automating repetitive tasks or for customizing existing applications to meet a user's personal needs.

Another variation of Visual Basic offers an alternative to JavaScript. Visual Basic Scripting Edition, or VBScript, can be embedded into HTML pages and distributed over the Internet. VBScript can be very useful for making dynamic web pages or for validating user input before it is submitted.

Both of these dialects of Visual Basic follow essentially the same syntax rules as the full-programming edition. Although some variation exists, this allows programmers to extend their existing skills without needing to learn something completely new.

Like its text ancestor, Visual Basic has greatly simplified the task of programming and enjoys widespread distribution. Unfortunately, to some degree, it has also inherited the stigma of being a second-rate programming language. This conception actually arises from the trade-off between ease-of-use and control. Visual Basic attempts to shield programmers from some of the details associated with what occurs at lower levels of the computer. This restricts the programmer to generalized, high-level functions. Alternative languages, such as C++ grants programmers more control over how processing occurs, and thus they can optimize the code to the specific task at hand. If sub-second optimizations are critical to the success of the program, Visual Basic may not be adequate. However, most applications to be run by businesses will not benefit from such minute speed-ups and programmers will find that the simplified development makes Visual Basic very appealing.

see also Java Applets; JavaScript; Procedural Languages; Programming.

Stephen Hughes

Bibliography

Overland, Brian R. Visual Basic in Plain English. Foster City, CA: IDG Books World-Wide, 1999.

Perry, Greg M. Sams Teach Yourself Visual Basic 6 in 21 Days. Indianapolis, IN: Sams, 1998.

Schneider, David I. An Introduction to Programming Using Visual Basic 6.0. Upper Saddle River, NJ: Prentice-Hall, 1998.

Visual Basic

views updated Jun 27 2018

Visual Basic A system for rapid development of Microsoft Windows applications. The user designs a visual interface by selecting “controls” (e.g. menus, dialog boxes) from a predefined palette, and then provides code in a dialect of Basic to specify the actions for each control in response to user input. Because the code is interpreted, the run-time performance of applications produced in this way is inferior to that of an application coded in C or C++.

Visual Basic for Applications

views updated May 23 2018

Visual Basic for Applications (VBA) A common control language for Microsoft applications, in which Basic control structures and variables are supplemented by procedures and functions specific to the application. It was first implemented for the Excel spreadsheet. See also Word Basic.

More From encyclopedia.com