Share via


MeĀ 

Provides a way to refer to the specific instance of a class or structure in which the code is currently executing.

Remarks

The Me keyword 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. For example, suppose you have the following procedure in a module.

Sub ChangeFormColor(FormName As Form)
   Randomize()
   FormName.BackColor = Color.FromArgb(Rnd() * 256, Rnd() * 256, Rnd() * 256)
End Sub

You can call this procedure and pass the current instance of the Form class as an argument using the following statement.

ChangeFormColor(Me)

The Me keyword can be used in these contexts:

Class Statement

Structure Statement

See Also

Reference

MyBase
MyClass

Concepts

Object Variable Assignment