SlideShare a Scribd company logo
Implementing Object Oriented Programming
In Visual Basic.NET

Pre-Assessment Questions
    •    Consider the following statements:
         • Statement A: There are two types of user interfaces, character user
             interface and (CUI) and graphical user interface (GUI).
         • Statement B: In CUI, you can interact with an application by entering
             commands.
         Which of the following is correct with respect to the above statements?
         d.  Both, Statement A and Statement B, are False.
         e.  Both, Statement A and Statement B, are True.
         f.  Statement A is True and Statement B is False.
         g.  Statement A is False and Statement B is True.




 ©NIIT                  Introduction to VB.NET            Lesson 2A / Slide 1 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Pre-Assessment Questions (Contd.)
    2. Which of the statements is false?
        •    A Windows Form is a representation of any window displayed in an
             application.
        •    Windows form properties are used to determine its appearance at
             compile time.
        •    Every Window Form is a class derived from Form class in
             System.Windows.Forms namespace.
        •    The form class is derived from the control class.




 ©NIIT                  Introduction to VB.NET            Lesson 2A / Slide 2 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Pre-Assessment Questions (Contd.)
    3.   Which of the following data types can contain values between 0 and 65535?
          •   Boolean
          •   String
          •   Char
          •   Decimal

    •    In the following code
                           Dim Result as Boolean
                           Result = X<Y
         •    The Result will have the true value
         •    The Result will have false value
         •    The Result will have either true or false value
         •    The Result will have no value



 ©NIIT                    Introduction to VB.NET                Lesson 2A / Slide 3 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Pre-Assessment Questions (Contd.)
    5. Data types like Boolean,String or Integer are
        •     Composite data types
        •     System data types
        •     Object data types
        •     Array data types




 ©NIIT                   Introduction to VB.NET        Lesson 2A / Slide 4 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Solutions to Pre-Assessment
  Questions
    •    b.
    •    b.
    •    c. Char
    •    a.
    •    b. System data type




 ©NIIT                  Introduction to VB.NET   Lesson 2A / Slide 5 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Objectives
    In this lesson, you will learn to:
         • Identify classes and objects
         • List the advantages of using classes and objects
         • Declare and import namespaces
         • Implement abstract classes in Visual Basic .NET
         • Declare structures and interfaces
         • Create and instantiate a class
         • Create an inherited form in Visual Basic .NET
         • Implement inheritance in VB .NET




 ©NIIT                   Introduction to VB.NET               Lesson 2A / Slide 6 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Understanding Object-Orientation
