(Week 4) Lecture Note

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 31

www.covenantuniversity.edu.

ng

Visual Basic.NET Fundamentals

Lecture Note (Week Four)

1
Learning Objectives
 To introduce the Visual Studio.NET Integrated
Development Environment (IDE)
 To introduce the Visual Basic programming
language

2
Introduction
 Visual Basic .NET evolved from BASIC
(Beginner’s All-Purpose Symbolic Instruction
Code) which was developed in the mid-1960s by
Professors John Kemeny and Thomas Kurtz of
Dartmouth College as a language for writing
simple programs.

3
Introduction
 BASIC’s primary purpose was to familiarize novices with
programming techniques.
 When Bill Gates founded Microsoft Corporation, he
implemented BASIC on several early personal computers.
 With the development of the Microsoft Windows graphical
user interface (GUI) in the late 1980s and the early 1990s, the
natural evolution of BASIC was Visual Basic, introduced by
Microsoft in 1991.
4
Introduction
 Until Visual Basic appeared in 1991, developing Microsoft Windows-based
applications was a difficult and cumbersome process.
 Although Visual Basic is derived from the BASIC programming language,
it is a distinctly different language that offers such powerful features as:
– graphical user interfaces,
– event handling,
– access to the Windows 32-bit Application Programming Interface (Win32
API),
– object-oriented programming and exception handling.

5
Introduction
 Visual Basic .NET is an event-driven, visual programming language in which
programs are created using an Integrated Development Environment (IDE).
 With the IDE, a programmer can write, run, test and debug Visual Basic
programs conveniently, thereby reducing the time it takes to produce a
working program to a fraction of the time it would have taken without using
the IDE.
 The process of rapidly creating an application is typically referred to as
Rapid Application Development (RAD).
– Visual Basic is the world’s most widely used RAD language.

6
The Visual Studio .NET IDE
 Visual Studio .NET is Microsoft’s Integrated
Development Environment (IDE) for creating, running
and debugging programs (also called applications)
written in a variety of .NET programming languages.
 This IDE is a powerful and sophisticated tool for
creating business-critical and mission-critical
applications.

7
The Visual Studio .NET IDE
 When Visual Studio .NET begins execution, the
Start Page1 displays (Fig. 1).
 The left-hand side of the Start Page contains a list
of helpful links, such as Get Started.
 Clicking a link displays its contents.

8
Menu Bar

Click to start
a new project

Fig. 1: Start Page in Visual Studio .NET 9


The Visual Studio .NET IDE
 To create a new Visual Basic program, click the New Project
button (Fig. 1), which displays the New Project dialog (Fig. 2).
– Dialogs are windows that facilitate user-computer communication.
 The Visual Studio .NET IDE organizes programs into projects and
solutions, which contain one or more projects.
 After selecting a project’s type, click OK to display the IDE in
design view (Fig. 3), which contains all the features necessary to
begin creating programs.
10
Select and click OK
to open new project

Fig. 2: New Project Dialog


11
The Visual Studio .NET IDE
 The Visual Studio .NET IDE provides project types for a variety of
programming languages.
– Our focus in this course is on Visual Basic, so we select the Visual Basic
Projects folder from the Project Types window (Fig. 2).
 A Windows Application is a program that executes inside the
Windows OS (e.g., Windows 2000 or Windows XP).
 Windows applications include customized software that programmers
create, as well as software products like Microsoft Word, Internet
Explorer and Visual Studio .NET.
12
The Visual Studio .NET IDE
 By default, the Visual Studio .NET IDE assigns the name
WindowsApplication1 to the new project and solution (Fig.
3).
 The Visual Studio Projects folder in the My Documents folder
is the default folder referenced when Visual Studio .NET is
executed for the first time.
 Programmers can change both the name of the project and the
location where it is created.
13
Fig. 3: Design view of Visual Studio .NET IDE
14
The Visual Studio .NET IDE
 The gray rectangle (called a Form) titled Form1 represents the
