In VB.NET, the specialization relationship is implemented using a principle called inheritance. This is not the only way to implement specialization, but it is the most common and most natural way to implement this relationship.
Saying that ListBox inherits from (or derives from) Window indicates that it specializes Window. Window is referred to as the base class, and ListBox is referred to as the derived class. That is, ListBox derives its characteristics and behaviors from Window and then specializes to its own particular needs.
In VB.NET, you create a derived class by adding the
Inherits keyword after the name of the derived
class, followed by the name of the base
Public Class ListBox Inherits Window
Or you might combine these two lines onto one as follows:
Public Class ListBox : Inherits Window
This code declares a new class, ListBox, that derives from Window.
You can read the
Inherits keyword as
The derived class inherits all the members of the base class, both member variables and methods. These members can be treated just as if they were created in the derived class, as shown in Example 11-1.
Example 11-1. Deriving a new class
Option Strict On Imports System Public Class Window ' constructor takes two integers to ' fix location on the console Public Sub New(ByVal top As Integer, ByVal left As Integer) Me.top = top Me.left = left End Sub 'New ' simulates drawing the window Public Sub DrawWindow( ) Console.WriteLine("Drawing ...