19849091-vb-net-tutorial-3
TRANSCRIPT
-
8/18/2019 19849091-VB-net-tutorial-3
1/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide " o# $%
Objectives
In t&is lesson' (ou )ill learn to*
Identi#( t&e ad+antages o# using classes and objects
Identi#( t&e use o# structures
Identi#( t&e use o# abstract classes in Visual Basic .NET
Identi#( t&e use o# inter#aces
Identi#( t&e di##erences bet)een inter#aces and abstract
classes
Identi#( t&e use o# assemblies
Identi#( t&e application &ierarc&( in Visual Basic .NET
,reate and instantiate a class
-
8/18/2019 19849091-VB-net-tutorial-3
2/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide o# $%
Objectives (Contd.)
eclare and import namespaces
,reate an in&erited #orm in Visual Basic .NET
-
8/18/2019 19849091-VB-net-tutorial-3
3/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide o# $%
Object-orientation in Visual Basic .NETVisual Basic .NET*
!upports t&e #our pillars o# object-oriented programming*
Encapsulation bstraction
In&eritance
Pol(morp&ism 0ses prede#ined classes pro+ided b( t&e .NET
1rame)or2.
llo)s (ou to create (our o)n classes.
!upports structures t&at enable (ou to create (our o)ndata t(pe ata dapter.
lso &as #ull support #or inter#aces.
-
8/18/2019 19849091-VB-net-tutorial-3
4/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $ o# $%
Classes and Objects
,lass
Is a conceptual representation o# all t&e entities t&at
s&are common attributes and be&a+iors.
e#ines t&e attributes and be&a+iors o# all t&e instances
o# t&e class.
Object Is an instance o# a class.
3as indi+idual cop( o# t&e common attributes and s&are
a common set o# be&a+iors.
-
8/18/2019 19849091-VB-net-tutorial-3
5/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide 4 o# $%
Advantages of Using Classes and Objects
5aintenance o# code b( introducing modularit(.
Encapsulation o# internal comple6ities in code #rom
end-users.
7euse o# code across applications.
!upport #or a single inter#ace to implement multiple
met&ods.
-
8/18/2019 19849091-VB-net-tutorial-3
6/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide 8 o# $%
tructure
Is a generali9ation o# a user-de#ined data t(pe :0T;.
Is created )&en (ou )ant a single +ariable to &old multiple
t(pes o# related data.
Is declared b( using t&e Structure and End Structure
statements.
,an also include procedures as its members.
!upports e+ent &andling.
-
8/18/2019 19849091-VB-net-tutorial-3
7/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide < o# $%
tructure (Contd.)
=ou can speci#( t&e accessibilit( o# t&e data members )it&in
a structure b( using one o# t&e #ollo)ing access modi#iers*
Public
Protected
1riend
Protected 1riend
Pri+ate
-
8/18/2019 19849091-VB-net-tutorial-3
8/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide % o# $%
tructure (Contd.)
!toring and accessing data )it&in/#rom a structure*
Is done b( using t&e .:dot; notation.
E6ample
Dim ord1 As order_details
ord1.Inv_no = "I0001“
ord1.Ord_dt = #5/31/2001#I ord1.Inv_no = "" !"en
s$%o&'()lease enter t"e Invoice num*er(+
End I
-
8/18/2019 19849091-VB-net-tutorial-3
9/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide > o# $%
Classes Vs. tructure
#e) similarities bet)een a class and a structure are*
Bot& can &a+e members' including constructors'
properties' constants' and e+ents.
Bot& can implement inter#aces.
Bot& can &a+e s&ared constructors' )it& or )it&out
parameters.
-
8/18/2019 19849091-VB-net-tutorial-3
10/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide "? o# $%
Classes Vs. tructure (Contd.)
#e) dissimilarities bet)een a class and a structure are
gi+en in t&e #ollo)ing table*
Class Structure
A class is inheritable from other existing
classes.
A structure is not inheritable.
A class can have instance constructors
with or without parameters.
A structure can have instance
constructors only if they take parameters.
A class is a reference type. A structure is a value type.
The members of a class can be
initialized within the class declaration.
The members of a structure cannot be
initialized within the structure declaration.
-
8/18/2019 19849091-VB-net-tutorial-3
11/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide "" o# $%
Abstract Class
,ontains t&e s2eleton o# t&e met&ods t&at deri+ed
classes can implement.
E6ample
)u*lic ustIn"erit ,lass Em-loeeDetails
)u*lic ustOverride Su* Annual_Salar'%al m AsInte$er+
End ,lass
)u*lic ,lass Em-_details
In"erits Em-loeeDetails
)u*lic Overrides Su* Annual_Salar'%al m As Inte$er+ rite t"e im-lementation code "ere
End Su* End ,lass
-
8/18/2019 19849091-VB-net-tutorial-3
12/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide " o# $%
Abstract Class (Contd.)
=ou can create an abstract class b( using t&e
ustIn"erit 2e()ord in t&e class de#inition.
=ou can de#ine a met&od in an abstract class using t&eustOverride 2e()ord.
=ou must implement t&e met&od in deri+ed classes using
t&e Overrides 2e()ord.
I# a deri+ed class o# an abstract class does not implement
one o# t&e abstract met&ods o# t&e abstract base class' it
also must be declared )it& ustIn"erit 2e()ord as it
also becomes an abstract class.
-
8/18/2019 19849091-VB-net-tutorial-3
13/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide " o# $%
!nterface
,an contain onl( t&e declaration o# members suc& asproperties' met&ods' and e+ents.
Enables (ou to separate t&e de#inition o# objects #rom t&eirimplementation so t&at t&e objects can e+ol+e )it&out t&eris2 o# introducing incompatibilit( in e6isting applications.
Is declared b( using t&e Interace and End Interace statements.
E6ample
Interace Iorderdetails
)ro-ert ,ustame'+ As Strin$
Su* -date,ustStatus'+Event -date_,om-lete'+
End Interace
-
8/18/2019 19849091-VB-net-tutorial-3
14/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide "$ o# $%
!nterface (Contd.)
!tatements are )u*lic b( de#ault.
,an in&erit members #rom an e6isting inter#ace b( using t&e
In"erits statement.
E6ample
Interace alidate_,ust
Su* alidate_,ustname'+
End InteraceInterace Iorderdetails In"erits
alidate_,ust
)ro-ert ,ustame'+ As Strin$
Su* -date,ustStatus'+Event -date_,om-lete'+
End Interace
-
8/18/2019 19849091-VB-net-tutorial-3
15/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide "4 o# $%
"ifferences Bet#een !nterfaces and Abstract Classes
Inter#aces represent t&e &ig&est le+el o# abstraction in
object-oriented programming because all t&e met&ods in an
inter#ace do not &a+e an( implementation.
In contrast' t&e abstract classes t&at are created b( using
t&e ustIn"erit 2e()ord mig&t contain a met&od
t&at &as a bod(.
-
8/18/2019 19849091-VB-net-tutorial-3
16/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide "8 o# $%
Asse$blies
,onsist o# a single or multiple e6ecutable and resource #iles
t&at contain in#ormation necessar( #or deplo(ing and
maintaining t&e +ersions o# an application.
Enable users to use an application e+en )&en t&e
application is not registered in t&e !(stem 7egistr(' since*
E+er( assembl( is sel#-describing t&roug& metadata.
E+er( re#erence to a t(pe is scoped b( an assembl(
re#erence.
.NET can automaticall( locate re#erenced assemblies.
-
8/18/2019 19849091-VB-net-tutorial-3
17/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide "< o# $%
Asse$blies (Contd.)
T&e application &ierarc&( in Visual Basic .NET is illustrated
in t&e #ollo)ing #igure*
-
8/18/2019 19849091-VB-net-tutorial-3
18/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide "% o# $%
Asse$blies (Contd.)
,onsist o# mani#est' module' and t(pe.
5ani#est is t&e descriptor o# t&e assembl(. It contains
in#ormation on*
T&e name and +ersion number o# t&e assembl(.
Its interaction )it& ot&er assemblies.
T&e t(pes e6posed b( t&e assembl(.
!ecurit( permissions re@uired b( t&e assembl(.
-
8/18/2019 19849091-VB-net-tutorial-3
19/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide "> o# $%
Asse$blies (Contd.)
5odule is eit&er a LL or EAE. It contains*
,ompiled code in intermediate languages.
5etadata associated )it& t&e module.
Optionall(' t&e mani#est #or t&e assembl(.
T(pe in Visual Basic .NET can be a class or a structure t&at
contain data and logic a##ecting t&e data.
-
8/18/2019 19849091-VB-net-tutorial-3
20/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide ? o# $%
%ust a &inute' . &( is a structure called a composite data t(peC
. Identi#( t&e s(ntactical error in t&e #ollo)ing declaration o#
an inter#ace*Interace I-roductdetails
)ro-ert )roductame'+ As Strin$
Su* -date,ustStatus'+
4a*el1.!e&t=!"is is a Su* )rocedure to c"ec6 t"e status o
t"e -roduct7
End Su*
Event -date_com-lete'+
End Interace
. 3o) are inter#aces di##erent #rom abstract classesC
-
8/18/2019 19849091-VB-net-tutorial-3
21/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide " o# $%
roble$ tate$ent .".*
T&e call centers at ia9 Telecommunications need to maintain
customer in#ormation to respond to customer @ueries. T&e
details o# t&e customers need to be accepted t&roug& a
grap&ical inter#ace. T&e customer in#ormation also needs to
be stored in t&e rele+ant memor( +ariables. T&e details o# t&e
customers essentiall( include customer id' customerDs #irst
name' customerDs last name' address' telep&one number' and
customerDs e-mail id.
-
8/18/2019 19849091-VB-net-tutorial-3
22/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide o# $%
Tas+ ,istIdenti#( t&e data t&at needs to be captured.
Identi#( t&e t(pe o# user inter#ace to be used.
Identi#( t&e user inter#ace components to accept data.
Identi#( t&e mec&anism to store data in t&e rele+antmemor( +ariables.
Identi#( t&e memor( +ariables to store customerin#ormation.
Per#orm appropriate steps to create t&e user inter#acescreen' as designed.
dd a class to t&e project.rite t&e code to add t&e rele+ant members to a class.
-
8/18/2019 19849091-VB-net-tutorial-3
23/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide o# $%
Tas+ ,ist (Contd.)
rite t&e code to instantiate t&e class.
rite t&e code to store and retrie+e data #rom t&e class.
!a+e t&e application.
7un t&e application.
-
8/18/2019 19849091-VB-net-tutorial-3
24/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $ o# $%
Tas+ * !dentif t/e data t/at needs to be ca0tured.
7esult
s per t&e problem statement' t&e data t&at needs to be
captured is* ,ustomer I
1irst Name
Last Name ddress
Telep&one number
E-mail I
-
8/18/2019 19849091-VB-net-tutorial-3
25/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide 4 o# $%
Tas+ 1 !dentif t/e t0e of user interface to be used.T&ere are t&ree t(pes o# user inter#aces*
indo)s 1orms
eb 1orms ,onsole
7esult*
!ince t&e re@uirement stated in t&e problem statement is #ora grap&ical user inter#ace' (ou )ill use indo)s 1orms
as t&e user inter#ace.
-
8/18/2019 19849091-VB-net-tutorial-3
26/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide 8 o# $%
Tas+ !dentif t/e user interface co$0onents toacce0t data.
uidelines #or designing a user inter#ace*
Identi#( t&e name and title o# t&e #orm.
Identi#( t&e controls re@uired.
7ecommend suitable pre#i6es t&at (ou can use #or
+arious controls*Object Prefix Example
Form frm frmCustomerdetail
s
Label lbl lblCustomerame
Text!ox txt txtCustomerame
!utton cmd cmd"ave
-
8/18/2019 19849091-VB-net-tutorial-3
27/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide < o# $%
Tas+ !dentif t/e user interface co$0onents toacce0t data. (Contd.)
7esult*
Based on t&e guidelines' set t&e #orm name as#rm,ustomerdetails and t&e te6t' )&ic& is t&e title o# t&e
#orm' as ,ustomer etails.
To ma2e a user-#riendl( inter#ace' add label controls to
displa( static te6t #or t&e customer details* ,ustomer I'1irst Name' Last Name' ddress' Telep&one number' and
Email I. Ne6t' add te6t bo6 controls to accept in#ormation
#or eac& customer detail. In addition' add t)o buttons
to sa+e and retrie+e t&e data stored #or t&e customer.
-
8/18/2019 19849091-VB-net-tutorial-3
28/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide % o# $%
Tas+ 2 !dentif t/e $ec/anis$ to store data inrelevant $e$or variables.
In Visual Basic .NET' (ou can store data in rele+ant
memor( +ariables b( implementing t&e object oriented‑
#eatures. T&e object-oriented #eatures enable (ou to create
a class t&at &as member +ariables to store data during
data processing.
7esult*!ince t&e re@uirement stated in t&e problem statement is to
store customer in#ormation in t&e rele+ant memor(
+ariables' a class called ,ustomer needs to be created
t&at )ill &a+e member +ariables to store customerin#ormation.
-
8/18/2019 19849091-VB-net-tutorial-3
29/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide > o# $%
Tas+ 3 !dentif t/e $e$or variables to storecusto$er infor$ation.
7esult*
!ince t&e customer in#ormation is to be stored in t&emember +ariables o# t&e ,ustomer class' (ou need to add
+ariables to t&e ,ustomer class. Eac& member
+ariable o# t&e ,ustomer class s&ould store a particular
t(pe o# customer detail. =ou must ensure t&at t&e data
t(pe o# a member +ariable matc&es t&e data t(pe o# t&e
customer detail stored b( t&e +ariables. !i6 member
+ariables need to be declared in t&e ,ustomer class.
O
-
8/18/2019 19849091-VB-net-tutorial-3
30/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide ? o# $%
Tas+ 4 erfor$ a00ro0riate ste0s to create t/e userinterface screen5 as designed.
Tas+ 6 Add a class to t/e 0roject.
Namespace
Is a naming sc&eme t&at &elps (ou organi9e t&e classesa+ailable in an application so t&at t&e( can be easil(#ound.
Enables (ou to a+oid name collisions. Is created using t&e Namespace 2e()ord.
E+er( project in Visual Basic .NET &as a rootnamespace' )&ic& is set in t&e Propert( page o# t&e
project. =ou can use namespaces e6plicitl( t&roug& direct
addressing or implicitl( t&roug& t&e Imports statement.
I l ti Obj t i t d P i i
-
8/18/2019 19849091-VB-net-tutorial-3
31/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide " o# $%
Tas+ 7 8rite t/e code to add t/e relevant $e$bersto a class.
Tas+ 9 8rite t/e code to instantiate t/e class.
Object Li#etime
T&e li#e o# an object begins )&en an instance o# a class
is created using t&e e8 2e()ord.
T&e li#e o# an object ends a#ter it goes out o# scope or isset to ot"in$ and is released b( t&e .NET
1rame)or2.
,onstructors
re o# t)o t(pes' s&ared constructors and instance
constructors.
I l ti Obj t i t d P i i
-
8/18/2019 19849091-VB-net-tutorial-3
32/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide o# $%
/ared Constructors0sed to initiali9e t&e +ariables t&at are declared )it& t&eS"ared 2e()ord.
3a+e an implicit )u*lic access.
ill not run more t&an once during a single e6ecution o# aprogram.
E6ample
)u*lic ,lass class1
S"ared & As Inte$er
S"ared Su* e8'+
& = 10
End Su*
End ,lass
I l ti Obj t i t d P i i
-
8/18/2019 19849091-VB-net-tutorial-3
33/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide o# $%
!nstance Constructors0sed to initiali9e +ariables t&at are declared )it& Dim')u*lic' )rivate' 9riend' )rotected' and )rotected 9riend 2e()ords.
llo) access to s&ared +ariables.
E6ample
)u*lic ,lass class1
Dim & As Inte$er
)u*lic Su* e8'+
& = 10
End Su*
End ,lass
Implementing Object oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
34/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $ o# $%
"estructors
re special met&ods t&at are used to release an instance o#
a class #rom memor(. T&ere are t)o t(pes o# destructors in
Visual Basic .NET*
9inali:e' +
Dis-ose' +
Implementing Object oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
35/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide 4 o# $%
:inali;e ( ) "estructor Is called #rom t&e class to )&ic& it belongs or #rom t&e
deri+ed classes.
Is called a#ter t&e last re#erence to an object is released#rom t&e memor(.
Is automaticall( in+o2ed b( t&e .NET 1rame)or2 to destro(
objects in t&e memor(.
Implementing Object oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
36/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide 8 o# $%
"is0ose ( ) "estructor Is called to release a resource' suc& as a database
connection' as soon as t&e object using suc& a resource is
no longer in use.
Is not called automaticall(' and (ou must e6plicitl( call it
#rom a client application.
Implementing Object oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
37/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide < o# $%
Tas+ *
-
8/18/2019 19849091-VB-net-tutorial-3
38/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide % o# $%
roble$ tate$ent .".1
T&e call centers at ia9 Telecommunications need data entr(
#orms to store in#ormation in t&e ,ustomers' Orders' Fuer(
3andling' Products' and Emplo(ees databases. E+er( data
entr( #orm s&ould &a+e a similar user inter#ace )it& t&e 7esetand E6it buttons. Incorporate t&e inter#ace #or t&e Order details
#orm.
Implementing Object-oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
39/48
Implementing Object-oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide > o# $%
Tas+ ,ist Identi#( t&e mec&anism to pro+ide a similar user inter#ace.
Identi#( t&e user inter#ace components to accept data.
Identi#( t&e additional user inter#ace controls.
,reate t&e user inter#ace screen' as designed.
dd code #or t&e controls.
Per#orm t&e prere@uisite tas2 to implement t&e planned
mec&anism.
Implement t&e mec&anism' as planned.
Implementing Object-oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
40/48
Implementing Object oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $? o# $%
Tas+ ,ist (Contd.) dd t&e additional user inter#ace control' as planned.
Per#orm t&e tas2s to displa( a similar user inter#ace.
dd code #or t&e in&erited controls.
!a+e t&e application.
7un t&e application.
Implementing Object-oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
41/48
Implementing Object oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $" o# $%
Tas+ * !dentif t/e $ec/anis$ to 0rovide a si$ilaruser interface.
In Visual Basic .NET' (ou can create a base #orm in a
project and t&en create a #orm t&at in&erits #rom t&e base
#orm.
7esult*
!ince t&e re@uirement stated in t&e problem statement is to
create a similar user inter#ace #or all t&e data entr( #orms'(ou can create a base #orm t&at &as t&e 7eset and E6it
buttons on it. =ou can t&en in&erit all t&e data entr( #orms
#rom t&e base #orm.
Implementing Object-oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
42/48
Implementing Object oriented Programming in
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $ o# $%
Tas+ 1 !dentif t/e user interface co$0onents toacce0t data.
7esult*
!ince all t&e data entr( #orms must &a+e t&e 7eset and E6it
buttons' (ou need to design t&e user inter#ace o# t&e
base #orm )it& t&ese t)o buttons. =ou also need to speci#(
t&e Te6t and Name properties o# t&e #orm and t&e buttons
on t&e #orm.
Implementing Object-oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
43/48
p e e t g Object o e ted og a g
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $ o# $%
Tas+ !dentif t/e additional user interfacecontrols.
7esult*
!ince t&e data entr( #orms #or t&e ,ustomers' Orders'
Fuer( 3andling' Products' and Emplo(ees databases must
&a+e +arious controls to accept data #rom a user' (ou
need to identi#( additional controls t&at need to be included
in t&e deri+ed #orms. In t&e current scenario' (ou )ill onl(
create a base #orm )it& t)o buttons and in&erit t&e #ormOrderGdetails.
Implementing Object-oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
44/48
p g j g g
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $$ o# $%
Tas+ 2 Create t/e user interface screen5 asdesigned.
Tas+ 3 Add code for t/e controls.
Tas+ 4 erfor$ t/e 0rere>uisite tas+ to i$0le$entt/e 0lanned $ec/anis$.
Tas+ 6 !$0le$ent t/e $ec/anis$5 as 0lanned.
Tas+ 7 Add t/e additional user interface control5 as0lanned.
Implementing Object-oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
45/48
p g j g g
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $4 o# $%
Tas+ 9 erfor$ t/e tas+s to dis0la a si$ilar userinterface.
Tas+ *
-
8/18/2019 19849091-VB-net-tutorial-3
46/48
p g j g g
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $8 o# $%
roble$ tate$ent ..*T&e call centers o# ia9 Telecommunications need to &a+e
data entr( #orms to store in#ormation in t&e ,ustomers'
Orders' Fuer( 3andling' Product' and Emplo(ees databases.
E+er( data entr( #orm s&ould &a+e a similar user inter#ace )it&t&e dd' 5odi#(' elete' 7eset and E6it buttons. Incorporate
t&e inter#ace #or t&e Fuer( 3andling data entr( #orm.
Implementing Object-oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
47/48
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $< o# $%
u$$arIn t&is lesson' (ou learned t&at*
Visual Basic .NET is an object-oriented programming
language. structure is used to create user-de#ined data t(pes.
ata can be stored in and retrie+ed #rom a structure.
bstract classes are used to de#ine t&e s2eleton o# t&emet&ods t&at t&e deri+ed class can implement.
Inter#aces are in&eritable in Visual Basic .NET.
,lasses can be added to a Visual Basic .NET project.
Implementing Object-oriented Programming in
-
8/18/2019 19849091-VB-net-tutorial-3
48/48
Visual Basic .NET
©NIIT Implementing Object-oriented Programming in VB .NET/Lesson /!lide $% o# $%
u$$ar (Contd.) n assembl( contains in#ormation necessar( #or deplo(ing
and maintaining t&e +ersions o# an application.
n assembl( consists o# mani#est' module' and t(pe. n important ad+antage o# using a namespace is t&e
pre+ention o# a name collision.
,lasses can be in&erited in a Visual Basic .NET project.