How to: Inherit from a Class in Visual Basic
This example defines the Circle and Rectangle classes, which both inherit from the Shape class, and the Square class, which inherits from the Rectangle class.
Example
This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Visual Basic Language. For more information, see How to: Insert Snippets Into Your Code (Visual Basic).
Public Class Shape
' Definitions of properties, methods, fields, and events.
End Class
Public Class Circle : Inherits Shape
' Specialized properties, methods, fields, events for Circle.
End Class
Public Class Rectangle : Inherits Shape
' Specialized properties, methods, fields, events for Rectangle.
End Class
Public Class Square : Inherits Rectangle
' Specialized properties, methods, fields, events for Square.
End Class
Compiling the Code
This example requires:
A reference to the System namespace.
Note
Make sure the class from which you want to inherit is not defined as NotInheritable.
See Also
Tasks
How to: Draw an Outlined Shape