New Object-Oriented Capabilities in VB.NET

Summary

Visual Inheritance

So far we’ve been discussing the new OO features of the VB.NET language, with a large focus on inheritance.

However, VB.NET also supports visual inheritance for Windows Forms. This means that we can create a Windows Forms form, and then inherit from that form to create other forms that have the same layout, controls, and behaviors. This topic was covered in more detail in Chapter 4.

We can also use inheritance to create our own versions of Windows Forms controls. For instance, we may want to create an enhanced TextBox control that performs some specialized validation of the input data. This can be accomplished through inheritance by creating a subclass of the original TextBox control class and enhancing it as needed. This was also covered in Chapter 4.

The same is true of Web Forms controls, where we can take an existing Web Forms control and create a subclass. Our subclass can override existing functionality or add new functionality as required. See Chapter 6 for more on this.

Summary

Of all the features requested for the new version of VB, perhaps the most common was true inheritance. As we’ve seen in this chapter, not only does VB.NET provide us with inheritance, but we also gain a number of other important new features and enhancements.

VB.NET dramatically enhances the way we create and work with multiple interfaces, making them far easier to use than in the past. Additionally, through the support for events as being a formal part of an interface, we can now express all the elements of an interface through this mechanism – methods, properties, and events.

For most people, the elimination of reference counting in favor of a garbage collection scheme for object termination will be a non-issue. However, it is important to be aware of this change, since an object that maintains a reference to expensive system resources will need some mechanism other than its termination to release those valuable resources.

Overall, VB.NET dramatically enhances our ability to create OO applications with VB, while preserving the vast majority of the features we have become used to in previous versions of the language.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The generation of random numbers is too important to be left to chance.” - Robert R. Coveyou