0% found this document useful (0 votes)
40 views42 pages

Introduction To Visual Basics (Week One)

Uploaded by

proflatibedrew6
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
40 views42 pages

Introduction To Visual Basics (Week One)

Uploaded by

proflatibedrew6
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 42

INTRODUCTION TO

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

In addition to keywords, programming languages have operators that perform various


operations on data. For example, all programming languages have math operators that
perform arithmetic. In Visual Basic, as well as most other languages, the + sign is an
operator that adds two numbers. The following would add 12 and 75: 12 + 75.

3. VARIABLES

A variable is a storage location in memory that is represented by a name. When a value is


stored in a variable, it is stored in the computer’s memory. Programs use variables to
store data in memory. For example, a program that calculates the sales tax on a
purchase might use a variable named tax to hold that value in memory
4. SYNTAX

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.

Steps for Developing a Visual Basic Application


1. Clearly define what the application is to do.
2. Visualize the application running on the computer and design its user
interface.
3. Determine the controls needed.
4. Define the values of each control’s relevant properties.
5. Determine the event handlers and other code needed for each control.
6. Create a flowchart or pseudocode version of the code.
7. Check the flowchart or pseudocode for errors.

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

this step as many times as necessary.

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.

In this section, we look at the important tools that is used commonly


and regularly to build visual basic desktop applications.
STARTING A NEW PROJECT
Each Visual Basic application that you create is called a
project.

To create a Visual Basic 2022 project, launch Microsoft


Visual Studio 2022 to bring up the Visual Studio 2022
Start Page, as shown in figure 1.5 in the next slide.
As cab be seen from figure 1.5,the Visual Studio 2022 start page
comprises four options: clone a repository, open a project or solution,
open a local folder or create a new project.

Let us create a new project by clicking the Create a new project


option. You will see the Create a new project template page, as
shown in Figure 1.6 in the next slide.

There are a dozen templates to choose from, scroll down to select


WPF application, as shown in Figure1.6 in the next slide.
After selecting the template and clicking the
Next button, the project configuration page
appears, as shown in Figure 1.7 in the next
slide. You can configure your project by typing
the project name and selecting a few other
options.
After renaming the project, click OK to continue. The Visual
Basic 2022 IDE Windows will appear, as shown in Figure 1.8
in the next page. Visual Basic 2022 IDE comprises a few
windows: the Form window, the Solution Explorer window,
and the Properties window. It also consists of a toolbox
which contains many useful controls that allows the
programmer to develop his or her Visual Basic 2022
programs.
THE DESIGNER WINDOW( OR FORM WINDOW)

You use the Designer window to create an application’s


graphical user interface. The Designer window shows the
application’s form, and it allows you to visually design its
appearance by placing the desired controls that will
appear on the form when the application executes.
THE SOLUTION EXPLORER WINDOW

A solution is a container for holding Visual Basic


projects. When you create a new VB project, a new
solution is automatically created to contain it. The
Solution Explorer window allows you to navigate among
the files in a Visual Basic project.
THE PROPERTIES WINDOW

When you are creating a Visual Basic application,


you use the Properties window to examine and
change a control’s properties.

The following slide shows these three windows.


Visual Studio is a customizable environment. You can move these windows
around, so they may not appear in the exact locations shown in the previous
slide. You can also close the windows so they do not appear at all.

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.

 If you do not see the Properties window, click VIEW on the


menu bar. On the VIEW menu, click Properties Window. You
can also press F4 on the keyboard
AUTO HIDE
Many windows in Visual Studio have a feature known as Auto Hide. When
you see the pushpin icon in a window’s title bar, as shown in Figure on the
next slide, you know that the window has Auto Hide capability.

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:

• To change a window from docked to floating, right-click its title bar

and select Float.

• To change a window from floating to docked, right-click its title bar

and select Dock.


The next slide shows Visual Studio with the Toolbox,
Solution Explorer, and Properties windows floating.
When a window is floating, you can click and drag it by
its title bar around the screen. You may use whichever
style you prefer—docked or floating.
NOTE

Remember, you can always reset the window layout


by clicking Window on the menu bar, and then
selecting Reset Window Layout. If you accidentally
close the Designer window, the Solution Explorer
window, or the Properties window, you can use the
VIEW menu to redisplay them.
QUESTIONS
1. Briefly describe the purpose of the Solution Explorer window.
2. Briefly describe the purpose of the Properties window.
3. Briefly describe the purpose of the standard toolbar.
4. What is the difference between the toolbar and the Toolbox?
5. What is a ToolTip?
6. What is Auto Hide? How do you turn Auto Hide on or off?
7. What is the Toolbox window in Visual Studio?
8. What is the standard toolbar in Visual Studio?
9. What is a ToolTip?
10. If you do not see the Solution Explorer window in Visual Studio, how do
you display it?
THE END

You might also like