Concepts
    •    Visual Basic.Net is an object-oriented programming language.
    •    Visual Basic .NET supports all the four features of object-oriented
         programming.
    •    The features of object-oriented programming are
           • Encapsulation
           • Abstraction
           • Inheritance
           • Polymorphism.




 ©NIIT                      Introduction to VB.NET              Lesson 2A / Slide 7 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Understanding Classes
         •   A class is a conceptual representation of all the entities that share
             common attributes and behaviors.




 ©NIIT                     Introduction to VB.NET               Lesson 2A / Slide 8 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Object
    •    An object is an instance of a class
    •    All the objects of a class have individual copies of the attributes and share a
         common set of behaviors




 ©NIIT                      Introduction to VB.NET              Lesson 2A / Slide 9 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Advantages of Using Classes and
 Objects
    •    Maintenance of code by introducing modularity
    •    Encapsulation of internal complexities in code from end-users
    •    Reusabilty
    •    Support for a single interface to implement multiple methods




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 10 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

 Constructors
    •    Constructors are special methods that allow control over the initialization of
         objects.
    •    A shared constructor will not run more than once during a single execution of a
         program.
    •    When an instance of a class is created, the run-time environment executes the
         instance constructors.




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 11 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Destructors
    •    Destructors are special methods that are used to release the instance of a
         class from memory.
    •    There are two types of destructors in Visual Basic .NET, Finalize() and
         Dispose().
    •    The sequences in which the constructors and destructors are invoked are:
           • Shared constructor of the inherited class
           • Shared constructor of the base class
           • Instance constructor of the base class
           • Instance constructor of the inherited class




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 12 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Namespaces
    •    Namespaces enable you to avoid name collisions.
    •    Every project in Visual Basic .NET has a root namespace, which is set in the
         Property page of the project Using Namespaces.
    •    You can also organize classes using the Namespace keyword as shown below.
                Namespace CustNameSpace
                Class CustClass
                End Class
                End Namespace
    •    You can use namespaces explicitly through direct addressing or implicitly
         through the Imports statement.




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 13 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

 Abstract Classes in Visual Basic .NET
    •    Visual Basic .NET enables you to create abstract classes that contain the
         skeleton of the methods implemented by the derived class.




 ©NIIT                     Introduction to VB.NET             Lesson 2A / Slide 14 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Understanding Structures
    •     A structure is used to create user-defined data types.
    •     You can declare a structure when you want a single variable to hold multiple
         types of related data.
    •    Data can be stored in and retrieved from a structure.




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 15 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Interfaces in Visual Basic.NET
    •    Interfaces are inheritable in Visual Basic.Net.
    •    An interface defines properties, methods, and events.
    •    You declare an interface using the Interface and End Interface statements.
    •    You can declare only methods, functions, properties, and events in an
         interface.




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 16 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Interfaces in Visual Basic.NET(Contd.)
    •    An interface can inherit members from an existing interface
    •    The members of an interface consist of the declared members and the
         members inherited from its base interfaces.




 ©NIIT                    Introduction to VB.NET           Lesson 2A / Slide 17 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

 Inheritance
    •    The inheritance feature allows you to define a new class by extending an
         existing class.




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 18 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Polymorphism
    •    The concept of using operators or functions in different ways depending on
         what they are operating on is called polymorphism.




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 19 of 27
Implementing Object Oriented Programming
In Visual Basic.NET




                Demo for
   Creating a Class in Visual Basic.Net




 ©NIIT        Introduction to VB.NET   Lesson 2A / Slide 20 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Problem Statement
    •    A company called Protec Inc. needs to maintain customer information. The
         details of the customer need to be accepted through a graphical interface. The
         user interface can be either Windows Forms, Web Forms, or Console. The
         customer information also needs to be stored in relevant memory variables of
         a class. The information should also be retrieved and displayed to the user.
         The details of the customer will include CustomerID, First Name, Last
         Name, Address, Telephone number and E-mail Id.




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 21 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Solution
    •    A user interface screen is used to accept data from the user and displaying
         data to the user. A class can be used to store and retrieve data from the
         database. Perform the following steps to create a class:
           • Create a user interface.
           • Adding a class to the project
           • Write the code to store and retrieve data from the class
           •  Save and run the application




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 22 of 27
Implementing Object Oriented Programming
In Visual Basic.NET




                Demo for
         Implementing Inheritance




 ©NIIT        Introduction to VB.NET   Lesson 2A / Slide 23 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Problem Statement
    •    The company Protec Inc needs data entry forms to store information in the
         Customers, Orders, and Query Handling databases. The data entry forms
         should have a similar user interface with the Reset and Exit buttons.
         Incorporate the interface for the Order details form.




 ©NIIT                    Introduction to VB.NET          Lesson 2A / Slide 24 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Solution
    •    To create the user interface form you need to perform the following steps:
           • Create the user interface screen
           • Add code for the controls
           • Create an inherited form based on the base form
           • Add an inherited form to the project
           • Add the additional user interface control
           • Display a similar user interface
           • Add code for the inherited controls
           • Save and Execute the application




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 25 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Summary
    In this lesson, you learned that:
    • Visual Basic .NET is an object-oriented programming language
    • Classes can be added to a Visual Basic .NET project
    • An object is an instance of a class
    • Advantages of Using Classes and Objects
          • Maintenance of code
          • Encapsulation
          • Reusabilty
          • Support for a single interface to implement multiple methods
    • Constructors are special methods that allow control over the initialization of
        objects.
    • Destructors are special methods that are used to release the instance of a
        class from memory.



 ©NIIT                    Introduction to VB.NET            Lesson 2A / Slide 26 of 27
Implementing Object Oriented Programming
In Visual Basic.NET

