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

difference between ME and MYCLASS

P: n/a
Hi. I have the following question:

Since the methods are virtual, the following code produces "Child other
stuff" - the call runs as if pasted in Child... it runs in Parent but in the
context of Child.
-------------------------------
Module Module1

Sub Main()
Dim obj As New Child()
obj.DoSomething()
End Sub

End Module
-------------------------------
Public Class Parent

Public Sub DoSomething()
OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------
Public Class Child
Inherits Parent

Public Overrides Sub OtherStuff()
MsgBox("Child other stuff")
End Sub

End Class
----------------------------------

Therefore, to avoid this, we have to change parent using MYCLASS....

-------------------------------
Public Class Parent

Public Sub DoSomething()
MyClass.OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------

I'm confused as to what exactly is the difference between ME and MYCLASS -
why doesn't ME work in this case ? ME should refer to the current object,
(Parent, in this case), correct ?

Thank you.
Alex.
Mar 10 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Radu,

An answer from a guy who seldom is beside it in this kind of questions.

http://groups.google.com/group/micro...7b6507718c418f

I hope this helps,

Cor
Mar 10 '06 #2

P: n/a

Radu wrote:
Hi. I have the following question:

Since the methods are virtual, the following code produces "Child other
stuff" - the call runs as if pasted in Child... it runs in Parent but in the
context of Child.
-------------------------------
Module Module1

Sub Main()
Dim obj As New Child()
obj.DoSomething()
End Sub

End Module
-------------------------------
Public Class Parent

Public Sub DoSomething()
OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------
Public Class Child
Inherits Parent

Public Overrides Sub OtherStuff()
MsgBox("Child other stuff")
End Sub

End Class
----------------------------------

Therefore, to avoid this, we have to change parent using MYCLASS....

-------------------------------
Public Class Parent

Public Sub DoSomething()
MyClass.OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------

I'm confused as to what exactly is the difference between ME and MYCLASS -
why doesn't ME work in this case ? ME should refer to the current object,
(Parent, in this case), correct ?


Me does refer to the current object - the object in question (obj) is a
Child! What you are seeing is overriding working as intended...

--
Larry Lard
Replies to group please

Mar 10 '06 #3

P: n/a
"Cor Ligthert [MVP]" <no************@planet.nl> schrieb
Radu,

An answer from a guy who seldom is beside it in this kind of
questions.

http://groups.google.com/group/micro...7b6507718c418f

I hope this helps,

Cor


Good to have a big archive and somebody who can search it. I would have had
no immediate answer (really). :)
Armin

Mar 10 '06 #4

P: n/a
Thank you all ! It helped !:-)))

Alex.
"Radu" <RE***************************@yahoo.com> wrote in message
news:Zq********************@b2b2c.ca...
Hi. I have the following question:

Since the methods are virtual, the following code produces "Child other
stuff" - the call runs as if pasted in Child... it runs in Parent but in
the context of Child.
-------------------------------
Module Module1

Sub Main()
Dim obj As New Child()
obj.DoSomething()
End Sub

End Module
-------------------------------
Public Class Parent

Public Sub DoSomething()
OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------
Public Class Child
Inherits Parent

Public Overrides Sub OtherStuff()
MsgBox("Child other stuff")
End Sub

End Class
----------------------------------

Therefore, to avoid this, we have to change parent using MYCLASS....

-------------------------------
Public Class Parent

Public Sub DoSomething()
MyClass.OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------

I'm confused as to what exactly is the difference between ME and MYCLASS -
why doesn't ME work in this case ? ME should refer to the current object,
(Parent, in this case), correct ?

Thank you.
Alex.

Mar 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.