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. 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 is used in these contexts: