Introduction To Visual Basics (Week One)
Introduction To Visual Basics (Week One)
VISUAL BASICS
LECTURE NOTE
BY
MR. ANTHONY ANDREW
PROGRAMS AND PROGRAMMING
LANGUAGE
A program is a set of instructions a computer
follows in order to perform a task.
A programming language is a special language
used to write computer programs.
An algorithm is a set of well-defined steps for
performing a task or solving a problem
For example, suppose we want the computer to calculate
someone’s gross pay—a Wage Calculator application. The
following shows what the computer should do:
1. Display a message on the screen: How many hours did
you work?
2. Allow the user to enter the number of hours worked.
3. Once the user enters a number, store it in memory.
4. Display a message on the screen: How much do you get
paid per hour?
5. Allow the user to enter an hourly pay rate.
6. Once the user enters a number, store it in memory.
7. Once both the number of hours worked and the hourly
pay rate are entered, multiply the two numbers and store the
result in memory as the gross pay.
8. Display a message on the screen that shows the gross
pay. The message must include the result of the calculation
performed in Step 7.
The table 1.1 below shows some common programming languages
COMMON COMPOSITION OF A PROGRAM
All programming languages, including Visual Basic, have certain elements
in common. Let’s look at the major programming language elements that
you will work with when writing a program.
1. KEYWORDS (RESERVED WORDS)
Each high-level language has its own set of words that the programmer must
learn in order to use the language. The words that make up a high-level
programming language are known as keywords or reserved words. Each
keyword has a specific meaning and cannot be used for any other purpose.
2. OPERATORS
3. VARIABLES
In addition to keywords and operators, each language also has its own syntax, which is a set of
rules that must be strictly followed when writing a program. The syntax rules dictate how
keywords, operators, and various punctuation characters must be used in a program. When you
are learning a programming language, you must learn the syntax rules for that particular
language.
5. STATEMENTS
The individual instructions that you write in a program are called statements. A
programming statement can consist of keywords, operators, punctuation, and other
allowable programming elements, arranged in the proper sequence to perform an
operation. The statements that are written in a program are commonly called source
code, or simply code.
6. PROCEDURES
A procedure is a set of programming statements that exist within a program for the purpose of
performing a specific task. The program executes the procedure when the task needs to be
performed.
7. COMMENTS(OR REMARKS)
Not everything that the programmer writes in a program is meant to be executed by the
computer. Some parts of a program are comments, or remarks, that help the human reader of
a program understand the purposes of the program statements. In Visual Basic, any statement
that begins with an apostrophe (’) is considered a comment. When the Visual Basic compiler
sees a statement that begins with an apostrophe, it recognizes it as a comment and it skips
over it. You should always add descriptive comments to your code.
THE PROGRAMMING PROCESS
The programming process consists of several steps, which include designing,
creating, testing, and debugging activities.
8. Start Visual Studio and create the forms and other controls identified in
Step 3.
9. Use the flowcharts or pseudocode from Step 6 to write the actual code.
10. Attempt to run the application. Correct any syntax errors found and repeat
11. Once all syntax errors are corrected, run the program with test data for input.
Correct any runtime errors. Repeat this step as many times as necessary.
THE VISUAL STUDIO INTEGRATED
DEVELOPMENT ENVIRONMENT (IDE)
The Visual Studio IDE is the environment where you have tools that
allow you to build desktop applications using Visual basic. To build
good applications, you need to familiarize yourself with the
environment.
If you do not see one or more of them, you can follow these steps to make
them visible:
If you do not see the Designer window, click VIEW on the menu bar. On the
VIEW menu, click Designer. You can also press Shift+F7 on the keyboard.
(You can also double-click the Form’s filename inside the Solution Explorer
window.)
If you do not see the Solution Explorer window, click VIEW on
the menu bar. On the VIEW menu, click Solution Explorer. You
can also press Ctrl+Alt+L on the keyboard.
When Auto Hide is turned on, the window is displayed only as a tab along
one of the edges of the Visual Studio window. This feature gives you more
room to view your application’s forms and code. Figure 1-24 shows how the
Solution Explorer and Properties windows appear when their Auto Hide
feature is turned on. Notice the tabs that read Solution Explorer and
Properties along the right edge of the screen.
THE MENU BAR
This is the bar at the top of the Visual Studio window that
provides menus such as FILE, EDIT, VIEW, PROJECT,
GIT, BUILD, DEBUG,FORMAT and so forth. As you
progress in this course and during personal practice, you
will become familiar with many of the menus.
THE TOOLBAR
Below the menu bar is the standard toolbar. The standard toolbar
contains buttons that execute frequently used commands. All commands
that are displayed on the toolbar may also be executed from a menu, but
the standard toolbar gives you quicker access to them.
THE TOOLBOX
The Toolbox is a window that allows you to select the controls that you want to
use in an application’s user interface. When you want to place a Button, Label,
TextBox, or other control on an application’s form, you select it in the Toolbox.
The Toolbox is divided into sections, and each section has a name. In the next
slide you can see the All Windows Forms and Common Controls sections. If
you scroll the Toolbox, you will see many other sections. Each of the sections
can be opened or closed. If you want to open a section of the Toolbox, you
simply click on its name tab. To close the section, click on its name tab again.
USING TOOLTIPS
A ToolTip is a small rectangular box that pops up when you
hover the mouse pointer over a button on the toolbar or in the
Toolbox for a few seconds. The ToolTip box contains a short
description of the button’s purpose. The picture shows the
ToolTip that appears when the cursor is left sitting on the Save
All button. Use a ToolTip whenever you cannot remember a
particular button’s function.
DOCKED AND FLOATING WINDOWS
Up to this point, all the previous figures shows the Toolbox, Solution Explorer,
and Properties windows when they are docked, which means they are attached
to one of the edges of the Visual Studio window. Alternatively, the windows can
be floating. You can control whether a window is docked or floating as follows: