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

Visual Basic Programming: University of Gondar Faculty of Informatics Department of Information Science

This document provides an overview of Visual Basic programming and Visual Basic as a programming language. It discusses the history of Visual Basic, its features, the programming process, and the types of programs that can be developed in Visual Basic. Specifically, it notes that Visual Basic is an event-driven, object-oriented programming language that allows developing graphical user interface applications. It provides examples of programs like educational software that can be created.

Uploaded by

Aisha m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

Visual Basic Programming: University of Gondar Faculty of Informatics Department of Information Science

This document provides an overview of Visual Basic programming and Visual Basic as a programming language. It discusses the history of Visual Basic, its features, the programming process, and the types of programs that can be developed in Visual Basic. Specifically, it notes that Visual Basic is an event-driven, object-oriented programming language that allows developing graphical user interface applications. It provides examples of programs like educational software that can be created.

Uploaded by

Aisha m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

University of Gondar

Faculty of Informatics
Department of Information Science

Visual Basic Programming


INSC 2103

By: Melsew Belachew


N.B:- in this course there is eight chapters, but here in the handout there is only seven chapters. B/c
the eighth chapter is about Creating Packages and Deployment Wizards, so this is a steps included in the
laboratory portion.
Laboratory procedures and code programs are not included here.
Visual Basic Programming
INSC 2103
Chapter One:
Introduction To Visual Programming
Melsew B.
Department of Information Science
University of Gondar

7/13/22 By: Melsew Belachew 2


Discussion Outline
Introduction to Visual Programming and Visual Basic
History of Visual Basic
Features of Visual Basic
Steps In Programming
Programs Visual Basic Can Develop
Object-Oriented Programming Language
History of Windows Environment
• Command Line Interface
• Windows Programming Interface (GUI)
Design of User Interfaces
Windows-Based Programming Tools
Procedural Programming Language
VB Environment

7/13/22 By: Melsew Belachew 3


Introduction to Visual Programming and Visual Basic

What is Visual basic?


Visual Basic is a programming language and
development environment created by Microsoft.
It provides a graphical user interface (GUI) that allows
the developer drag and drop objects into the program as
well as manually write program code.
Is designed to make software development easy and
efficient.
Visual programming language (VPL) is a programming
language that uses graphical elements and figures to
7/13/22
develop a program. By: Melsew Belachew 4
Cont’d …
“Visual” refers to the way the Graphical User Interface (GUI)
is designed.
“BASIC” stands for Beginners All-Purpose Symbolic
Instruction Code which refers to the coding section of the
software.

Program - detailed set of instructions for a computer to


execute certain task.

Programming is writing instructions for a computer.

The process of developing and implementing various sets

7/13/22
of instructions to enable By:
a Melsew
computer
Belachew
to do a certain task. 5
Cont’d …
• Visual Basic falls into a category of programming referred
to as Event-driven Programming.
• Event-driven programs respond to events from the
computer, such as the mouse button being pressed.
• This approach to programming drastically reduces the
amount of code required to develop a Windows
application.
• Visual Basic is event-driven, meaning code remains idle
until called upon to respond to some event (button
pressing, menu selection ...).
• Visual Basic is governed by an event processor.
• Visual Basic is a tool that allows you to develop
Windows (Graphic User Interface - GUI) applications.
The applications have a familiar appearance to the user.
7/13/22 By: Melsew Belachew 6
History of BASIC
Visual Basic 1.0
MS-BASIC 2.0
Visual Basic 6.0
Visual-BASIC 8.0
Visual Basic. Net
Visual-studio 10
Visual studio 12
 Visual studio 13
 Visual studio 15
 Visual studio 17
Visual studio 17, 15.9
7/13/22 Visual studio 19 By: Melsew Belachew 7
Cont’d …
 Visual Basic has gone through many phases of development
since the days of BASIC that was built for DOS.
 Visual Basic was initially a functional or procedural
