SlideShare a Scribd company logo
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page1
Pondicherry University Community College
Department of Computer Science
Course : BCA
Year : II
Semester : III
Subject : Programming with Visual Basic
Unit I Study Material
Prepared by
D.GAYA
Assistant Professor,
Department of Computer Science,
Pondicherry University Community College,
Lawspet, Puducherry-08.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page2
UNIT –I
Introduction to GUI - Visual Basic: Starting and Exiting Visual Basic – Project
Explorer – Working with Forms – Properties Window – Using the Toolbox – Toolbars –
Working with Projects – Programming Structure of Visual Basic applications – Event
and Event driven procedures.
Introduction to GUI
A GUI is a type of computer human interface on a computer. It solves the blank
screen problem that confronted early computer users. These early users sat down in front of a
computer and faced a blank screen, with only a prompt. The computer gave the user no
indication what the user was to do next. GUI are an attempt to solve this blank screen
problem.
The first commercially available GUI, called "PARC," was developed by Xerox. It
was used by the Xerox 8010 Information System, which was released in 1981. After Steve
Jobs saw the interface during a tour at Xerox, he had his team at Apple develop an operating
system with a similar design. Apple's GUI-based OS was included with the Macintosh, which
was released in 1984. Microsoft released their first GUI-based OS, Windows 1.0, in 1985.
For several decades, GUIs were controlled exclusively by a mouse and a keyboard.
While these types of input devices are sufficient for desktop computers, they do not work as
well for mobile devices, such as smartphones and tablets.
Therefore, mobile operating systems are designed to use a touchscreen interface.
Many mobile devices can now be controlled by spoken commands as well.
Introduction to Visual Basic
Visual Basic 6 programming let us understand some basic concepts of programming.
According to a computer program is an organized list of instructions that, when executed,
causes the computer to behave in a predetermined manner. Without programs, computers are
useless.
Therefore, programming means designing or creating a set of instructions to ask the
computer to carry out certain jobs which normally are very much faster than human beings
can do.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page3
A lot of people think that computer CPU is a very intelligent thing, which in actual
fact it is a dumb and in animate object that can do nothing without human assistance.
The microchips of a CPU can only understand two distinct electrical states, namely,
the on and off states, or 0 and 1 codes in the binary system. So, the CPU only understands
combinations of 0 and 1 codes, a language which we called machine language. Machine
language is extremely difficult to learn and it is not for us to master it easily.
Fortunately , we have many smart programmers who wrote interpreters and
compilers that can translate human language-like programs such as BASIC into machine
language so that the computer can carry out the instructions entered by the users.
Machine language is known as the primitive language while Interpreters and
compilers like Visual Basic are called high-level language. Some of the high level computer
languages beside Visual Basic are Fortran, Cobol, Java, C, C++, Turbo Pascal, and etc .
What is Visual Basic?
VISUAL BASIC is a high level programming language which evolved from the
earlier DOS version called BASIC. BASIC means Beginners' All-
purpose Symbolic Instruction Code.
It is a very easy programming language to learn. The code look a lot like English
Language. Different software companies produced different versions of BASIC, such as
Microsoft QBASIC, QUICKBASIC, GWBASIC ,IBM BASICA and so on.
However, people prefer to use Microsoft Visual Basic today, as it is a well-developed
programming language and supporting resources are available everywhere. Now, there are
many versions of VB exist in the market, the most popular one and still widely used by many
VB programmers is none other than Visual Basic 6.
We also have VB.net, VB2005, VB2008 and the latest VB2010. Both Vb2008 and
VB2010 are fully object oriented programming (OOP) language.
VISUAL BASIC is a VISUAL and events driven Programming Language. These are
the main divergence from the old BASIC. In BASIC, programming is done in a text-only
environment and the program is executed sequentially. In VB, programming is done in a
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page4
graphical environment. In the old BASIC, you have to write program code for each graphical
object you wish to display it on screen, including its position and its color.
However, In VB , you just need to drag and drop any graphical object anywhere on
the form, and you can change its color any time using the properties windows.
On the other hand, because the user may click on a certain object randomly, so each
object has to be programmed independently to be able to response to those actions (events).
Therefore, a VB Program is made up of many subprograms, each has its own program
code, and each can be executed independently and at the same time each can be linked
together in one way or another.
What programs can you create with Visual Basic 6?
 With VB 6, 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 ! There are many such
programs in this tutorial, so you must spend more time on the tutorial in order to learn
how to create those programs.
Starting and Exiting Visual Basic
After installing the vb6 compiler, the icon will appear on your desktop or in your
programs menu. Click on the icon to launch the VB6 compiler.
On start-up, Visual Basic 6.0 will display the following dialog box as shown in
Figure.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page5
You can choose to start a new project, open an existing project or select a list of
recently opened programs. A project is a collection of files that make up your application.
There are various types of applications that we could create, however, we shall
concentrate on creating Standard EXE programs (EXE means executable). Before you begin,
you must think of an application that preferably have commercial ,educational or recreational
value.
Next, click on the Standard EXE icon to go into the actual Visual Basic 6
programming environment.
When you start a new Visual Basic 6 Standard EXE project, you will be
presented with the Visual Basic 6 Integrated Development Environment (IDE).
The Visual Basic 6 Integrated Programming Environment is shown in Figure. It
consists of the toolbox, the form, the project explorer and the properties window.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page6
The Form is the primary building block of a Visual Basic 6 application. A Visual
Basic 6 application can actually comprise many forms, but we shall focus on developing an
application with one form first.
We will learn how to develop applications with multiple forms later. Before you
proceed to build the application, it is a good practice to save the project first.
You can save the project by selecting Save Project from the File menu, assign a name
to your project and save it in a certain folder.
The Integrated Development Environment (IDE)
One of the most significant changes in Visual Basic 6.0 is the Integrated Development
Environment (IDE). IDE is a term commonly used in the programming world to describe the
interface and environment that we use to create our applications.
It is called integrated because we can access virtually all of the development tools that
we need from one screen called an interface. The IDE is also commonly referred to as the
design environment, or the program.
The Visual Basic IDE is made up of a number of components
 Menu Bar
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page7
 Tool Bar
 Project Explorer
 Properties window
 Form Layout Window
 Toolbox
 Form Designer
 Object Browser
