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

Ad

Evolution of Visual Basic

In the last several years, Visual Basic has evolved rapidly.  Until recently, Visual Basic was a proprietary language used only by Microsoft products.  Microsoft now licenses Visual Basic for Applications to those software developers who want to add programmability to their applications.  This will increase Visual Basic prevalence.

Visual Basic is now the universal macro language for the Microsoft Office suite of applications.  The newest version of Word, for instance, has migrated to Visual Basic for Applications.  Other large programmable application, such as Microsoft Project, also use Visual Basic for Applications.

Another important development of the Visual Basic language is the advent of the Visual Basic Scripting Edition (also known as VBScript) for developing Internet-enabled applications.  The capability of Visual Basic to create downloadable ActiveX components and the capability of VBScript to manipulate Internet browsers and Internet documents (HTML documents) suggests Visual Basic will play a major role in the explosion of Internet and intranet application.

This text assumes you have the Standard, Professional, or Enterprise Editions of Visual Basic.  All chapters other than the database chapters can be completed using the Standard Edition of Visual Basic, but you will need the Professional Edition to work with Data Access Objects “Using Data Access Objects.”  Microsoft Office will also need to be installed on your computer.

Share:

Interpreted or Compiled Languages

Computer languages can be interpreted or compiled.  An interpreter executes a program, while a compiled language uses a compiler to translate the high-level language into machine language.  Visual Basic is now both an interpreted language and a compiled language.  The developer has a choice when creating a Visual Basic executable whether to make a compiled program or an interpreted program.  You will create both types of programs here.

The main advantage of an interpreted language is immediate response.  Program development often goes faster because the code instructions can be easily modified and immediately tested without being compiled (or translated) first.  This saves you considerable time in writing and testing a program.  The main disadvantage of an interpreted program is speed of execution – especially in processor-intensive instructions.  An interpreted program must translate instructions each time a program is run.  This is not required of a compiled program.

The advent of compilation in Visual Basic 5 has dramatically sped up numeric calculations and most other computations.  The speed by which forms now load into memory in Visual Basic 5 is one of the language’s more dramatic speed improvements.  But compilation alone does not guarantee speed.  Design of a program is one of the more important determinants of performance.  Visual Basic programs, whether they are interpreted or compiled, rely upon other runtime libraries of functions in order to execute.  These libraries are probably the largest factor in Visual Basic performance.

Share:

Low-Visual and High-Visual Languages

Computer languages can be described as having a low-visual or a high-visual orientation.  Prior to 1990, most languages were low-visual languages, so programmers had considerable difficulty designing the computer forms and reports, data entry screens, and navigation tools by which to move from one area of a computer program to another.  High-visual languages greatly simplify the tasks of designing forms, screens, and navigation tools.  For this and other reasons, Visual Basic is known as a rapid prototyping language.  Its design tools let you quickly design a version or prototype of a computer application.

Low-Visual Languages

Let’s consider how a low-visual language differs from a high-visual language.  Low-visual languages are not supported by a GUI.  Instead, the programmer usually works with a blank terminal screen, adding line after line of instruction to that screen.  After the instructions are entered, the programmer issues a Run or Execute command to execute the instructions.  Only at this time do visual images appear on the screen.  Those of you who use common DOS-level commands, such as Copy, Del or CD use a low-visual language. 

High-Visual Languages

High-visual languages are supported by a GUI design environment.  The appearance of the design environment is conceived to improve speed in program design and can even be customized to suit your needs.  At the top of the screen is a menu bar, which contains the File, Edit, View, Project, Format, Debug Run, Tools, Add-Ins, Window and Help menus.  Below the menu bar is a toolbar.

The buttons appearing on the toolbar allow quick access to the most commonly used commands.  As you work through the exercises you will become familiar with the use of each tool in the toolbox.  Finally, the Visual Basic startup screen often contains a Form Window, a Project (Explorer) Window and a Properties Window.  “Writing and Running Your First Visual Basic Program,” asks you to use each in constructing a Visual Basic Program.