programming language until the popular Visual Basic 6.
 Then, Microsoft transformed Visual Basic into a more powerful
object oriented programming language by launching Visual
Basic. Net, Visual Basic 2005, Visual Basic 2008 and the latest
Visual Basic 2010.
 VB 2010 is the latest version of Visual Basic launched by
Microsoft in 2010. It is almost similar to Visual Basic 2008 but it
has added many new features.
 Microsoft VB 2010 is an important upgrade and enhancement of
the popular Visual Basic programming language and compiler, a
technology that enjoys an installed base of millions of
programmers worldwide.
7/13/22 By: Melsew Belachew 8
Cont’d …
 Visual Basic 2010 is not a stand-alone product but a key
component of Microsoft Visual Studio 2010, a comprehensive
development system
 That allows you to create powerful applications for Windows,
the Web, handheld devices, and a host of other environments.
 Microsoft has added many new features particularly those
features for building mobile applications in visual basic 2015
which is a full-fledged Object-Oriented Programming(OOP)
Language implemented in the .NET Framework. 
 Visual Basic 2015 is bundled together with other Microsoft
Programming languages C++, C#, JavaScript, Python and more
in an IDE called Visual Studio Community 2015.
 Visual Basic 2015 is an event-driven programming language,
which means that the code is executed in response to events.
7/13/22 By: Melsew Belachew 9
Features of Visual Basic
 GuI Interface: - VB is a Graphical User Interface language. This means that
a VB program will always show something on the screen that the user can
interact with to get a job done.
 Modularization: - It is considered good programming practice to
modularize your programs. Small modules where it is clearly indicated
what comes into the module and what goes out makes a program easy to
understand.
 Object Oriented: - Object Oriented Programming is a concept where the
programmer thinks of the program in "objects" that interact with each
other. Visual Basic forces this good programming practice.
 Debugging: - Visual Basic offers two different options for code
debugging:- Debugging Managed Code & Runtime Debugger. The
Debugging Managed Code individually debugs C and C++ applications
and Visual Basic Windows applications. The Runtime Debugger helps to
find and fix bugs in programs at runtime.
 Data Access Feature: - By using data access features, we can create
databases, scalable server-side components for most databases, including
Microsoft SQL Server and other enterprise-level database.
 Macros IDE: - The Macros integrated development environment is similar
7/13/22
in design and function to the Visual Studio IDE. The Macros IDE includes a
By: Melsew Belachew 10
code editor, tool windows, the properties windows and editors
Cont’d …
Some Features of Visual Basic
⇒ Full set of objects - you 'draw' the application
⇒ Lots of icons and pictures for your use
⇒ Response to mouse and keyboard actions
⇒ Clipboard and printer access
⇒ Full array of mathematical, string handling and graphics
functions
⇒ can handle fixed and dynamic variable and control arrays
⇒ Sequential and random access file support
⇒ Useful debugger and error-handling facilities
⇒ Powerful database access tools
⇒ ActiveX support
⇒ Package & Deployment Wizard makes distributing your
7/13/22
applications Visual Basic simple
By: Melsew Belachew 11
Cont’d …
Steps in Programming
Problem Identification
Solution Design
Coding
Compiling with compiler or running with interpreter
Debugging
Testing

Question:? What is Interpreter & Compiler?