Summary (Contd.)
    •    An important advantage of using a namespace is the prevention of a name
         collision
    •    Abstract classes are used to define the skeleton of the methods that the
         derived class can implement.
    •    A structure is used to create user-defined data types.
    •    An interface enables you to separate the definition of objects from their
         implementation so that the objects can evolve without the risk of introducing
         incompatibility in existing applications.
    •    The inheritance feature allows you to define a new class by extending an
         existing class
    •    The concept of using operators or functions in different ways depending on
         what they are operating on is called polymorphism.
    •    Interfaces and classes are inheritable in Visual Basic .NET




 ©NIIT                     Introduction to VB.NET            Lesson 2A / Slide 27 of 27

More Related Content

PPS
Vb.net session 01
PPS
Ajs 2 a
PPS
Ajs 2 c
PPTX
Object Oriented Programming Concepts
PPT
Principios de diseño oo
PPTX
Capa negocio con clases en VB
PPT
Visual Studio.NET
PPTX
Object Oriented Programming I
Vb.net session 01
Ajs 2 a
Ajs 2 c
Object Oriented Programming Concepts
Principios de diseño oo
Capa negocio con clases en VB
Visual Studio.NET
Object Oriented Programming I

Viewers also liked (19)

PPT
Concepts In Object Oriented Programming Languages
PPTX
Objects and classes in Visual Basic
PDF
Modelos de desarrollo de aplicaciones web
PDF
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
PDF
Part 3 binding navigator vb.net
PPTX
Presentation1
PPS
Vb.net session 15
PDF
Transforming the world with Information technology
PPTX
What&rsquo;s new in Visual C++
PPTX
Part 5 create sequence increment value using negative value
PPTX
Part 8 add,update,delete records using records operation buttons in vb.net
PDF
Python Tools for Visual Studio: Python na Microsoftovom .NET-u
PDF
How Not To Be Seen
PDF
Part 1 picturebox using vb.net
PPT
Introduction to XML
PPTX
Information Overload and Information Science / Mieczysław Muraszkiewicz
PPTX
Prolog -Cpt114 - Week3
PPTX
Cognitive information science
PDF
Part2 database connection service based using vb.net
Concepts In Object Oriented Programming Languages
Objects and classes in Visual Basic
Modelos de desarrollo de aplicaciones web
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
Part 3 binding navigator vb.net
Presentation1
Vb.net session 15
Transforming the world with Information technology
What&rsquo;s new in Visual C++
Part 5 create sequence increment value using negative value
Part 8 add,update,delete records using records operation buttons in vb.net
Python Tools for Visual Studio: Python na Microsoftovom .NET-u
How Not To Be Seen
Part 1 picturebox using vb.net
Introduction to XML
Information Overload and Information Science / Mieczysław Muraszkiewicz
Prolog -Cpt114 - Week3
Cognitive information science
Part2 database connection service based using vb.net
Ad

Similar to Vb.net session 03 (20)

PPS
Vb net xp_03
PPS
Vb.net session 04
PPT
VB.net
PDF
Objectoriented Programming With Visual Basicnet Michael Mcmillan
PPT
Object Oriented Programming In .Net
PDF
C# Dot net unit-3.pdf
PDF
Bt0082 visual basic
PDF
C# Summer course - Lecture 1
PDF
PDF
ptu3-harvey-m-deitel-paul-j-deitel-tem-r-nieto-contributor-paul-j-deitel.pdf
PPT
Visual studio.net
PPT
What's New in Visual Studio 2008
PPTX
.NET presentation
PDF
oopsinvb-191021101327.pdf
PPTX
Oops in vb
PDF
VB. NET ONLINE TRAINING
PDF
Oop c sharp_part_1
PPS
Vb.net session 09
PPTX
ASP.Net Technologies Part-2
Vb net xp_03
Vb.net session 04
VB.net
Objectoriented Programming With Visual Basicnet Michael Mcmillan
Object Oriented Programming In .Net
C# Dot net unit-3.pdf
Bt0082 visual basic
C# Summer course - Lecture 1
ptu3-harvey-m-deitel-paul-j-deitel-tem-r-nieto-contributor-paul-j-deitel.pdf
Visual studio.net
What's New in Visual Studio 2008
.NET presentation
oopsinvb-191021101327.pdf
Oops in vb
VB. NET ONLINE TRAINING
Oop c sharp_part_1
Vb.net session 09
ASP.Net Technologies Part-2
Ad

