IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
VB.Net
Search VB.Net Group:

Advanced
-Collapse +Expand VB.Net To/From
To/FromCODEGuides
-Collapse +Expand VB.Net Store
PRESTWOODSTORE

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingVB.NetOOP   Print This     
  From the November 2008 Issue of Prestwood eMag
 
VB.Net OOP:
VB.Net Inheritance (Inherits ParentClass)
 
Posted 16 years ago on 10/26/2008 and updated 1/23/2009
VB.Net Code Snippet:
 A flashcard from our VB.Net Flashcards Library
 A code snippet from our VB.Net Code Snippets Page
 Tags: VB.Net , Inheritance

KB101397

General Info: Inheritance

The concept of a class makes it possible to define subclasses that share some or all of the main class characteristics. This is called inheritance. Inheritance also allows you to reuse code more efficiently. In a class tree, inheritance is used to design classes vertically. (You can use Interfaces to design classes horizontally within a class tree.) With inheritance, you are defining an "is-a" relationship (i.e. a chow is-a dog). Analysts using UML call this generalization where you generalize specific classes into general parent classes.

VB.Net Inheritance

VB.Net uses the Inherits keyword followed by the parent class name. If you do not include Inherits, your class inherits from System.Object.

Syntax Example:

In the following example, a terminator T-600 is-an android. 

Public Class Android
End Class
 
Public Class T-600
  Inherits Android
End Class

When designing classes and creating (instanciating) objects in VB.Net, you use the Inherits keyword to signify what class to inherit from. VB.Net supports single inheritance so you have to specify a single class (you cannot specify more than one parent class).

Class Scope Specifiers

Private, Protected, and Public Members

In most OOP languages, private, protected, and public members have a specific scope:

  • Private = Used by the defining class only. Invisible outside of the class except by friendly classes.
  • Protected = Used by the defining class and descendant classes only (plus friendly classes).
  • Public = Visible wherever its class can be referenced.

More Info

Definition:  Inheritance

Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1105A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile


Linked Certification Question(s)

The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

Intermediate

1 Intermediate Level Question

Question #1: Multiple Choice

What is the correct syntax for class inheritance?

Answer:
1. 
Public Class Android
End Class
 
Public Class T-600 : Android
End Class
2. 
Public Class Android
End Class
 
Public Class T-600 As Android
End Class
3. 
Public Class Android
End Class
 
Public Class T-600
  Inherits Android
End Class
4. 
Public Class Android
End Class
 
Public Class T-600(Android)
End Class
5. 
Public Class Android
End Class
 
Public Class T-600
  Parent Android
End Class

 KB Article #101397 Counter
13104
Since 10/26/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]