0% found this document useful (0 votes)
46 views

Lesson 1 - Introduction To Visual

This document introduces Visual Basic .NET (VB.NET) and its key elements. It discusses how VB.NET applications have both a visual and language element. The visual element involves placing objects like labels, textboxes and buttons on a form. The language element involves writing code to handle events from these objects. It provides an overview of common visual objects and their uses. The document aims to explain the basics of creating VB.NET applications using both the visual design windows and programming instructions.

Uploaded by

Erica Maduro
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Lesson 1 - Introduction To Visual

This document introduces Visual Basic .NET (VB.NET) and its key elements. It discusses how VB.NET applications have both a visual and language element. The visual element involves placing objects like labels, textboxes and buttons on a form. The language element involves writing code to handle events from these objects. It provides an overview of common visual objects and their uses. The document aims to explain the basics of creating VB.NET applications using both the visual design windows and programming instructions.

Uploaded by

Erica Maduro
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

LESSON 1: INTRODUCTION TO

VISUAL BASIC .NET


In this chapter we begin learning about the fundamentals of programming and Visual
Basic .NET. First, we examine the two elements that are required by every practical Visual Basic
program: the screens and instructions seen by the user, and the “behind the scenes” processing
that is done by the program. We then present the basic design windows that you must be familiar
with to produce such programs. Finally, we show you how to use these design windows to create
the visual user interface, or GUI, and then add processing instructions.
Elements of a Visual Graphic Application
Visual Basic was initially introduced in 1991 as the first programming language that directly
supported programmable graphical user interfaces using language-supplied objects. From that
time until 2002, there were five other versions released, each version having features that
increased the power of the language. In 2001, Microsoft released the .NET (pronounced “dot
net”) platform. Visual Basic .NET, or VB.NET, is an upgrade to the last version of VB (version 6.0)
that conforms to the .NET platform. As you will see in subsequent chapters, the changes in
VB.NET allow programmers to write Web or desk-top applications within the same language. In
addition, VB.NET is fully object-oriented as opposed to prior versions that had many, but not all,
of the elements of an object-oriented language. This book is based on VB.NET. In the balance of
the book we will sometimes refer to Visual Basic as VB, omitting .NET.
From a programming viewpoint, Visual Basic is an object-oriented language that consists
of two fundamental parts: a visual part and a language part. The visual part of the language
consists of a set of objects, while the language part consists of a high-level procedural
programming language. These two elements of the language are used together to create
applications. An application is simply a Visual Basic program that can be run under the Windows
operating system. The term application is preferred to the term program for two reasons: one, it
is the term selected by Microsoft to designate any program that can be run under its Windows
Operating System (all versions) and two, it is used to avoid confusion with older procedural
programs that consisted entirely of only a language element. Thus, for our purposes we can
express the elements of a Visual Basic application as:

Visual Basic Application = Object-Based Visual Part +


Procedural-Based Language Part

Thus, learning to create Visual Basic applications requires being very familiar with both
elements, visual and language.
The Visual Element
From a user’s standpoint, the visual part of an application is provided within a window. This is
the graphical interface that allows the user to see the input and output provided by the
application. This user interface is referred to as the graphical user interface (GUI). From a
programmer’s perspective the GUI is constructed by placing a set of visual objects on a blank
window, or form, when the program is being developed. For example, consider Figure 1–1, which
shows how a particular application would look to the user. From a programmer’s viewpoint, the
application shown in Figure 1–1 is based on the design form shown in Figure 1–2. The points
displayed on the form are a design grid used to arrange objects on the form and are only
displayed during design time.

Figure 1–1 A User’s View of an Application

Figure 1–2 The Design Form on which Figure 1–1 is Based