More from Niit Care (20)

PPS
Ajs 1 b
PPS
Ajs 4 b
PPS
Ajs 4 a
PPS
Ajs 4 c
PPS
Ajs 3 b
PPS
Ajs 3 a
PPS
Ajs 3 c
PPS
Ajs 2 b
PPS
Ajs 1 a
PPS
Ajs 1 c
PPS
Dacj 4 2-c
PPS
Dacj 4 2-b
PPS
Dacj 4 2-a
PPS
Dacj 4 1-c
PPS
Dacj 4 1-b
PPS
Dacj 4 1-a
PPS
Dacj 1-2 b
PPS
Dacj 1-3 c
PPS
Dacj 1-3 b
PPS
Dacj 1-3 a
Ajs 1 b
Ajs 4 b
Ajs 4 a
Ajs 4 c
Ajs 3 b
Ajs 3 a
Ajs 3 c
Ajs 2 b
Ajs 1 a
Ajs 1 c
Dacj 4 2-c
Dacj 4 2-b
Dacj 4 2-a
Dacj 4 1-c
Dacj 4 1-b
Dacj 4 1-a
Dacj 1-2 b
Dacj 1-3 c
Dacj 1-3 b
Dacj 1-3 a

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Approach and Philosophy of On baking technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation theory and applications.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Empathic Computing: Creating Shared Understanding
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
Teaching material agriculture food technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Electronic commerce courselecture one. Pdf
NewMind AI Weekly Chronicles - August'25 Week I
Approach and Philosophy of On baking technology
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Empathic Computing: Creating Shared Understanding
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Review of recent advances in non-invasive hemoglobin estimation
Teaching material agriculture food technology
Spectral efficient network and resource selection model in 5G networks
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Per capita expenditure prediction using model stacking based on satellite ima...

