Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Me and MyClass keywords

5 views
Skip to first unread message

Erik Cruz

unread,
Mar 9, 2003, 3:48:21 PM3/9/03
to
Hi.

I am actually reading a book where several examples of classes use the Me
keyword to point to a method inside this class, like Me.Method. The MS
documentation shows the MyClass keyword to do the same thing apparently. Are
there any diferences between these two keywords or any kind of guideline to
when use one or the other?

TIA,
Erik Cruz


Jay B. Harlow [MVP - Outlook]

unread,
Mar 9, 2003, 6:05:18 PM3/9/03
to
Erik,
'Me' refers to the current object, if Method is overridden the overriding
method will be executed. 'MyClass' refers to the current class, if Method is
overridden, the method in the current class is executed.

Try the following example:

Public Module ErikCruz

Public Sub Main()
Dim x As New DerivedClass()
x.DoIt()
End Sub

End Module

Public Class BaseClass

Public Overridable Sub Method()
Debug.WriteLine("Method()", "BaseClass")
End Sub

Public Sub DoIt()
Me.Method()
MyClass.Method()
End Sub

End Class

Public Class DerivedClass
Inherits BaseClass

Public Overrides Sub Method()
Debug.WriteLine("Method()", "DerivedClass")
End Sub

End Class

Hope this helps
Jay


"Erik Cruz" <erikacf...@antares.com.br> wrote in message
news:#cafq2n5...@TK2MSFTNGP11.phx.gbl...

Armin Zingler

unread,
Mar 9, 2003, 4:31:40 PM3/9/03
to
"Erik Cruz" <erikacf...@antares.com.br> schrieb

Me and MyClass do the same, except with overridable members that have been
overriden in a derived class. In that case Me.Method calls the member in the
derived class whereas MyClass.Method calls the method of the class
containing the line.

Armin

0 new messages