Library tutorials & articles
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.
Related articles
Related discussion
-
How can I execute server-side function using asp.net Ontextchanged orJavascript onchange?
by mamoru0916 (0 replies)
-
Excel Oledb Engine and VB.NET
by anand.lv (1 replies)
-
we search the company in India for program creation under the order
by anand.lv (1 replies)
-
VB.NET Windows: Getting Windows Message from external class without overriding WndProc
by CallMeLaNN (0 replies)
-
String size limit and array upperbound limit
by Akhtar Hussain (2 replies)
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum)
Events coming up
-
Dec
6
Developing AJAX Web Applications with Castle Monorail
London, United Kingdom
Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!
application level
Error in the article "New Object-Oriented Capabilities in VB.NET - Events"
Derived classes cannot raise base class events in VB.Net. Handle them sure, but not raise them - even if they are declared public. In order to achieve this handle the base class event and raise a derived class event instead.
B.
While it is true that VB.NET cannot directly raise events in base classes from a derived class, there is an easy workaround. BTW, in C# you can simply call an event in a base class like: base.onMyEventName(EventArgs e).
But in VB.NET you cannot use MyBase.EventName() at all. But the workaround is an easy one.
1) In the base class add an overridable sub that simply raises an event defined in the base class.
Public MustInherit Class MyClass
Protected Event MyEventName(ByVal e as EventArgs)
Protected Overridable Sub OnMyEventName(ByVal e as EventArgs)
Raiseevent MyEventName(e)
End Sub
End Class
2) In the derived class make a call to the overridable method: Me.OnMyEventName(New EventArgs). It's really just that easy. Do it all the time.
Have Fun....
Error in the article "New Object-Oriented Capabilities in VB.NET - Events"
Derived classes cannot raise base class events in VB.Net. Handle them sure, but not raise them - even if they are declared public. In order to achieve this handle the base class event and raise a derived class event instead.
B.
How do we read the attributes in an XML file using a DataSet?
boig,
I needed the same thing and found that I have it working using the Public Shared declaration on the class that contains my XMLDocument and the functions to access the document. This makes the class available across the application.
Public Shared oTriggers As Triggers
If you only need the XMLDocument I would give that a try.
Hope this helps.
I need a global variable; but it is a "XmlDocument" object, does anybody know how do I have to create it, and how to initialitze it?
If you set a shared property of a user class in a ASP.NET application, how long wil the value last? Application level? Session level? Page level? Well i was actually looking for an answer to that when i got here... useful article anyway even though it doesn't answer my question...
This thread is for discussions of New Object-Oriented Capabilities in VB.NET.