7/13/22 By: Melsew Belachew 12
What programs can you create with Visual Basic ?
With VB, you can create any program depending on your
objective. For example,
If you are a college or university lecturer,  you can create 
educational programs to teach business, economics,
engineering, computer science, accountancy , financial
management, information system and more to make
teaching more effective and interesting.
If you are in business, you can also create business
programs such as inventory management system , point-
of-sale system, payroll system, financial program as well
as accounting program to help manage your business and
increase productivity.
For those of you who like games and working as games
programmer, you can create those programs as well.
Indeed, there is no limit to what program you can create !
7/13/22 By: Melsew Belachew 13
Object-Oriented Programming Languages
• Visual Basic is an object-oriented programming language that
uses the Microsoft Windows platform.
• The programs that are created using Visual Basic will look and
act like standard Windows programs.
• Visual Basic provides one the tools to create windows with
elements such as menus, text boxes, command buttons, option
buttons, and list boxes and scroll bars.
• It is based on developing software programs using and
manipulating objects that often represent "real-world" objects.
• Object oriented technology is the foundation of programming
tools such as Visual Basic (VB). 
• VB depend on the implementation of windows, buttons, and
other objects as "objects" to define and build a user interface. 
• Object based programming is technically an "application" of
object oriented programming. 
7/13/22 By: Melsew Belachew 14
Cont’d...
• There are some basic features of Window-based Programming objects
that are important to understand:
 Properties (data/fields) - what they are
 Methods - what they can do
 Events - what can happen to them
Properties
• Objects are described with "properties" (data) which tell you what they
look like, where they go, how they will act, and what they contain.
• Properties often describe physical properties of the object (color or
size), but they can also describe behavior, and the data contained by
an object. Examples of properties include:
• Appearance___color
• Behavior__dragging,visibility
• Position___top,left.width,height
• Content___text,graphics
• Font__name,size,bold,italic
7/13/22 • Value__data stored by the object
By: Melsew Belachew 15
Cont’d...
Events
• The secret to how most windows-based programs lies
in behaviors called "events".
• Events are triggered when windows are "loaded,"
buttons are "clicked," or text boxes are "changed."
• These events drive the program.
• Objects can respond to stimuli or things that are done
to them.
• For example: Click, Double Click, Mouse Down, Over,
Up, drag change

7/13/22 By: Melsew Belachew 16


Cont’d...
Methods
• Objects usually have many things that they can do or
that can be done to them. These are predefined
procedures that often modify properties of the object
such as its location. For example:
• Move—change the location of an object
• Drag–allow it to be dragged with by the mouse
• Paint—display or redisplay the object
• Draw (Point, Line)—use the object to draw (e.g., use a
mouse) or draw with the object (e.g., a picture object)

7/13/22 By: Melsew Belachew 17


Introduction to Window Programming

• History of Windows Environment


• Command Line Interface
• Windows Programming Interface (GUI)
• Design of User Interfaces
• Windows-based Programming Tools
• Programming Windows

7/13/22 By: Melsew Belachew 18


History of Windows Environment
• Until the mid-1980s, computer interfaces were based on a
text-based delivery model often called a "Command Line
Interface" (CLI).

• Commands and data were read one line at a time use of


arcane commands such as "dir" for getting a list of files.

• A mechanism for interacting with a computer operating


system or software by typing commands to perform
specific tasks.

7/13/22 By: Melsew Belachew 19


Command Line Interface (CLI)
• A Command Line Interface allows the user to interact
directly with the computer system by typing commands
(instructions) into a screen which looks similar to the one
below:

7/13/22 By: Melsew Belachew 20


Cont’d ....
• Example in DOS you could type in:
• copy c:\item.txt   d:\
• That tells the machine to copy the file 'item.txt' that resides in
the root directory of drive C: into the root directory of drive
D:\
Advantages of CLI
Much faster than any other type of interface.
Needs much less memory (RAM) in order to use it than
other user interfaces.-
Not use as much CPU processing time as the others do.
A low resolution, cheaper monitor can be used with this
type of user interface.
A CLI does not require Windows to run.
7/13/22 By: Melsew Belachew 21
Disadvantages of CLI
 For someone who has never used a command line
interface it can be very confusing.

 Commands have to be typed in precisely, if there is a


spelling error the command will fail.

 If you miss-type an instruction, it is often necessary to


start all over again.

 There are a large number of commands which need to be


learned - in the case of Unix, it can be hundreds.
7/13/22 By: Melsew Belachew 22
Graphical User Interface (Windows
Programming Interface)
 A graphical user interface provides the user with a