Pause and Breathe for a Moment!

Looking at the toolbar and toolbox the first time might fill your heart with fear.  You might exclaim, I can’t remember what all those icons mean!  With Visual Basic, help is readily on hand.  To quickly identify a control, just let your mouse pointer linger over an item in the toolbox.  A ToolTip appears by your pointer and identifies the control.  The same applies for buttons on the toolbar.  You can also click the button you want to inspect and press the Help key: the F1 function key on the keyboard.  The Visual Basic Help screen appears with a description of the button.

Share:

Procedure-Oriented and Event-Oriented Languages

Besides low-level and high-level languages, computer languages can be classified as procedure-oriented or event-oriented.  Procedure-oriented languages tend to run without human interference or the taking of some action by the user: A computer program is executed by a simple run instruction, and usually runs from top to bottom, with all the code executed until the program ends.  Event-oriented languages are different in that they depend on the user: They wait for the user to take some action before they execute.  The program waits for an event (or happening) to occur before beginning a program execution.

Procedure-Oriented Languages

Prior to 1990, most commercial high-level languages were procedure-oriented languages.  The emphasis in writing a computer program was to identify a set of processing tasks and to describe the steps important to each task.  Collectively, the set of tasks represented a procedure: a listing of a set of tasks required to perform an activity.  As an example, consider the procedure required in processing an employee paycheck, in which the steps of the procedure are expressed as tasks:

  1. Get employee name.
  2. Get hours worked.
  3. Get hourly wage.
  4. Multiply hours worked by the hourly wage to compute gross pay.
  5. Compute taxes based on gross pay.
  6. Subtract taxes and other deduction (such as union dues) from gross pay to compute net pay.
  7. Print the employee’s check.

This procedure could be used in writing a QBasic program. The following code listing shows a partial QBasic program written to print an employee’s check.  Even though you may not know the QBasic language, you should be able to understand, step by step, how the computer processes an employee paycheck.

'Compute and print a payroll check
'Initialize variables
emp.name$ = "Roger Rabbit"
pay.date$ = "06/12/99"
hours.worked = 40              
'Total hours worked
rate = 7.50                    
'pay per hour
tax.rate = 0.25                
'Tax percentage
'Compute gross and net pay
gross.pay = hours.worked * rate
taxes = gross.pay * tax.rate
net.pay = gross.pay - taxes
'Display the results
PRINT TAB(40); "Date: "; pay.date$
PRINT
PRINT "Pay to the order of: "; emp.name$
PRINT
PRINT "Pay the full amount of: "; gross.pay
PRINT TAB(28); "---"
PRINT
PRINT TAB(40); "------------------"
PRINT TAB(40); "W. Pinchpenney, treasurer"

Event-Oriented Languages

Event-oriented languages became possible with the advent of the Macintosh operating system for Apple Macintosh computers and Microsoft Windows for MS-DOS computer systems.  Both environments were designed to bring hardware and software together into a standard user interface by employing a graphical user interface, or GUI (pronounced goo-ey).  A GUI simplifies learning:  Once you learn how to work with one application using the interface, it is easy to learn another application because the interface remains the same.

An event-oriented language implies that an application (the computer program) waits for an event to occur before taking any action.  What is an event?  It might be the press of a key on the keyboard or the click of a mouse button.  With these events (these are many types), the computer waits for a key press or a mouse click (pushing a button on a hand-held mouse).

Share:

Learning How VB Differs from other Languages

Of the 1,000 or so computer languages that have been developed, each language can be categorized based upon the following criteria:

  • Low-level or High-level
  • Procedure-oriented or Event-oriented
  • High-visual or Low-visual
  • Interpreted or compiled

Imagine 1,000 or so languages!  Where does Visual Basic fit?  This section helps to explain not only where Visual Basic fits, but why it is different from many other programming languages.

Low-level and High-level Languages

A computer language can be described as a low-level or high-level language based on how close the language is to machine language (which depicts a low-level language) or to English (which depicts a high-level language).  Let’s look at what we mean by this difference in language.

