user avatar
user avatar
user avatar
Mathieu Guindon
  • Member for 9 years, 10 months
  • Last seen more than a week ago
Stats
7,721
reputation
53k
reached
28
answers
35
questions
Loading…
About

About Me

Me is a reserved name (you can't have a variable by that name) that refers to something that can only exist at run-time in a procedure's scope: the current object. Under the hood, when you make a member call to DoSomething against a Class1 object, the call goes essentially like this:

Set obj = New Class1
Class1.DoSomething obj

This means DoSomething looks like this in VBA:

Public Sub DoSomething()
End Sub

But VBA sees it like this:

Public Sub DoSomething(ByVal Me As Class1)
End Sub

That makes Me an implicit locally-scoped ByVal parameter of type Class1, and inside the DoSomething scope it holds a reference to whatever object the caller is currently using.


Moderator (retired) on Code Review Stack Exchange, 2015-2021
Microsoft MVP (Office Apps & Services), 2018-2022

Rubberduck
rubberduckvba.com | twitter | github | wordpress

2
gold badges
27
silver badges
51
bronze badges
275
Score
25
Posts
40
Posts %
76
Score
17
Posts
27
Posts %
57
Score
13
Posts
21
Posts %
42
Score
6
Posts
10
Posts %
31
Score
5
Posts
8
Posts %
29
Score
11
Posts
17
Posts %
Top posts
View all questions and answers