A Quick Inheritance Example

Create a new VB .NET Windows Application project and name it InheritanceTest. Add a button to the form and go to the code window. In the code, add the following class. Make sure that you add it outside the class for the form!

Public Class Person

   Dim msName, msAddress As String

   Property Name() As String
      Get
         Name = msName
      End Get
      Set(ByVal Value As String)
         msName = Value
      End Set
   End Property

   Property Address() As String
      Get
         Address = msAddress
      End Get
      Set(ByVal Value As String)
         msAddress = Value
      End Set
   End Property

   Public Function Enroll() As Boolean
      'check class enrollment
      'if enrollment < max. class size then
      'enroll person in class
      Enroll = True
   End Function
End Class

This code creates a Person class with two properties, ...

Get A Programmer's Introduction to Visual Basic® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.