Low-Level Language

Low-level languages are machine oriented.  These languages work close to machine language, which is limited to 0s and 1s.  Why only 0s and 1s?  This is the language the computer understands or it works by turning electronic circuits Off (0)  and circuits On (1).  By making a language closer to 0s and 1s, the speed at which the computer processes data improves.

An example of a low-level language is assembly language code.  With this language, such instructions as the following tell the computer to save, move, add and store the results of processing:


PUSH BX
PUSH AX
MOV AX, @A
MOVE BX, @B
ADD BX, AX
MOV @B, BX
POP BX
POP AX

Assembly language code uses mnemonics (memory aids), for which such words as ADD and POP make it easier to remember what an assembly instruction does.  While not quite 0s and 1s, you deal with the exact steps the computer must take in processing data when programming in assembly language.

Low-level languages are said to have one-to-one relationship with the computer.  A programmer must write an explicit instruction for every operation of the machine.  A low-level language is precise.  Programmers use low-level language code for such tasks as writing operating systems (the software that enables your computer to operate).

High-Level Language

High-level language are more people-oriented.  These languages have a one-to-many relationship, in which one instruction leads to a series of machine-level instructions.  These languages feature more English and English-like words.  In Visual Basic, examples of these English-like words are If, Else, Dim (for dimension), and OpenDatabase.

Because of this one-to-many relationship, high-level languages are easier to learn, use and understand.  However, they do require more machine time to translate a single instruction into a set of machine-level instructions.

Programmers (those who write computer programs) use high-level languages in writing application programs.  For example, a high-level language, such as Visual Basic, would be used to write the instructions for processing a company payroll.  Application programs define the ways by which users are able to use the computer.

Share:

Running a Visual Basic Program

Welcome to the world of Visual Basic.  Released by Microsoft in 1991, Visual Basic was designed to be a visually oriented programming language in contrast to the popular languages of that time (Pascal, C, COBOL, and FORTRAN).  Although Visual Basic is similar to QBasic – the procedural languages supplied with every version of MS-DOS beginning with version 5.0 – it contains important extensions that make it more of an object-oriented  language.

The newest version of Visual Basic is more object-oriented than ever.  It is capable of handling software development projects of enormous scope and depth.  Visual Basic is now one of the most flexible and powerful visual object-oriented computer language available, and it remains the most popular language for the world’s most popular operating system.

One way of describing Visual Basic's nature is to say that when the computer programmer develops programs in Visual Basic, data is more often than not approached as an object rather than just numeric or text information.  Data Objects, like real-world objects, such as desks and chairs, have properties.  Desks and chairs could be said to have a “Leg Count” property, which describes the number of legs for that object, whether it is a three-legged stool or a four legged desk.  Similarly, a data object that held information about a store’s customers might have a CustomerCount Property.  Unlike the "LegCoung" physical property of a real-world chair, you can easily change the  CustomerCount property of a data object.

Share:

Introduction

Visual Basic is the most popular programming language for the world’s most popular operating system.  By encapsulating the complexities of the windows application program interface (API) into easily manipulated objects, Visual Basic is the first language people consider when they want rapid application development for the Windows environment.  The capability of custom controls to easily extend the language has made Visual Basic a popular choice for an amazingly wide variety of programming tasks.

However, the easy accessibility of the language and its enormous breadth pose challenges to both the students and the instructor.  Students approach the language from a wide variety of backgrounds and abilities: Some are new to programming; some have extensive programming experience in other languages (often character-based procedural languages); some want to learn the language to accomplish a very specific task.

Frequently, instructions are challenged by the variety of students who come together in a course.  A senior engineer from an aerospace company sits right next to a programming neophyte.  Some students are comfortable working with a visual programming environment, while others find the design paradigm quite difficult.  Consequently, teaching materials must be flexible enough to accommodate a broad range of backgrounds.

Next: Running a Visual Basic Program

Share:

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