Vb.net session 03

  • 1. Implementing Object Oriented Programming In Visual Basic.NET Pre-Assessment Questions • Consider the following statements: • Statement A: There are two types of user interfaces, character user interface and (CUI) and graphical user interface (GUI). • Statement B: In CUI, you can interact with an application by entering commands. Which of the following is correct with respect to the above statements? d. Both, Statement A and Statement B, are False. e. Both, Statement A and Statement B, are True. f. Statement A is True and Statement B is False. g. Statement A is False and Statement B is True. ©NIIT Introduction to VB.NET Lesson 2A / Slide 1 of 27
  • 2. Implementing Object Oriented Programming In Visual Basic.NET Pre-Assessment Questions (Contd.) 2. Which of the statements is false? • A Windows Form is a representation of any window displayed in an application. • Windows form properties are used to determine its appearance at compile time. • Every Window Form is a class derived from Form class in System.Windows.Forms namespace. • The form class is derived from the control class. ©NIIT Introduction to VB.NET Lesson 2A / Slide 2 of 27
  • 3. Implementing Object Oriented Programming In Visual Basic.NET Pre-Assessment Questions (Contd.) 3. Which of the following data types can contain values between 0 and 65535? • Boolean • String • Char • Decimal • In the following code Dim Result as Boolean Result = X<Y • The Result will have the true value • The Result will have false value • The Result will have either true or false value • The Result will have no value ©NIIT Introduction to VB.NET Lesson 2A / Slide 3 of 27
  • 4. Implementing Object Oriented Programming In Visual Basic.NET Pre-Assessment Questions (Contd.) 5. Data types like Boolean,String or Integer are • Composite data types • System data types • Object data types • Array data types ©NIIT Introduction to VB.NET Lesson 2A / Slide 4 of 27
  • 5. Implementing Object Oriented Programming In Visual Basic.NET Solutions to Pre-Assessment Questions • b. • b. • c. Char • a. • b. System data type ©NIIT Introduction to VB.NET Lesson 2A / Slide 5 of 27
  • 6. Implementing Object Oriented Programming In Visual Basic.NET Objectives In this lesson, you will learn to: • Identify classes and objects • List the advantages of using classes and objects • Declare and import namespaces • Implement abstract classes in Visual Basic .NET • Declare structures and interfaces • Create and instantiate a class • Create an inherited form in Visual Basic .NET • Implement inheritance in VB .NET ©NIIT Introduction to VB.NET Lesson 2A / Slide 6 of 27
  • 7. Implementing Object Oriented Programming In Visual Basic.NET Understanding Object-Orientation Concepts • Visual Basic.Net is an object-oriented programming language. • Visual Basic .NET supports all the four features of object-oriented programming. • The features of object-oriented programming are • Encapsulation • Abstraction • Inheritance • Polymorphism. ©NIIT Introduction to VB.NET Lesson 2A / Slide 7 of 27
  • 8. Implementing Object Oriented Programming In Visual Basic.NET Understanding Classes • A class is a conceptual representation of all the entities that share common attributes and behaviors. ©NIIT Introduction to VB.NET Lesson 2A / Slide 8 of 27
  • 9. Implementing Object Oriented Programming In Visual Basic.NET Object • An object is an instance of a class • All the objects of a class have individual copies of the attributes and share a common set of behaviors ©NIIT Introduction to VB.NET Lesson 2A / Slide 9 of 27
  • 10. Implementing Object Oriented Programming In Visual Basic.NET Advantages of Using Classes and Objects • Maintenance of code by introducing modularity • Encapsulation of internal complexities in code from end-users • Reusabilty • Support for a single interface to implement multiple methods ©NIIT Introduction to VB.NET Lesson 2A / Slide 10 of 27
  • 11. Implementing Object Oriented Programming In Visual Basic.NET Constructors • Constructors are special methods that allow control over the initialization of objects. • A shared constructor will not run more than once during a single execution of a program. • When an instance of a class is created, the run-time environment executes the instance constructors. ©NIIT Introduction to VB.NET Lesson 2A / Slide 11 of 27
  • 12. Implementing Object Oriented Programming In Visual Basic.NET Destructors • Destructors are special methods that are used to release the instance of a class from memory. • There are two types of destructors in Visual Basic .NET, Finalize() and Dispose(). • The sequences in which the constructors and destructors are invoked are: • Shared constructor of the inherited class • Shared constructor of the base class • Instance constructor of the base class • Instance constructor of the inherited class ©NIIT Introduction to VB.NET Lesson 2A / Slide 12 of 27
  • 13. Implementing Object Oriented Programming In Visual Basic.NET Namespaces • Namespaces enable you to avoid name collisions. • Every project in Visual Basic .NET has a root namespace, which is set in the Property page of the project Using Namespaces. • You can also organize classes using the Namespace keyword as shown below. Namespace CustNameSpace Class CustClass End Class End Namespace • You can use namespaces explicitly through direct addressing or implicitly through the Imports statement. ©NIIT Introduction to VB.NET Lesson 2A / Slide 13 of 27
  • 14. Implementing Object Oriented Programming In Visual Basic.NET Abstract Classes in Visual Basic .NET • Visual Basic .NET enables you to create abstract classes that contain the skeleton of the methods implemented by the derived class. ©NIIT Introduction to VB.NET Lesson 2A / Slide 14 of 27
  • 15. Implementing Object Oriented Programming In Visual Basic.NET Understanding Structures • A structure is used to create user-defined data types. • You can declare a structure when you want a single variable to hold multiple types of related data. • Data can be stored in and retrieved from a structure. ©NIIT Introduction to VB.NET Lesson 2A / Slide 15 of 27
  • 16. Implementing Object Oriented Programming In Visual Basic.NET Interfaces in Visual Basic.NET • Interfaces are inheritable in Visual Basic.Net. • An interface defines properties, methods, and events. • You declare an interface using the Interface and End Interface statements. • You can declare only methods, functions, properties, and events in an interface. ©NIIT Introduction to VB.NET Lesson 2A / Slide 16 of 27
  • 17. Implementing Object Oriented Programming In Visual Basic.NET Interfaces in Visual Basic.NET(Contd.) • An interface can inherit members from an existing interface • The members of an interface consist of the declared members and the members inherited from its base interfaces. ©NIIT Introduction to VB.NET Lesson 2A / Slide 17 of 27
  • 18. Implementing Object Oriented Programming In Visual Basic.NET Inheritance • The inheritance feature allows you to define a new class by extending an existing class. ©NIIT Introduction to VB.NET Lesson 2A / Slide 18 of 27
  • 19. Implementing Object Oriented Programming In Visual Basic.NET Polymorphism • The concept of using operators or functions in different ways depending on what they are operating on is called polymorphism. ©NIIT Introduction to VB.NET Lesson 2A / Slide 19 of 27
  • 20. Implementing Object Oriented Programming In Visual Basic.NET Demo for Creating a Class in Visual Basic.Net ©NIIT Introduction to VB.NET Lesson 2A / Slide 20 of 27
  • 21. Implementing Object Oriented Programming In Visual Basic.NET Problem Statement • A company called Protec Inc. needs to maintain customer information. The details of the customer need to be accepted through a graphical interface. The user interface can be either Windows Forms, Web Forms, or Console. The customer information also needs to be stored in relevant memory variables of a class. The information should also be retrieved and displayed to the user. The details of the customer will include CustomerID, First Name, Last Name, Address, Telephone number and E-mail Id. ©NIIT Introduction to VB.NET Lesson 2A / Slide 21 of 27
  • 22. Implementing Object Oriented Programming In Visual Basic.NET Solution • A user interface screen is used to accept data from the user and displaying data to the user. A class can be used to store and retrieve data from the database. Perform the following steps to create a class: • Create a user interface. • Adding a class to the project • Write the code to store and retrieve data from the class •  Save and run the application ©NIIT Introduction to VB.NET Lesson 2A / Slide 22 of 27
  • 23. Implementing Object Oriented Programming In Visual Basic.NET Demo for Implementing Inheritance ©NIIT Introduction to VB.NET Lesson 2A / Slide 23 of 27
  • 24. Implementing Object Oriented Programming In Visual Basic.NET Problem Statement • The company Protec Inc needs data entry forms to store information in the Customers, Orders, and Query Handling databases. The data entry forms should have a similar user interface with the Reset and Exit buttons. Incorporate the interface for the Order details form. ©NIIT Introduction to VB.NET Lesson 2A / Slide 24 of 27
  • 25. Implementing Object Oriented Programming In Visual Basic.NET Solution • To create the user interface form you need to perform the following steps: • Create the user interface screen • Add code for the controls • Create an inherited form based on the base form • Add an inherited form to the project • Add the additional user interface control • Display a similar user interface • Add code for the inherited controls • Save and Execute the application ©NIIT Introduction to VB.NET Lesson 2A / Slide 25 of 27
  • 26. Implementing Object Oriented Programming In Visual Basic.NET Summary In this lesson, you learned that: • Visual Basic .NET is an object-oriented programming language • Classes can be added to a Visual Basic .NET project • An object is an instance of a class • Advantages of Using Classes and Objects • Maintenance of code • Encapsulation • Reusabilty • Support for a single interface to implement multiple methods • Constructors are special methods that allow control over the initialization of objects. • Destructors are special methods that are used to release the instance of a class from memory. ©NIIT Introduction to VB.NET Lesson 2A / Slide 26 of 27
  • 27. Implementing Object Oriented Programming In Visual Basic.NET Summary (Contd.) • An important advantage of using a namespace is the prevention of a name collision • Abstract classes are used to define the skeleton of the methods that the derived class can implement. • A structure is used to create user-defined data types. • An interface enables you to separate the definition of objects from their implementation so that the objects can evolve without the risk of introducing incompatibility in existing applications. • The inheritance feature allows you to define a new class by extending an existing class • The concept of using operators or functions in different ways depending on what they are operating on is called polymorphism. • Interfaces and classes are inheritable in Visual Basic .NET ©NIIT Introduction to VB.NET Lesson 2A / Slide 27 of 27