Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inherit class in VB.NET

Tags:

vb.net

I'm pretty new to VB and I want to inherit from DataGridView, I use something like

Public Class DataGridViewEx Inherits DataGridView
End Class

But compiler generates an error as End of statement expected pointing to Inherits DataGridView. What is wrong and how I should do this?

like image 471
BigBoss Avatar asked Dec 09 '12 16:12

BigBoss


People also ask

How do you inherit a class in Visual Basic?

In visual basic, it's not possible to inherit the base class constructors in the derived class and the accessibility of other members of the base class also depends on the access modifiers which we used to define those members in the base class.

How inherit another class in VB net?

Visual Basic introduces the following class-level statements and modifiers to support inheritance: Inherits statement — Specifies the base class. NotInheritable modifier — Prevents programmers from using the class as a base class. MustInherit modifier — Specifies that the class is intended for use as a base class only.

How do we inherit a class?

Inheritance is a feature or a process in which, new classes are created from the existing classes. The new class created is called “derived class” or “child class” and the existing class is known as the “base class” or “parent class”. The derived class now is said to be inherited from the base class.

How inheritance is achieved in VB net?

What is Inheritance in VB.Net? Inheritance can be defined as the feature of the programming language that offers an opportunity to make the use of functions that are already defined in a base class. In Inheritance, the base class is the class which passes its functionality to other class.


1 Answers

Put it in the next line:

Public Class DataGridViewEx 
    Inherits DataGridView
End Class

MSDN: Inherits

If used, the Inherits statement must be the first non-blank, non-comment line in a class or interface definition. It should immediately follow the Class or Interface statement.

like image 124
Tim Schmelter Avatar answered Oct 12 '22 23:10

Tim Schmelter