familiar environment in which to work
 This environment contains command buttons, textboxes,
lists, menus, labels, so forth known as events, and a
program that responds to events is said to be event
driven.
 Visual Basic is very much so an interface-oriented
language
 almost all user interfaces in Visual Basic are constructed
using the WIMP, or "windows, icon, menu, pointer," GUI
style.
 A graphical user interface is the most common type of
7/13/22 user interface seen today
By: Melsew Belachew 23
Cont’d ....
 GUI is also known as a WIMP interface because it makes use
of:

 Windows - a rectangular area on the screen where the


commonly used applications run

 Icons - a picture or symbol which is used to represent a


software application or hardware device

 Menus - a list of options from which the user can choose what
they require

 Pointers - a symbol such as an arrow which moves around the


7/13/22 screen as you move your mouse.
By: Melsew Belachew 24
Graphical User Interface Components
 The basic common components in GUI are:
Text boxes
Frames
Command buttons
 Checkboxes
 Radio Buttons
 Popup Menus
 List Boxes

NB: we will see later, the basic characteristics of


common graphical user interface components. It
describes how to create and use each component, as
well as the types of events each component can
7/13/22 generate. By: Melsew Belachew 25
Advantages of GUI
 Extremely easy to use, especially for a beginner
 It is easy to explore and find your way around the
system using a GUI
 You do not have to learn complicated commands
 There are usually good help facilities provided with
GUIs
 You get the benefit of WYSIWYG(What You See Is What
You Get. )
 It can be user-friendly and speed up the user's work.
 It can be more attractive for non-technical people.

7/13/22 By: Melsew Belachew 26


Disadvantages of GUI
 It need much larger amount of hard disk space than
other interfaces
 It need more memory (RAM) to run than other interface
types
 It need more processing power
 It can be slow for experienced programmers to use, they
find CLI interfaces much faster to use.
 When it is not properly built, it can be very difficult to
work with.
 It might require the installation of additional software
 Depending on the programmer, it might require more
time to be implemented.

7/13/22 By: Melsew Belachew 27


Design of User Interfaces
 An interface is a set of commands or menus through
which a user communicates with a program.
 User interface is one of the most important parts of any
program because it determines how easily you can make
the program do what you want
 A powerful program with a poorly designed user
interface has little value.
 Three main types of user interfaces are:
1. Command language: the user must know the machine
and program-specific instructions or codes.
2. Menus: user chooses the commands from lists displayed
on the screen.
3. Graphical user interface (GUI): user gives commands
by selecting and clicking on icons displayed on the
7/13/22
screen. By: Melsew Belachew 28
A Good User Interface Should:
Be attractive and pleasing to the eye

Be easy to use

Ensure all screens are consistent

 Have all options clearly shown

 Have clear warning messages when someone makes


a mistake

Have online help and support


7/13/22 By: Melsew Belachew 29
Windows-based Programming Tools
 Microsoft Visual C++,
 Borland C++,
 native UNIX C
 C++ tools, and others,
 Java (various commercial vendors, for Windows,
Macintosh, and UNIX)
 Smalltalk
 Delphi
 PowerBuilder
 Visual Basic

7/13/22 By: Melsew Belachew 30


Visual Basic Programming Environment
The Visual Basic environment consists of the following main
windows.
The menu bar- Displays the commands you use to work with
Visual Basic. Including File, Edit, View, Window, Project,
Format, Debug, help, etc.
The toolbar- Provide quick access to commonly used
commands in the programming environment.
The form window- this window is where the GUI is designed
that will enable the user to interact with the application.
The code window- this window acts as a code editor for
adding, editing, or deleting code.
7/13/22 By: Melsew Belachew 31
Cont’d ....
Form layout window- The Form Layout window allows
you to position the forms in your application using a
small graphical representation of the screen.
Properties window- Lists the property settings for the
selected form or control. A property is a characteristic of
an object, such as size, caption, or color.
The project explorer window- displays the entire files
linked with an application.
 In VB, a program is referred to as a project.
 Every VB project consists of at least two separate files – a
