Ask the Expert

Why is VB.NET considered truly object-oriented, but VB6 isn't?

Why is VB.NET considered truly object-oriented? And why was VB 6.0 not considered to be so?
VB6 is considered "object-based" because it supports classes and objects but not inheritance. Inheritance allows a class to get fields and methods from a base class, like this sample in VB.NET:

' Base class
Class Dog
  Public Sub Bark()
    MessageBox.Show("Woof")
  End Sub
End Class

' Derived class
Class BigDog
  ' Inherit all members from base class Dog
  Inherits Dog

  ' Add new member
  Public Sub EatCat()
    MessageBox.Show("Munch")
  End Sub
End Class

Module App
  Sub Main()
    ' Create an instance of the derived class
    Dim fido As BigDog = New BigDog()

    ' Call a method from the base class
    fido.Bark()
  End Sub
End Module

Inheritance is a powerful feature of reuse, allowing you to factor shared functionality between classes into a base class, reusing them in specific derived classes. While there are other new object-oriented features new to VB.NET, inheritance, long present in languages like C++ and Java, is the key new feature in VB.NET that makes it object-oriented instead of object-based.

This was first published in November 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: