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

Visual Basic Unit-I

Uploaded by

ananthaskishor32
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Visual Basic Unit-I

Uploaded by

ananthaskishor32
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

KONGU ARTS AND SCIENCE COLLEGE

(AUTONOMOUS)
ERODE 638 107
DEPARTMENT OF
BUSINESS
ADMINISTARTION WITH
COMPUTER APPLICATIONS
UNIT-I
• Introduction to Visual Basic
• Event and Event procedure
• Object Related Concepts
• Visual Basic Program Concepts
• Visual Basic Environment
• Visual Basic Fundamentals
Introduction to Visual Basic
• Visual basic is an object oriented program
• It is the third generation language
• It is the programming language
• It runs under MS Window Environment
• It consist of two major Components
1)Controls
2)Commands
Introduction to Visual Basic
• An extensive collection of pre written tools
is called controls
Eg: label box, text box etc.,
• A complete set of program is called
commands
• The overall approach of visual basic
program is under two steps
– Create an user interface
– Add a group of basic instruction commands
Visual Basic Screen
Visual Basic Screen
Visual Basic Screen
Event and Event Procedure
Event
• Visual basic is an event driven
programming
• The program responses to the action
taken by the user.
• In VB, controls (like buttons, text boxes,
etc.) can generate events.
Event and Event Procedure
Common types of events
Click
• Triggered when a user clicks a control, like
a button.
TextChanged
• Triggered when the text in a text box
changes.
Load
• Triggered when a form is loaded.
Event and Event Procedure
Event Procedure
• The group of basic commands which bring
about responses is called as event
procedure.
Example
Private Sub Command1_Click()
....
End Sub
Event and Event Procedure
• In this example, Command1_Click is an
event procedure that handles the Click
event of Command1.
• When Command1 is clicked, the code
within the Command1_Click procedure
executes.
Event and Event Procedure
Example Program
Write and explain your practical program
Object Related Concepts
• There are five different things in the object
related concepts
1)Forms
2)Controls
3)Objects
4)Properties
5)Methods
Forms

• In Visual Basic (VB), a form is a


fundamental part of creating a graphical
user interface (GUI) for applications.
• A form is a window or a dialog box that
makes up part of the user interface.
• It serves as a container for controls such
as buttons, text boxes, labels, and other
GUI components.
Forms
Controls
• The icon with which user interacts is
called controls
• The controls can be placed in the
client area by means of two ways
1)Click and Drag
2)Double click the icon
• The most commonly used controls
are label box, text box and command
buttons
Controls
Objects
• Forms and controls are collectively
referred to as objects
• Most of the objects are associated with
events
• Most objects include their unique event
procedure
• Objects are also associated with
properties and methods
Properties
• Object include properties which define
their appearance and behavior
• The choice of properties depends on the
type of the object
• Eg: Name ,Caption, etc.,
Methods
• Object includes visual basic program
statements called methods
• The methods bring some pre defined
action associated with the object
Visual Basic Program Concepts
• In visual basic program is referred to as
project
• Visual basic project consist of two
separate files
1)Project file with extension .vbp
2)Form with extension .frm
• The form file and project file can be seen
in project window
• The project file can also include class
module
Visual Basic Environment
• The visual basic environment consist of
different things namely
1)Title Bar
2)Menu Bar
3)Tool Bar
4)Control Tool Box
5)Form Design Window
6)Project Window
7)Properties Window
Visual Basic Environment
8)Form Layout Window
9)Code Editor Window
10)Immediate Window
Visual Basic Environment
Title Bar
•In visual Basic the first one is the title bar
•The title bar consist the name of the project
•It consist of three buttons
1)Minimize
2)Restore Down
3)Close
Menu Bar
• In visual Basic below the title bar is
the Menu bar.
• The Menu bar consist of menus
• It also consist of three buttons
1)Minimize
2)Restore Down
3)Close
Tool Bar
•In VB below the menu bar is the tool bar
•The tool bar consist of short cut tools which
is available in menu bar
•The tool bar consist of frequently used list in
the form for user friendly purpose
Control Tool Box
•The control tool is used to design
the form.
•The control tool consist of differ
tool for different purpose
•Each tool has its own unique feature
•With out control tools we can not
able to design the visual basic form
Form Design Window
•In VB form design window is
the user interface area
•The control tool box can be
placed in the form design
window
•The control tool can be placed
by means of two way
1)Click and Drag
2)Double click the icon
Project Window
Project Window
• In Visual Basic (VB) within the Visual Studio
Integrated Development Environment (IDE),
the Project Window (or Solution Explorer) is
a key component used to manage the files
and settings for VB project.
• It provides an organized view of all the
project’s elements, including forms,
modules, classes, and other resources.
Properties Window
• The Properties window in Visual Basic (VB)
within Visual Studio is an essential tool for
viewing and modifying the properties of
various objects in project, such as forms,
controls, and other components.
• It provides a user-friendly interface to change
settings without writing code, making it
easier to design and configure your
application.
Properties Window
Form Layout Window