In previous versions of Visual Basic, the IDE was designed as a Single Document
Interface (SDI). In a Single Document Interface, each window is a free-floating window that
is contained within a main window and can move anywhere on the screen as long as Visual
Basic is the current application.
But, in Visual Basic 6.0, the IDE is in a Multiple Document Interface (MDI) format.
In this format, the windows associated with the project will stay within a single container
known as the parent. Code and form-based windows will stay within the main container form.
Menu Bar
This Menu Bar displays the commands that are required to build an application. The
main menu items have sub menu items that can be chosen when needed. The toolbars in the
menu bar provide quick access to the commonly used commands and a button in the toolbar
is clicked once to carry out the action represented by it.
Toolbox
The Toolbox contains a set of controls that are used to place on a Form at design time
thereby creating the user interface area. Additional controls can be included in the toolbox by
using the Components menu item on the Project menu. A Toolbox is represented in figure 2
shown below.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page8
Control Description
Pointer Provides a way to move and resize the controls form
PictureBox
Displays icons/bitmaps and metafiles. It displays text or acts as a
visual container for other controls.
TextBox Used to display message and enter text.
Frame Serves as a visual and functional container for controls
CommandButton Used to carry out the specified action when the user chooses it.
CheckBox Displays a True/False or Yes/No option.
OptionButton
OptionButton control which is a part of an option group allows
the user to select only one option even it displays mulitiple
choices.
ListBox Displays a list of items from which a user can select one.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page9
ComboBox
Contains a TextBox and a ListBox. This allows the user to select
an ietm from the dropdown ListBox, or to type in a selection in
the TextBox.
HScrollBar and
VScrollBar
These controls allow the user to select a value within the
specified range of values
Timer Executes the timer events at specified intervals of time
DriveListBox
Displays the valid disk drives and allows the user to select one of
them.
DirListBox
Allows the user to select the directories and paths, which are
displayed.
FileListBox
Displays a set of files from which a user can select the desired
one.
Shape Used to add shape (rectangle, square or circle) to a Form
Line Used to draw straight line to the Form
Image
used to display images such as icons, bitmaps and metafiles. But
less capability than the PictureBox
Data
Enables the use to connect to an existing database and display
information from it.
OLE
Used to link or embed an object, display and manipulate data
from other windows based applications.
Label Displays a text that the user cannot modify or interact with.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page10
Project Explorer
Docked on the right side of the screen, just under the tollbar, is the Project Explorer
window.
The Project
Explorer as shown
in in figure servers
as a quick
reference to the
various elements of
a project namely
form, classes and modules. All of the object that make up the application are packed in a
project.
A simple project will typically contain one form, which is a window that is designed
as part of a program's interface.
It is possible to develop any number of forms for use in a program, although a
program may consist of a single form.
In addition to forms, the Project Explorer window also lists code modules and
classes.
Properties Window
The Properties Window is docked under the Project
Explorer window. The Properties Window exposes the various
characteristics of selected objects.
Each and every form in an application is considered
an object. Now, each object in Visual Basic has characteristics
such as color and size.
Other characteristics affect not just the appearance of
the object but the way it behaves too. All these characteristics
of an object are called its properties.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page11
Thus, a form has properties and any controls placed on it will have properties too. All
of these properties are displayed in the Properties Window.
Object Browser
The Object Browser allows us to browse through the various properties, events and
methods that are made available to us. It is accessed by selecting Object Browser from the
View menu or pressing the key F2.
The left column of the Object Browser lists the objects and classes that are available
in the projects that are opened and the controls that have been referenced in them.
It is possible for us to scroll through the list and select the object or class that we wish
to inspect. After an object is picked up from the Classes list, we can see its members
(properties, methods and events) in the right column.
A property is represented by a small icon that has a hand holding a piece of paper.
Methods are denoted by little green blocks, while events are denoted by yellow lightning bolt
icon.
Working with Forms
The main characteristic of a Form is the title bar on which the Form's caption is
displayed. On the left end of the title bar is the Control Menu icon.
Clicking this icon opens the Control Menu. Maximize, Minimize and Close buttons
can be found on the right side of the Form. Clicking on these buttons performs the associated
function.
The following figure illustrates the appearance of a Form
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page12
The control menu contains the following commands:
 Restore: Restores a maximized Form to the size it was before it was maximized;
available only if the Form has been maximized.
 Move : Lets the user moves the Form around with the mouse
 Size : Lets the user resizes the control with the mouse
 Minimize: Minimizes the Form
 Maximize : Maximizes the Form
 Close : Closes the Form