project file (with extension .vbp), and one or more forms
(with extension .frm).
7/13/22 By: Melsew Belachew 32
Cont’d ....
 Some projects include other types of files, such as class module
(.cls), standard module (.bas) and ActiveX control (.ocx) files.
 Thus the development of a VB project involves keeping track
of several different files, and accessing these files individually
within the VB environment.
 To enter the VB environment, click the mouse on all programs
then Microsoft visual basic 2010 or VB icon which appears on
the windows desktop. This will result in the opening group of
windows as shown below.
 Workspace for a new project can be selected through
Standard.EXE then open or by selecting New Project from the
File menu.
 Existing projects can be opened by selecting either the
7/13/22
Existing tab or the recent tab or Open Project from File menu.
By: Melsew Belachew 33
Cont’d ....
• Default Environment Settings
• The full version of Visual Studio 2010 provides an option
to allow the programmer to select the default profile for
the IDE.
• The first time you open VisualStudio, you are presented
with the Choose Default Environment Settings
dialogbox,where you can chooseVisual Basic Development
Settings.
• Notice the instructions in the dialog box: you can make a
different selection later from theTools menu.
• Note: If you are using the Express version of Visual Basic,
you won’t see this dialog box.

7/13/22 By: Melsew Belachew 34


7/13/22 By: Melsew Belachew 35
Cont’d ....
• The New Project Dialog
• You will create your first Visual Basic projects by selecting
File / New Projecton the menu bar or clicking New Project
on the Start Page, either of which opens the New Project
dialog.
• In the New Project dialog, select Windows Forms
Application if you are using VB Express.
• In the Professional version, first select Visual Basic and
Windows in the Installed Templates pane and Windows
Application in the center pane.
• You also give the project a name inthis dialog box.

7/13/22 By: Melsew Belachew 36


Visual Basic Start-up Dialog Box is look like this.

7/13/22 By: Melsew Belachew 37


The Visual Basic Environment

7/13/22 By: Melsew Belachew 38


Cont’d ....
 Title Bar: The top line, it includes the project name and
icons to minimize, maximize and close the project.
 Menu Bar: The second line is called the Menu bar.
Selecting one of the choices (File, Edit, View, Project,
Format… Help) causes one of drop-down menus to
appear. The user can select required menu.
 Tool bar: The third line is called the Standard Tool bar.
The icons on this line duplicate several of the more
commonly used menu items. It acts as a short cut to
select the menu
 Project window: The Project Window displays a
hierarchical list of the files associated with a given
project.

7/13/22 By: Melsew Belachew 39


Cont’d ....
• Form design and project container windows: The Form
design window is where the user interface is actually
designed by placing the controls from Tool Box. Each
control can be moved, resized and its properties can be
assigned using Properties Window.
• Tool box: it contains commonly used controls. A control
can be selected and placed in the Form by double
clicking on the control or by clicking once on the control,
then clicking on the desired location within the form. The
associated code can be viewed or edited by double
clicking on the control
• Properties window: Each Object has its own unique list
of properties. It allows assigning or changing the
properties.

7/13/22 By: Melsew Belachew 40


Cont’d ....
 Code Editor Window: It displays the code associated
with the currently active form. The leftmost list box is the
Object list box, which lists the objects, the rightmost is the
Procedure list box, it allows selecting the event
procedure associated with a particular type of event (Ex.
click, drag and drop, key down, mouse down).
 Form layout window: This window specifies the screen
location of the forms within a project; the location can be
changed by dragging the form icon to the desired
position
 Immediate window: This window is very useful for
debugging a project. Whenever a variable or expression
is entered, the corresponding value will be shown
immediately
7/13/22 By: Melsew Belachew 41

You might also like