• The Form Layout Window in Visual Basic


(VB) within Visual Studio is a tool that
helps you visually design and arrange the
layout of forms in your application.
• This window allows to position and size
form within the overall user interface,
providing a visual representation of how
form will appear at runtime.
Form Layout Window
Code Editor Window
• The Code Editor Window in Visual Basic
(VB) within Visual Studio is where we write,
edit, and manage VB code.
• It is a powerful tool with many features
that facilitate coding, debugging, and
navigating through project
Code Editor Window
Immediate Window
• It is also called as watch value
• It is very useful when debugging a project
• It will show whenever user enter a variable
or expression in the window
Numeric Constant
• Numbers are referred to as numeric
constants
• The numeric constants are expressed in
integers
• The basic rules of numeric constants are
• Commas(,)can not appear anywhere in it
• It may have(+) or (-) symbol
Numeric Constant
• An integer constants occupies 2 bytes
• The range of numeric constant is -32768
to 32767
• The integer comes under three categories
1)Long Integer
2)Single Precision
3)Double Precision
String Constant
• A string is a sequence of character
• It consist of letters, numbers and special
characters
• Blank space can also included in the string
• The string are used to represent non
numeric values
• The maximum length of the string is
infinite
• Example for string is “Hi I am fine”
Variables
• It is the name which represents the
numeric quantity
• The rules for naming a variable is
– A variable must begin with a letter
– Additional character may be letter or digits
– The special data type characters are not
permitted (!, #, $, &)
Variables
– A variable cannot exceed 255 characters
– The key words can not be used as variable
name
– There is no difference between lower and
upper case
Example: Hai(Valid) 9Hai(Not valid)
Data Types
• Visual basic supports all common data
types(integer, string)
• It also supports other data types such as
Boolean, date, currency as well as variant
• It also support undeclared variables are
referred as variant data type
• It also suggest that use of variants should
be avoided
• Example: Dim a as integer
Dim b
Operators and Expressions
• The specific symbol are called operators
• The operators are used to connect
constant and numeric variables
• The standard arithmetic operators are
S.NO Symbol Name
1 + Addition
2 - Subtraction
3 * Multiplication
4 / Division
Hierarchy of Operators
• It is the process where evaluation has to
be step by step in an order
• If the operators have equal priority then
the execution has to be carried from left to
right
• The hierarchy table is listed below
S.NO Symbol Name
1 ^ Exponent
2 *,/ Multiplication, Division
3 +,- Addition, Subtraction
String Expression
• Numeric operations can not be performed
on string variables or string constants
• The string can be connected by means of
string Concatenation
• The symbol for string concatenation is &
• Example for it is
str1= “Ten” Str2=“Thousand”
Str3=str1&str2
Ten Thousand
Library Function
• Visual Basic contains number of library
functions
• It provides quick and easy way to access
and perform operations
• The commonly used library functions are
1)ABS- Return absolute value
2)DATE - Return the current system date
3)TIME - Return the current system time
Special rule for Arithmetic expression
• The preceding a variable by a minus(-)
sign is equallent to multiplication by -1
• Except for the condition described
operations it cannot be implemented
Program Comments
• In Visual Basic (VB), comments are used
to add explanations, notes, or to
temporarily disable parts of the code.
• Comments are ignored by the compiler
and do not affect the execution of the
program.
• They are useful for documenting the code,
making it easier to understand and
maintain.
Program Comments
• Example:
Single line comment
' This is a single-line comment
Multiple line comment
' This is a comment that spans
' multiple lines. Each line needs
' to have an apostrophe at the beginning.

You might also like