The programmer can place various objects on this form, which is itself a Visual Basic object.
When an application is run, the form becomes a window that provides the background for the various
objects placed on the form by the programmer. The objects on the window become the controls used to
direct program events. Let us take a moment to look at the objects provided in the Visual Basic Toolbox.
The standard object Toolbox, which is illustrated in Figure 1–3, contains the objects we will use in
constructing each graphical user interface.
Figure 1–3 The Standard Visual Basic Toolbox
Programmer Notes
Forms and Controls
When an application is being designed, a form is a container upon which controls are placed.
When an application is executed, the form becomes either a window or a dialog box. Forms can
be of two types: SDI or MDI. The acronym SDI stands for Single Document Interface, which means
that only one window at a time can be displayed by an application. SDI applications can have
multiple windows, but a user can only view one window at a time. The acronym MDI refers to
Multiple Document Interface, which means the application consists of a single “parent” or main
window that can contain multiple “child” or internal windows. For example, the Notepad
application supplied with the Windows operating system is an SDI application, while Excel and
Access are both MDI applications.
A control is an object that can be placed on a form, and has its own set of recognized properties,
methods, and events. Controls are used to receive user input, display output, and trigger event
procedures.
A majority of applications can be constructed using a minimal set of objects provided by
the standard object Toolbox. This minimal set consists of the Label, TextBox, and Button objects.
The next set of objects that are more frequently found in applications include the CheckBox,
RadioButton, ListBox, and ComboBox. Finally, the Timer and PictureBox can be used for
constructing interesting moving images across the window. Table 2–1 lists these object types and
describes what each object is used for. The remaining sections of the text will describe the use of
objects in the toolbox, with special emphasis on the four objects (Label, TextBox, Button, and
ListBox) that you will use in almost every application that you develop.
In addition to the basic set of controls provided in VB, a great number of objects can be
purchased either for special purpose applications or to enhance standard applications.
Table 1-1 Fundamental Object Types and Their Uses

Don’t be overwhelmed by all of the available controls. At a minimum, you will always have
the objects provided by the standard Toolbox available to you, and these are the ones we will be
working with. Once you learn how to place the basic control objects on a form, you will also
understand how to place the additional objects, because every object used in a Visual Basic
application, whether it is selected from a standard or purchased control, is placed on a form in
the same simple manner. Similarly, each and every object contains two basic characteristics:
properties and methods.
An object’s properties define particular characteristics of the object. For example, the
properties of a text box include the location of the text box on the form, the color of the box (the
background color), the color of text that will be displayed in the box (the foreground color), and
whether it is read-only or can also be written to by the user.
Methods are predefined procedures that are supplied with the object for performing
specific tasks. For example, you can use a method to move an object to a different location or
change its size.
Additionally, each object from the Toolbox recognizes certain actions. For example, a
button recognizes when the mouse pointer is pointing to it and the left mouse button is clicked.
These types of actions are referred to as events. In our example, we would say that the button
recognizes the mouse-click event. However, once an event is activated, we must write our own
procedures to do something in response to the event. This is where the language element of
Visual Basic comes into play.
The Language Element
Before the advent of GUIs, computer programs consisted entirely of a sequence of
instructions. Programming was the process of writing these instructions in a language to which
the computer could respond. The set of instructions and rules that could be used to construct a
program were called a programming language. Frequently, the word code was used to designate
the instructions contained within a program. With the advent of graphical user interfaces, the
need for code (program instructions) has not gone away—rather, it forms the basis for
responding to the events taking place on the GUI. Figure 1–4 illustrates the interaction between
an event and a program code.
As illustrated in Figure 1–4, an event, such as clicking the mouse on a button, sets in
motion a sequence of actions. If code has been written for the event, the code is executed;
otherwise the event is ignored. This is the essence of GUIs and event-driven applications—the
selection of executed code depends on what events occur, which ultimately depends on what
the user does. The programmer must still write the code that performs the desired action.
Visual Basic is a high-level programming language that supports all of the procedural
programming features found in other modern languages. These include statements to perform
calculations, permit repetitive instruction execution, and allow selection between two or more
alternatives.

With these basics in mind, it is now time to create our first Visual Basic application. In the next
section, we introduce the Visual Basic programming environment and create an application that uses
only a single object: the form itself. We will then add additional objects and code to create a more
complete Visual Basic application.

You might also like