Windows application that the programmer is creating.
 Collectively, the form and controls constitute the program’s
Graphical User Interface (GUI), which is the visual part of the
program with which the user interacts.
 Users enter data (inputs) into the program by typing at the
keyboard, by clicking the mouse buttons and in a variety of
other ways.
15
The Visual Studio .NET IDE
 Programs display instructions and other
information (outputs) for users to read in the GUI.
– For example, the New Project dialog in Fig. 2 presents
a GUI where the user clicks with the mouse button to
select a project type and then inputs a project name and
location from the keyboard.

16
The Visual Studio .NET IDE
 The name of each open document is listed on a tab. In our
case, the documents are the Start Page and Form1.vb [Design]
(Fig. 3).
 To view a document, click its tab.
– Tabs save space and facilitate easy access to multiple documents.
 The active tab (the tab of the document currently displayed in
the IDE) is displayed in bold text (e.g., Form1.vb [Design])
and is positioned in front of all the other tabs.
17
Menu Bar and Toolbar
 Commands for managing the IDE and for developing, maintaining and
executing programs are contained in the menus, which are located on
the menu bar (Fig. 4).
 Menus contain groups of related commands (also called menu items)
that, when selected, cause the IDE to perform specific actions (e.g.,
open a window, save a file, print a file and execute a program).
– For example, new projects are created by selecting File > New > Project....
 The menus depicted in Fig. 4 are summarized in Fig. 5.

18
Fig. 4: Visual Studio .NET IDE menu bar

19
Fig. 5: Summary of Visual Studio .NET IDE menus
20
Menu Bar and Toolbar
 Rather than having to navigate the menus for certain
commonly used commands, the programmer can access
them from the Toolbars (Fig. 6), which contains pictures,
called icons, that graphically represent commands.
 To execute a command via the toolbar, click its icon.
Some icons contain a down arrow that, when clicked,
displays additional commands.

21
Fig. 6: IDE Toolbar

22
Menu Bar and Toolbar
 Positioning the mouse pointer over an icon
highlights the icon and, after a few seconds,
displays a description called a tool tip (Fig. 7).
– Tool tips help novice programmers become familiar
with the IDE’s features.

23
Fig. 7: Tooltip Demonstration

24
Solution Explorer
 The Solution Explorer window provides access to all the files in the solution.
 When the Visual Studio .NET IDE is first loaded, the Solution Explorer is
empty.
 Once a solution is open, the Solution Explorer displays that solution’s
contents.
 The solution’s startup project is the project that runs when the program
executes and appears in bold text in the Solution Explorer.
 For our single-project solution, the startup project is the only project
(WindowsApplication1).

25
Solution Explorer
 The Visual Basic file, which corresponds to the form shown in
Fig. 3, is named Form1.vb. (Visual Basic files use the “.vb”
filename extension, which is short for “Visual Basic.”)
 The Solution Explorer window includes a toolbar that contains
several icons. When clicked, the show all files icon displays all
the files in the solution. The number of icons present in the
toolbar is dependent on the type of file selected.

26
Toolbox
 The Toolbox (Fig. 8) contains controls used to customize forms.
 Using visual programming, programmers can “drag and drop” controls onto
the form instead of building them by writing code.
– Just as people do not need to know how to build an engine to drive a car, programmers
do not need to know how to build a control to use the control.
 The use of pre-existing controls enables developers to concentrate on the “big
picture,” rather than on the minute and complex details of every control.
 The wide variety of controls that are contained in the Toolbox is a powerful
feature of the Visual Studio .NET IDE.

27
Fig. 8: Toolbox window

28
Properties Window
 The Properties window (Fig. 9) displays the properties for a
form or control. Properties specify information such as size,
color and position.
 Each form or control has its own set of properties; a property’s
description is displayed at the bottom of the Properties window
whenever that property is selected.
 If the Properties window is not visible, selecting View >
Properties Window, displays the Properties window.
29
Fig. 9: Properties window
30
Let’s write a simple program
 To add two numbers

31

You might also like