Setting the Start-Up Form
A typical application has more than a single Form. When an application runs the main
Form is loaded. By setting the Project properties you can control which Form is to be
displayed in the Start-Up of the application.
Following figure illustrates the Project property window.
By default, Visual Basic suggests the name of the first Form created when the project started.
Loading and Unloading Forms
In order to load and unload the forms, Load and Unload statements are used. The
Load statement has the following syntax :
Load FormName
And the Unload statement has the following syntax :
Unload FormName
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page13
The FormName variable is the name of the Form to be loaded or unloaded. Unlike the
Show method which cares of both loading and displaying the Form, the load statement
doesn't show the Form. You have to call the Form's Show method to display it on the
desktop.
Showing and Hiding Forms
Show method is used to Show a Form. If the Form is loaded but invisible, the Show
method is used to bring the Form on Top every other window. If the Form is not loaded, the
Show method loads it and then displays it.
Syntax of the Show method of the Form
FormName.Show mode
The FormName variable is the Form's name, and the optional argument mode
determines whether the Form will be Modal or not. It can have one of the following syntax :
* 0-Modeless (default)
* 1-Modal
Modeless Forms are the normal Forms. Modeless Forms interact with the user and the
user allowed to switch to any other Form of the application. If you do not specify the optional
mode argument, by default the mode is set to modeless.
The Modal Forms takes the total control of the application where user cannot switch
to any other Forms in the application unless the Form is closed. A modal Form, thus, must
have a Close button or some means to close the Form in order to return to the Form where the
Modal Form was loaded.
Hiding Forms
The Hide method is used to hide a Form. The following is the syntax of the Hide
Method.
FormName.Hide
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page14
To hide a Form from within its own code, the following code can be used.
Me.Hide
You must understand that the Forms that are hidden are not unloaded; they remains in
the memory and can be displayed instantly with the Show Method. When a Form is hidden,
you can still access its properties and code. For instance, you can change the settings of its
Control Properties or call any Public functions in the Form.
The following is an example illustrates the Show method and Mode statement
* Open a new Project and save the Project
Design the application as shown below
Object Property Setting
Form
Caption
Name
Form1
frm1
Form
Caption
Name
Form2
frm2
Form
Caption
Name
Form3
frm3
Label
Caption
Name
Click on a button to display a
Form
Label1
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page15
Using the Toolbox
In visual basic, you have to design the user interface. A visual basic interface consists
of objects that we place on screen in such a manner so that screen looks pretty and you can
work with those objects.
To design your user interface, we have to follow simply these steps-
1. At first, Create a form.
2. Choose the object you want to draw from the Toolbox.
3. Draw the object on the form.
So, create an object in visual basic, you have to use toolbox.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page16
TOOLBAR
The Toolbar provides the user quick access to the most commonly used functions of a
program. A toolbar can be used stand-alone or as a complement to the program's menu
structure.
Working with Projects
In Visual Basic, a project is the group of all the files that make up your program.
These might include forms, modules (blocks of code not attached to a form), graphics, and
ActiveX controls. Other types of files may also be part of a project, but don't worry about that
now.
The first thing to keep in mind about a project is that as you create your program, each
form, module, graphic, and ActiveX control is saved as an individual file
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page17
Common file types in a Visual Basic 6 project
File Type Description
FRM Form
BAS Module
FRX Automatically generated file for every graphic in your project
OCX ActiveX control
CLS Class module
VBP Visual Basic project
Detailed information about all your program's files is stored in the project file. The
project file lists all the files your program uses, as well as details such as the project name
and how the IDE should be configured while you work on this particular project. Project files
have the extension VBP.
Using the Project Explorer
You can keep track of all the files in your project with the Project Explorer, a window
found on the right side of the Visual Basic IDE .The Project Explorer provides a method to
organize your project's files and allows you to access them individually in form or code view.
 Use the Project Explorer to keep track of files in your project. Note that OCX and
FRX files aren't listed in the Project Explorer.
 Most of your interaction with the Project Explorer will be with its context menu.
The context menu allows you to
 View the file in a form window or code window
 View the properties of the file
 Add a form or module to the project
 Save the current file
 Delete the file from the project
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page18
 Print the file
 Make the Project Explorer float or dock it to the IDE
 Hide the Project Explorer
Creating a New Project
 Every time you run Visual Basic, you'll see the New Project dialog from this window,
you can simply select the type of project you want to create and click Open.
 Use the New Project dialog to create a project.
 It's also possible to start a new project while Visual Basic is already running.
