Share via


Me, My, MyBase, and MyClass in Visual Basic

The apparent similarities between Me, My, MyBase, and MyClass in Visual Basic may confuse you if you are coming to the concepts for the first time. This page describes each of these entities in order to distinguish between them.

Me

The Me keyword provides a way to refer to the specific instance of a class or structure in which the code is currently executing. Me behaves like either an object variable or a structure variable referring to the current instance. Using Me is particularly useful for passing information about the currently executing instance of a class or structure to a procedure in another class, structure, or module.

My

The My feature provides easy and intuitive access to a number of .NET Framework classes, enabling the Visual Basic user to interact with the computer, application, settings, resources, and so on.

MyBase

The MyBase keyword behaves like an object variable referring to the base class of the current instance of a class. MyBase is commonly used to access base class members that are overridden or shadowed in a derived class. MyBase.New is used to explicitly call a base class constructor from a derived class constructor.

MyClass

The MyClass keyword behaves like an object variable referring to the current instance of a class as originally implemented. MyClass is similar to Me, but all method calls on it are treated as if the method were NotOverridable.

See Also

Concepts

Development with My

Inheritance Basics

Reference

MyBase

MyClass

Me