Q

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

Dig deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close