Starting a new project
1. From the File menu, choose New Project. (You may be prompted to save the
current project. If you need to save it but aren't sure how, see the later section "Saving
and Naming a Project.")
2. In the New Project dialog, select the type of project you want to create and
click OK.
Changing a Project's Properties
Many pieces of information are required to describe a project, including the project
name, the version number, and the title that will appear in the title bar of the finished
application. Many others can be accessed via the Project Properties dialog
 You set your project's type, name, and help file on the General page. You can also add
a project description.
 On the Make page, you can set your project's version number and version-specific
information, as well as the project title and icon.
Access the Project Properties dialog
1. In the Project Explorer, right-click the project file (the first file listed).
2. From the context menu, select ProjectName Properties. The Project Properties
dialog appears. (Or, from the Project menu, choose ProjectName Properties.)
Saving and Naming a Project
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page19
When you save your project, you actually save each individual part of your project
(every form, module, graphic, and so forth) as an individual file, and then save the project file
itself. When you save your project for the first time, Visual Basic automatically suggests a
name for each file.
This filename will be the same as the name of the form (or module, graphic, and so
on), with an appropriate extension for the type of file you're saving. Thus, a module named
modStart would be named modStart.bas because modules have the extension .bas.
Save a project
1. From the File menu, choose Save Project.
2. If this is the first time you've saved this project, or if you've added a form or
module since the last time you've saved it, the Save File As dialog appears for each
unsaved file.
3. Enter a name for the file and click the Save button.
4. The last file to save is the project file. If you've assigned a name to your project
with the Project Properties dialog (refer to the section "Changing a Project's
Properties"), VB automatically suggests Project_name.vbp as the file name. If you
haven't assigned a project name, VB suggests a default name, such as Project1.vbp.
When this happens, you should change the default name to something more friendly,
such as SaveTest.vbp.
Opening an Existing Project
If you've worked on the file recently, open the File menu. At the bottom of this menu
is a list of the files you have most recently worked on. Select the appropriate file to open it. If
the desired project doesn't appear in this list, you'll have to look for it.
Opening an existing project
 From the File menu, choose Open Project. The Open Project dialog appears
 Open existing or recent projects with the Open Project dialog.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page20
 On the Existing page, switch to the folder in which you've saved your project. (If
you've recently worked on the project, select your project from the list on
the Recent page.)
 Select the project and click Open.
Adding Files to a Project
Often, your programs will require more than one form or module. For example, if you
want to have an About dialog in your program, it will require that you add a form.
You can add new files to your project in two ways: by selecting the file type (such as
form or module) that you want to add from the Project menu, or by adding files from the
Project Explorer.
Adding new files from the Project Explorer
1. Right-click inside the Project Explorer.
2. From the context menu choose Add, and then select the type of file you want to
add.
Whichever method you use, you may be prompted with a dialog that allows you to
pick a specific type of form or module to add .Visual Basic provides templates for commonly
used files, such as an About dialog, to save you the time and effort of creating it yourself.
Visual Basic contains many templates for creating commonly used forms.
You can also add existing files to your project, which comes in handy if you want to
use a form or module that you previously created for a different project. Adding an existing
file is very similar to adding a new file, except that you choose Add File from
the Project menu or from the Project Explorer's context menu (see Figure 5.9).
Removing Files from a Project
1. In the Project Explorer, right-click the file you want to remove.
2. From the context menu, select Remove filename.
Add existing files to your project by selecting Add File.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page21
You also can highlight the file in the Project Explorer and
choose Remove filename from the Project menu.
Programming Structure of Visual Basic applications
A Visual Basic program is built up from standard building blocks.
A solution comprises one or more projects.
Application (Project) is made up of:
 Forms - Windows that you create for user interface
 Controls - Graphical features drawn on forms to allow user interaction (text boxes,
labels, scroll bars, command buttons, etc.) (Forms and Controls are objects.)
 Properties - Every characteristic of a form or control is specified by a property.
Example properties include names, captions, size, color, position, and contents. Visual
Basic applies default properties. You can change properties at design time or run
time.
 Methods - Built-in procedure that can be invoked to impart some action to a particular
object.
 Event Procedures - Code related to some object. This is the code that is executed
when a certain event occurs.
 General Procedures - Code not related to objects. This code must be invoked by the
application.
 Modules - Collection of general procedures, variable declarations, and constant
definitions used by application.
Steps in Developing Application
There are three primary steps involved in building a Visual Basic application:
1. Draw the user interface
2. Assign properties to controls
3. Attach code to controls
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page22
Drawing the User Interface and Setting Properties
Visual Basic operates in three modes.
 Design mode - used to build application
 Run mode - used to run the application
 Break mode - application halted and debugger is available We focus here on
the design mode.
Event and Event driven procedures.
Event-driven programming is a programming paradigm in which the flow of program
execution is determined by events - for example a user action such as a mouse click, key
press, or a message from the operating system or another program.
An event-driven application is designed to detect events as they occur, and then deal
with them using an appropriate event-handling procedure.
A visual programming IDE such as VB.Net provides much of the code for detecting
events automatically when a new application is created. The programmer can therefore
concentrate on issues such as interface design, which involves adding controls such as
command buttons, text boxes, and labels to standard forms (a form represents an application's
workspace or window). Once the user interface is substantially complete, the programmer can
add event-handling code to each control as required.
Many visual programming environments will even provide code templates for event-
handlers, so the programmer only needs to provide the code that defines the action the
program should take when the event occurs.
Each event-handler is usually bound to a specific object or control on a form. Any
additional subroutines, methods, or function procedures required are usually placed in a
separate code module, and can be called from other parts of the program as and when needed.
D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC.
Page23

More Related Content

DOC
235042632 super-shop-ee
PDF
Porting iPhone Apps to Windows Phone 7
DOCX
Online advertising management system
PDF
Platform Independent App design
DOCX
Acknowledgement
PDF
mLearn Project 2012 Full Report
PDF
Cross platform app a comparative study
DOCX
Cs 6611 mad lab manual
235042632 super-shop-ee
Porting iPhone Apps to Windows Phone 7
Online advertising management system
Platform Independent App design
Acknowledgement
mLearn Project 2012 Full Report
Cross platform app a comparative study
Cs 6611 mad lab manual

What's hot (8)

DOCX
Over view of Technologies
DOCX
How backbone.js is different from ember.js?
PDF
The Best Alternatives To The Ionic Framework.pdf
PPTX
Drugs
PDF
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
PDF
Top 8 Alternatives Of Xamarin.pdf
PDF
Apress.migrating.to.windows.phone.dec.2011
Over view of Technologies
How backbone.js is different from ember.js?
The Best Alternatives To The Ionic Framework.pdf
Drugs
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
Top 8 Alternatives Of Xamarin.pdf
Apress.migrating.to.windows.phone.dec.2011
Ad

Similar to Unit 1 vb study_materials (20)

PPTX
Introduction to Visual Basic 6.0 Fundamentals
PPTX
LESSON1-INTRODUCTION-TO-VISUALBASIC-1.pptx
PPTX
Introduction to Visual Basic Programming
PPT
vb-1605181cbddfbfbdfbfdbdfbfdbdfbfdbfdb51614.ppt
PDF
vb-160518151614.pdf
PPTX
vb-160518151614.pptx
PPTX
vb.pptx
PDF
Programming with visual_basic_new
PPT
Visual basic
DOCX
Vb lecture
PPT
Advanced Programming Language(Visual basics) .ppt
PPT
Introduction to Visual Basic: Dive into the fundamental concepts of Visual Ba...
PPTX
Visual basic
PPTX
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
PPTX
Lesson 4 Introduction to Human Computer Interaction.pptx
PPT
VB6gjbbjbjbjbj jbjbjbjbjbjbjhbjbjbjbjbCh1.ppt
PPT
VB6 detailed set of instructions for a computer to execute.ppt
PDF
Visual Basic In Easy Steps Covers Visual Basic 2015 Fourth Mcgrath
PPTX
Managing a project (Mican Trtrttan).pptx
PDF
VB PPT by ADI part-1.pdf
Introduction to Visual Basic 6.0 Fundamentals
LESSON1-INTRODUCTION-TO-VISUALBASIC-1.pptx
Introduction to Visual Basic Programming
vb-1605181cbddfbfbdfbfdbdfbfdbdfbfdbfdb51614.ppt
vb-160518151614.pdf
vb-160518151614.pptx
vb.pptx
Programming with visual_basic_new
Visual basic
Vb lecture
Advanced Programming Language(Visual basics) .ppt
Introduction to Visual Basic: Dive into the fundamental concepts of Visual Ba...
Visual basic
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
Lesson 4 Introduction to Human Computer Interaction.pptx
VB6gjbbjbjbjbj jbjbjbjbjbjbjhbjbjbjbjbCh1.ppt
VB6 detailed set of instructions for a computer to execute.ppt
Visual Basic In Easy Steps Covers Visual Basic 2015 Fourth Mcgrath
Managing a project (Mican Trtrttan).pptx
VB PPT by ADI part-1.pdf
Ad

More from gayaramesh (7)

PDF
Unit1 rdbms study_materials-converted (1) (1)
PDF
Unit 2 rdbms study_material
PDF
Unit 3 rdbms study_materials-converted
PDF
Unit 4 rdbms study_material
PDF
Unit 5 rdbms study_material
PDF
Unit iii vb_study_materials
PDF
Unit1 rdbms study_materials
Unit1 rdbms study_materials-converted (1) (1)
Unit 2 rdbms study_material
Unit 3 rdbms study_materials-converted
Unit 4 rdbms study_material
Unit 5 rdbms study_material
Unit iii vb_study_materials
Unit1 rdbms study_materials

Recently uploaded (20)

PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
PPT on Performance Review to get promotions
PPTX
Welding lecture in detail for understanding
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPT
Mechanical Engineering MATERIALS Selection
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Digital Logic Computer Design lecture notes
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
additive manufacturing of ss316l using mig welding
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
DOCX
573137875-Attendance-Management-System-original
bas. eng. economics group 4 presentation 1.pptx
Strings in CPP - Strings in C++ are sequences of characters used to store and...
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Construction Project Organization Group 2.pptx
Structs to JSON How Go Powers REST APIs.pdf
Lecture Notes Electrical Wiring System Components
CH1 Production IntroductoryConcepts.pptx
PPT on Performance Review to get promotions
Welding lecture in detail for understanding
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mechanical Engineering MATERIALS Selection
Operating System & Kernel Study Guide-1 - converted.pdf
Digital Logic Computer Design lecture notes
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
additive manufacturing of ss316l using mig welding
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
573137875-Attendance-Management-System-original

Unit 1 vb study_materials

  • 1. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page1 Pondicherry University Community College Department of Computer Science Course : BCA Year : II Semester : III Subject : Programming with Visual Basic Unit I Study Material Prepared by D.GAYA Assistant Professor, Department of Computer Science, Pondicherry University Community College, Lawspet, Puducherry-08.
  • 2. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page2 UNIT –I Introduction to GUI - Visual Basic: Starting and Exiting Visual Basic – Project Explorer – Working with Forms – Properties Window – Using the Toolbox – Toolbars – Working with Projects – Programming Structure of Visual Basic applications – Event and Event driven procedures. Introduction to GUI A GUI is a type of computer human interface on a computer. It solves the blank screen problem that confronted early computer users. These early users sat down in front of a computer and faced a blank screen, with only a prompt. The computer gave the user no indication what the user was to do next. GUI are an attempt to solve this blank screen problem. The first commercially available GUI, called "PARC," was developed by Xerox. It was used by the Xerox 8010 Information System, which was released in 1981. After Steve Jobs saw the interface during a tour at Xerox, he had his team at Apple develop an operating system with a similar design. Apple's GUI-based OS was included with the Macintosh, which was released in 1984. Microsoft released their first GUI-based OS, Windows 1.0, in 1985. For several decades, GUIs were controlled exclusively by a mouse and a keyboard. While these types of input devices are sufficient for desktop computers, they do not work as well for mobile devices, such as smartphones and tablets. Therefore, mobile operating systems are designed to use a touchscreen interface. Many mobile devices can now be controlled by spoken commands as well. Introduction to Visual Basic Visual Basic 6 programming let us understand some basic concepts of programming. According to a computer program is an organized list of instructions that, when executed, causes the computer to behave in a predetermined manner. Without programs, computers are useless. Therefore, programming means designing or creating a set of instructions to ask the computer to carry out certain jobs which normally are very much faster than human beings can do.
  • 3. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page3 A lot of people think that computer CPU is a very intelligent thing, which in actual fact it is a dumb and in animate object that can do nothing without human assistance. The microchips of a CPU can only understand two distinct electrical states, namely, the on and off states, or 0 and 1 codes in the binary system. So, the CPU only understands combinations of 0 and 1 codes, a language which we called machine language. Machine language is extremely difficult to learn and it is not for us to master it easily. Fortunately , we have many smart programmers who wrote interpreters and compilers that can translate human language-like programs such as BASIC into machine language so that the computer can carry out the instructions entered by the users. Machine language is known as the primitive language while Interpreters and compilers like Visual Basic are called high-level language. Some of the high level computer languages beside Visual Basic are Fortran, Cobol, Java, C, C++, Turbo Pascal, and etc . What is Visual Basic? VISUAL BASIC is a high level programming language which evolved from the earlier DOS version called BASIC. BASIC means Beginners' All- purpose Symbolic Instruction Code. It is a very easy programming language to learn. The code look a lot like English Language. Different software companies produced different versions of BASIC, such as Microsoft QBASIC, QUICKBASIC, GWBASIC ,IBM BASICA and so on. However, people prefer to use Microsoft Visual Basic today, as it is a well-developed programming language and supporting resources are available everywhere. Now, there are many versions of VB exist in the market, the most popular one and still widely used by many VB programmers is none other than Visual Basic 6. We also have VB.net, VB2005, VB2008 and the latest VB2010. Both Vb2008 and VB2010 are fully object oriented programming (OOP) language. VISUAL BASIC is a VISUAL and events driven Programming Language. These are the main divergence from the old BASIC. In BASIC, programming is done in a text-only environment and the program is executed sequentially. In VB, programming is done in a
  • 4. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page4 graphical environment. In the old BASIC, you have to write program code for each graphical object you wish to display it on screen, including its position and its color. However, In VB , you just need to drag and drop any graphical object anywhere on the form, and you can change its color any time using the properties windows. On the other hand, because the user may click on a certain object randomly, so each object has to be programmed independently to be able to response to those actions (events). Therefore, a VB Program is made up of many subprograms, each has its own program code, and each can be executed independently and at the same time each can be linked together in one way or another. What programs can you create with Visual Basic 6?  With VB 6, 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 ! There are many such programs in this tutorial, so you must spend more time on the tutorial in order to learn how to create those programs. Starting and Exiting Visual Basic After installing the vb6 compiler, the icon will appear on your desktop or in your programs menu. Click on the icon to launch the VB6 compiler. On start-up, Visual Basic 6.0 will display the following dialog box as shown in Figure.
  • 5. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page5 You can choose to start a new project, open an existing project or select a list of recently opened programs. A project is a collection of files that make up your application. There are various types of applications that we could create, however, we shall concentrate on creating Standard EXE programs (EXE means executable). Before you begin, you must think of an application that preferably have commercial ,educational or recreational value. Next, click on the Standard EXE icon to go into the actual Visual Basic 6 programming environment. When you start a new Visual Basic 6 Standard EXE project, you will be presented with the Visual Basic 6 Integrated Development Environment (IDE). The Visual Basic 6 Integrated Programming Environment is shown in Figure. It consists of the toolbox, the form, the project explorer and the properties window.
  • 6. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page6 The Form is the primary building block of a Visual Basic 6 application. A Visual Basic 6 application can actually comprise many forms, but we shall focus on developing an application with one form first. We will learn how to develop applications with multiple forms later. Before you proceed to build the application, it is a good practice to save the project first. You can save the project by selecting Save Project from the File menu, assign a name to your project and save it in a certain folder. The Integrated Development Environment (IDE) One of the most significant changes in Visual Basic 6.0 is the Integrated Development Environment (IDE). IDE is a term commonly used in the programming world to describe the interface and environment that we use to create our applications. It is called integrated because we can access virtually all of the development tools that we need from one screen called an interface. The IDE is also commonly referred to as the design environment, or the program. The Visual Basic IDE is made up of a number of components  Menu Bar
  • 7. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page7  Tool Bar  Project Explorer  Properties window  Form Layout Window  Toolbox  Form Designer  Object Browser In previous versions of Visual Basic, the IDE was designed as a Single Document Interface (SDI). In a Single Document Interface, each window is a free-floating window that is contained within a main window and can move anywhere on the screen as long as Visual Basic is the current application. But, in Visual Basic 6.0, the IDE is in a Multiple Document Interface (MDI) format. In this format, the windows associated with the project will stay within a single container known as the parent. Code and form-based windows will stay within the main container form. Menu Bar This Menu Bar displays the commands that are required to build an application. The main menu items have sub menu items that can be chosen when needed. The toolbars in the menu bar provide quick access to the commonly used commands and a button in the toolbar is clicked once to carry out the action represented by it. Toolbox The Toolbox contains a set of controls that are used to place on a Form at design time thereby creating the user interface area. Additional controls can be included in the toolbox by using the Components menu item on the Project menu. A Toolbox is represented in figure 2 shown below.
  • 8. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page8 Control Description Pointer Provides a way to move and resize the controls form PictureBox Displays icons/bitmaps and metafiles. It displays text or acts as a visual container for other controls. TextBox Used to display message and enter text. Frame Serves as a visual and functional container for controls CommandButton Used to carry out the specified action when the user chooses it. CheckBox Displays a True/False or Yes/No option. OptionButton OptionButton control which is a part of an option group allows the user to select only one option even it displays mulitiple choices. ListBox Displays a list of items from which a user can select one.
  • 9. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page9 ComboBox Contains a TextBox and a ListBox. This allows the user to select an ietm from the dropdown ListBox, or to type in a selection in the TextBox. HScrollBar and VScrollBar These controls allow the user to select a value within the specified range of values Timer Executes the timer events at specified intervals of time DriveListBox Displays the valid disk drives and allows the user to select one of them. DirListBox Allows the user to select the directories and paths, which are displayed. FileListBox Displays a set of files from which a user can select the desired one. Shape Used to add shape (rectangle, square or circle) to a Form Line Used to draw straight line to the Form Image used to display images such as icons, bitmaps and metafiles. But less capability than the PictureBox Data Enables the use to connect to an existing database and display information from it. OLE Used to link or embed an object, display and manipulate data from other windows based applications. Label Displays a text that the user cannot modify or interact with.
  • 10. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page10 Project Explorer Docked on the right side of the screen, just under the tollbar, is the Project Explorer window. The Project Explorer as shown in in figure servers as a quick reference to the various elements of a project namely form, classes and modules. All of the object that make up the application are packed in a project. A simple project will typically contain one form, which is a window that is designed as part of a program's interface. It is possible to develop any number of forms for use in a program, although a program may consist of a single form. In addition to forms, the Project Explorer window also lists code modules and classes. Properties Window The Properties Window is docked under the Project Explorer window. The Properties Window exposes the various characteristics of selected objects. Each and every form in an application is considered an object. Now, each object in Visual Basic has characteristics such as color and size. Other characteristics affect not just the appearance of the object but the way it behaves too. All these characteristics of an object are called its properties.
  • 11. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page11 Thus, a form has properties and any controls placed on it will have properties too. All of these properties are displayed in the Properties Window. Object Browser The Object Browser allows us to browse through the various properties, events and methods that are made available to us. It is accessed by selecting Object Browser from the View menu or pressing the key F2. The left column of the Object Browser lists the objects and classes that are available in the projects that are opened and the controls that have been referenced in them. It is possible for us to scroll through the list and select the object or class that we wish to inspect. After an object is picked up from the Classes list, we can see its members (properties, methods and events) in the right column. A property is represented by a small icon that has a hand holding a piece of paper. Methods are denoted by little green blocks, while events are denoted by yellow lightning bolt icon. Working with Forms The main characteristic of a Form is the title bar on which the Form's caption is displayed. On the left end of the title bar is the Control Menu icon. Clicking this icon opens the Control Menu. Maximize, Minimize and Close buttons can be found on the right side of the Form. Clicking on these buttons performs the associated function. The following figure illustrates the appearance of a Form
  • 12. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page12 The control menu contains the following commands:  Restore: Restores a maximized Form to the size it was before it was maximized; available only if the Form has been maximized.  Move : Lets the user moves the Form around with the mouse  Size : Lets the user resizes the control with the mouse  Minimize: Minimizes the Form  Maximize : Maximizes the Form  Close : Closes the Form Setting the Start-Up Form A typical application has more than a single Form. When an application runs the main Form is loaded. By setting the Project properties you can control which Form is to be displayed in the Start-Up of the application. Following figure illustrates the Project property window. By default, Visual Basic suggests the name of the first Form created when the project started. Loading and Unloading Forms In order to load and unload the forms, Load and Unload statements are used. The Load statement has the following syntax : Load FormName And the Unload statement has the following syntax : Unload FormName
  • 13. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page13 The FormName variable is the name of the Form to be loaded or unloaded. Unlike the Show method which cares of both loading and displaying the Form, the load statement doesn't show the Form. You have to call the Form's Show method to display it on the desktop. Showing and Hiding Forms Show method is used to Show a Form. If the Form is loaded but invisible, the Show method is used to bring the Form on Top every other window. If the Form is not loaded, the Show method loads it and then displays it. Syntax of the Show method of the Form FormName.Show mode The FormName variable is the Form's name, and the optional argument mode determines whether the Form will be Modal or not. It can have one of the following syntax : * 0-Modeless (default) * 1-Modal Modeless Forms are the normal Forms. Modeless Forms interact with the user and the user allowed to switch to any other Form of the application. If you do not specify the optional mode argument, by default the mode is set to modeless. The Modal Forms takes the total control of the application where user cannot switch to any other Forms in the application unless the Form is closed. A modal Form, thus, must have a Close button or some means to close the Form in order to return to the Form where the Modal Form was loaded. Hiding Forms The Hide method is used to hide a Form. The following is the syntax of the Hide Method. FormName.Hide
  • 14. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page14 To hide a Form from within its own code, the following code can be used. Me.Hide You must understand that the Forms that are hidden are not unloaded; they remains in the memory and can be displayed instantly with the Show Method. When a Form is hidden, you can still access its properties and code. For instance, you can change the settings of its Control Properties or call any Public functions in the Form. The following is an example illustrates the Show method and Mode statement * Open a new Project and save the Project Design the application as shown below Object Property Setting Form Caption Name Form1 frm1 Form Caption Name Form2 frm2 Form Caption Name Form3 frm3 Label Caption Name Click on a button to display a Form Label1
  • 15. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page15 Using the Toolbox In visual basic, you have to design the user interface. A visual basic interface consists of objects that we place on screen in such a manner so that screen looks pretty and you can work with those objects. To design your user interface, we have to follow simply these steps- 1. At first, Create a form. 2. Choose the object you want to draw from the Toolbox. 3. Draw the object on the form. So, create an object in visual basic, you have to use toolbox.
  • 16. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page16 TOOLBAR The Toolbar provides the user quick access to the most commonly used functions of a program. A toolbar can be used stand-alone or as a complement to the program's menu structure. Working with Projects In Visual Basic, a project is the group of all the files that make up your program. These might include forms, modules (blocks of code not attached to a form), graphics, and ActiveX controls. Other types of files may also be part of a project, but don't worry about that now. The first thing to keep in mind about a project is that as you create your program, each form, module, graphic, and ActiveX control is saved as an individual file
  • 17. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page17 Common file types in a Visual Basic 6 project File Type Description FRM Form BAS Module FRX Automatically generated file for every graphic in your project OCX ActiveX control CLS Class module VBP Visual Basic project Detailed information about all your program's files is stored in the project file. The project file lists all the files your program uses, as well as details such as the project name and how the IDE should be configured while you work on this particular project. Project files have the extension VBP. Using the Project Explorer You can keep track of all the files in your project with the Project Explorer, a window found on the right side of the Visual Basic IDE .The Project Explorer provides a method to organize your project's files and allows you to access them individually in form or code view.  Use the Project Explorer to keep track of files in your project. Note that OCX and FRX files aren't listed in the Project Explorer.  Most of your interaction with the Project Explorer will be with its context menu. The context menu allows you to  View the file in a form window or code window  View the properties of the file  Add a form or module to the project  Save the current file  Delete the file from the project
  • 18. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page18  Print the file  Make the Project Explorer float or dock it to the IDE  Hide the Project Explorer Creating a New Project  Every time you run Visual Basic, you'll see the New Project dialog from this window, you can simply select the type of project you want to create and click Open.  Use the New Project dialog to create a project.  It's also possible to start a new project while Visual Basic is already running. Starting a new project 1. From the File menu, choose New Project. (You may be prompted to save the current project. If you need to save it but aren't sure how, see the later section "Saving and Naming a Project.") 2. In the New Project dialog, select the type of project you want to create and click OK. Changing a Project's Properties Many pieces of information are required to describe a project, including the project name, the version number, and the title that will appear in the title bar of the finished application. Many others can be accessed via the Project Properties dialog  You set your project's type, name, and help file on the General page. You can also add a project description.  On the Make page, you can set your project's version number and version-specific information, as well as the project title and icon. Access the Project Properties dialog 1. In the Project Explorer, right-click the project file (the first file listed). 2. From the context menu, select ProjectName Properties. The Project Properties dialog appears. (Or, from the Project menu, choose ProjectName Properties.) Saving and Naming a Project
  • 19. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page19 When you save your project, you actually save each individual part of your project (every form, module, graphic, and so forth) as an individual file, and then save the project file itself. When you save your project for the first time, Visual Basic automatically suggests a name for each file. This filename will be the same as the name of the form (or module, graphic, and so on), with an appropriate extension for the type of file you're saving. Thus, a module named modStart would be named modStart.bas because modules have the extension .bas. Save a project 1. From the File menu, choose Save Project. 2. If this is the first time you've saved this project, or if you've added a form or module since the last time you've saved it, the Save File As dialog appears for each unsaved file. 3. Enter a name for the file and click the Save button. 4. The last file to save is the project file. If you've assigned a name to your project with the Project Properties dialog (refer to the section "Changing a Project's Properties"), VB automatically suggests Project_name.vbp as the file name. If you haven't assigned a project name, VB suggests a default name, such as Project1.vbp. When this happens, you should change the default name to something more friendly, such as SaveTest.vbp. Opening an Existing Project If you've worked on the file recently, open the File menu. At the bottom of this menu is a list of the files you have most recently worked on. Select the appropriate file to open it. If the desired project doesn't appear in this list, you'll have to look for it. Opening an existing project  From the File menu, choose Open Project. The Open Project dialog appears  Open existing or recent projects with the Open Project dialog.
  • 20. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page20  On the Existing page, switch to the folder in which you've saved your project. (If you've recently worked on the project, select your project from the list on the Recent page.)  Select the project and click Open. Adding Files to a Project Often, your programs will require more than one form or module. For example, if you want to have an About dialog in your program, it will require that you add a form. You can add new files to your project in two ways: by selecting the file type (such as form or module) that you want to add from the Project menu, or by adding files from the Project Explorer. Adding new files from the Project Explorer 1. Right-click inside the Project Explorer. 2. From the context menu choose Add, and then select the type of file you want to add. Whichever method you use, you may be prompted with a dialog that allows you to pick a specific type of form or module to add .Visual Basic provides templates for commonly used files, such as an About dialog, to save you the time and effort of creating it yourself. Visual Basic contains many templates for creating commonly used forms. You can also add existing files to your project, which comes in handy if you want to use a form or module that you previously created for a different project. Adding an existing file is very similar to adding a new file, except that you choose Add File from the Project menu or from the Project Explorer's context menu (see Figure 5.9). Removing Files from a Project 1. In the Project Explorer, right-click the file you want to remove. 2. From the context menu, select Remove filename. Add existing files to your project by selecting Add File.
  • 21. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page21 You also can highlight the file in the Project Explorer and choose Remove filename from the Project menu. Programming Structure of Visual Basic applications A Visual Basic program is built up from standard building blocks. A solution comprises one or more projects. Application (Project) is made up of:  Forms - Windows that you create for user interface  Controls - Graphical features drawn on forms to allow user interaction (text boxes, labels, scroll bars, command buttons, etc.) (Forms and Controls are objects.)  Properties - Every characteristic of a form or control is specified by a property. Example properties include names, captions, size, color, position, and contents. Visual Basic applies default properties. You can change properties at design time or run time.  Methods - Built-in procedure that can be invoked to impart some action to a particular object.  Event Procedures - Code related to some object. This is the code that is executed when a certain event occurs.  General Procedures - Code not related to objects. This code must be invoked by the application.  Modules - Collection of general procedures, variable declarations, and constant definitions used by application. Steps in Developing Application There are three primary steps involved in building a Visual Basic application: 1. Draw the user interface 2. Assign properties to controls 3. Attach code to controls
  • 22. D.GAYA,AssistantProfessor,Departmentof ComputerScience,PUCC. Page22 Drawing the User Interface and Setting Properties Visual Basic operates in three modes.  Design mode - used to build application  Run mode - used to run the application  Break mode - application halted and debugger is available We focus here on the design mode. Event and Event driven procedures. Event-driven programming is a programming paradigm in which the flow of program execution is determined by events - for example a user action such as a mouse click, key press, or a message from the operating system or another program. An event-driven application is designed to detect events as they occur, and then deal with them using an appropriate event-handling procedure. A visual programming IDE such as VB.Net provides much of the code for detecting events automatically when a new application is created. The programmer can therefore concentrate on issues such as interface design, which involves adding controls such as command buttons, text boxes, and labels to standard forms (a form represents an application's workspace or window). Once the user interface is substantially complete, the programmer can add event-handling code to each control as required. Many visual programming environments will even provide code templates for event- handlers, so the programmer only needs to provide the code that defines the action the program should take when the event occurs. Each event-handler is usually bound to a specific object or control on a form. Any additional subroutines, methods, or function procedures required are usually placed in a separate code module, and can be called from other parts of the program as and when needed.