By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,422 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,422 IT Pros & Developers. It's quick & easy.

The difference between MyClass and Me as it pertains to classes

P: n/a
What is the difference between using MyClass and Me inside
of inherited classes?
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Iced Crow,
MyClass refers specifically to the current class. Me refers to the current
object.

For example if I have:

Class BaseClass
Public Overridable Sub f1()
debug.writeline("BaseClass", "f1")
End Sub
End Class

Class Class1 : Inherits BaseClass
Public Sub DoSomething()
MyClass.F1()
Me.F1()
End Sub
Public Overrides Sub f1()
debug.writeline("Class1", "f1")
End Sub
End Class

Class Class2 : Inherits Class1
Public Overrides Sub f1()
debug.writeline("Class2", "f1")
End Sub
End Class

Dim c as New Class2
c.DoSomething()

The call to MyClass.F2 in Class1 will execute Class1.F1 although Class2
overrides it. As MyClass looks specifically at that class.
The call to Me.F2 in Class1 will execute Class2.F1 as Class2 overrides it,
as Me looks at the object itself.

Hope this helps
Jay

"Iced Crow" <ch********@aol.com> wrote in message
news:07****************************@phx.gbl...
What is the difference between using MyClass and Me inside
of inherited classes?

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.