473,395 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do I do MyBase.MyBase?

I realize that MyBase.MyBase is illegal, so how DO I get to the Parent of
MyBase?

In Short what is the VB equivalent of "::"?

Example:

Class Component
Inherits Hashtable

Public Shadows Sub Add()
'Extra Add stuf for this component
End Sub
End Class

~~~~~~~~~~~~~~~
Class BetterComponent
Inherits Component

Public Shadows Sub Add()
'How do I get to the Hashtable.Add and skip the "Extra Component" stuff??
End Sub
End Class
Nov 21 '05 #1
9 9216
haven't thought of that...have you tried:

if not typeof mybase is [type of object you want to deal with] then return
dim whatever as [type of object you want to deal with] = mybase
'do whatever you want to do from here

btw, the base of a base is not a "parent".

hth,

steve
"Henry Padilla" <pa******@hotmail.com> wrote in message
news:_D******************@newssvr33.news.prodigy.c om...
|I realize that MyBase.MyBase is illegal, so how DO I get to the Parent of
| MyBase?
|
| In Short what is the VB equivalent of "::"?
|
| Example:
|
| Class Component
| Inherits Hashtable
|
| Public Shadows Sub Add()
| 'Extra Add stuf for this component
| End Sub
| End Class
|
| ~~~~~~~~~~~~~~~
| Class BetterComponent
| Inherits Component
|
| Public Shadows Sub Add()
| 'How do I get to the Hashtable.Add and skip the "Extra Component"
stuff??
| End Sub
| End Class
|
|
Nov 21 '05 #2
Yes, but I don't want to simply return I want to go up the inheritance tree
to the parent class (in code it's not necessarily a parent, in class
hierarchy it is).

Henry Padilla
"steve" <a@b.com> wrote in message
news:10*************@corp.supernews.com...
haven't thought of that...have you tried:

if not typeof mybase is [type of object you want to deal with] then return
dim whatever as [type of object you want to deal with] = mybase
'do whatever you want to do from here

btw, the base of a base is not a "parent".

hth,

steve
"Henry Padilla" <pa******@hotmail.com> wrote in message
news:_D******************@newssvr33.news.prodigy.c om...
|I realize that MyBase.MyBase is illegal, so how DO I get to the Parent of
| MyBase?
|
| In Short what is the VB equivalent of "::"?
|
| Example:
|
| Class Component
| Inherits Hashtable
|
| Public Shadows Sub Add()
| 'Extra Add stuf for this component
| End Sub
| End Class
|
| ~~~~~~~~~~~~~~~
| Class BetterComponent
| Inherits Component
|
| Public Shadows Sub Add()
| 'How do I get to the Hashtable.Add and skip the "Extra Component"
stuff??
| End Sub
| End Class
|
|

Nov 21 '05 #3
I don't think this is possible, though I could be wrong.

Besides, how would this work if your class inherited from object and didn't
have a 'grandparent'?

"Henry Padilla" <pa******@hotmail.com> wrote in message
news:vy******************@newssvr17.news.prodigy.c om...
Yes, but I don't want to simply return I want to go up the inheritance tree to the parent class (in code it's not necessarily a parent, in class
hierarchy it is).

Henry Padilla
"steve" <a@b.com> wrote in message
news:10*************@corp.supernews.com...
haven't thought of that...have you tried:

if not typeof mybase is [type of object you want to deal with] then return dim whatever as [type of object you want to deal with] = mybase
'do whatever you want to do from here

btw, the base of a base is not a "parent".

hth,

steve
"Henry Padilla" <pa******@hotmail.com> wrote in message
news:_D******************@newssvr33.news.prodigy.c om...
|I realize that MyBase.MyBase is illegal, so how DO I get to the Parent of | MyBase?
|
| In Short what is the VB equivalent of "::"?
|
| Example:
|
| Class Component
| Inherits Hashtable
|
| Public Shadows Sub Add()
| 'Extra Add stuf for this component
| End Sub
| End Class
|
| ~~~~~~~~~~~~~~~
| Class BetterComponent
| Inherits Component
|
| Public Shadows Sub Add()
| 'How do I get to the Hashtable.Add and skip the "Extra Component"
stuff??
| End Sub
| End Class
|
|


Nov 21 '05 #4
ALL YOUR BASE ARE BELONG TO US!

Sorry...had to say it.

Anyway, since it looks like you are trying to do this for components you are
writing, why not just add a property to the Component class you wrote that
returns what you are looking for. If this property doesn't exist then
you'll know that you've gone as far back as you can go. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Henry Padilla" <pa******@hotmail.com> wrote in message
news:_D******************@newssvr33.news.prodigy.c om...
I realize that MyBase.MyBase is illegal, so how DO I get to the Parent of
MyBase?

In Short what is the VB equivalent of "::"?

Example:

Class Component
Inherits Hashtable

Public Shadows Sub Add()
'Extra Add stuf for this component
End Sub
End Class

~~~~~~~~~~~~~~~
Class BetterComponent
Inherits Component

Public Shadows Sub Add()
'How do I get to the Hashtable.Add and skip the "Extra Component" stuff?? End Sub
End Class

Nov 21 '05 #5
"Henry Padilla" <pa******@hotmail.com> schrieb:
I realize that MyBase.MyBase is illegal, so how DO I get to
the Parent of MyBase?


You cannot. This could lead to unintended use of a class.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #6
so what you're saying herf, is that vb doesn't define scope and interface
access correctly...since most other oop languages do give access to
traversing underlying classes...i.e. "::" ?
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:up**************@TK2MSFTNGP14.phx.gbl...
| "Henry Padilla" <pa******@hotmail.com> schrieb:
| >I realize that MyBase.MyBase is illegal, so how DO I get to
| > the Parent of MyBase?
|
| You cannot. This could lead to unintended use of a class.
|
| --
| Herfried K. Wagner [MVP]
| <URL:http://dotnet.mvps.org/>
Nov 21 '05 #7
Hi ste,

"steve" <a@b.com> schrieb:
so what you're saying herf, is that vb doesn't define scope and interface
access correctly...since most other oop languages do give access to
traversing underlying classes...i.e. "::" ?


In VB.NET, C#, and Java access is resticted to the direct base class to
prevent inconsistencies in an object's state. Consider this sample:

\\\
Public Class A
Private m_Sum As Integer

Public Overridable Sub Add(ByVal Number As Integer)
m_Sum += Number
End Sub
End Class

Public Class B
Inherits A

Private m_Checksum As Integer

Public Overrides Sub Add(ByVal Number As Integer)
MyBase.Add(Number)
m_Checksum = ...
End Sub
End Class

Public Class C
Inherits B

' Objects of type 'C' are objects of type 'B' too. 'B' guarantees
' that the checksum will be set properly. If there was a way to
' call 'A''s 'Add' method directly, the checksum set in 'B' would
' not be updated and thus the class' state would be inconsistent.
End Class
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #8
Steve,
so what you're saying herf, is that vb doesn't define scope and interface
access correctly...since most other oop languages do give access to
traversing underlying classes...i.e. "::" ? Most?

C# has the same safety net, I believe Managed C++ does also. Java does, I
don't know Smalltalk or Eiffel well enough to say, I would not be surprised
if they had the same safety net also.

Only language that I remember that allows this is C++, even there I remember
it was discouraged. I want to say one of Scott Meyers "Effective C++" books
touched on it, however I am not seeing the reference right now.
My understanding is it is enforced by the CLR itself, as knowing who your
grand base class is not really needed in OOP. You shouldn't really care or
know who your grand base class is, as your class lineage can change, both
who your inherit from & what they implement, which is why I understand
referring to specific base classes, other then your immediate parent, in C++
is frowned upon also.

My biggest concern is you might bypass code that is "Required" by the class
hierarchy, for example, if Derived class calls a GrandBase function
directly, by-passing a Base function, where the Base function is needed for
the entire hierarchy to function correctly...

IMHO: I actually see the restriction as fixing a scope & interface access
problem that older OOP languages exhibit.

Just a thought
Jay


"steve" <a@b.com> wrote in message
news:10*************@corp.supernews.com... so what you're saying herf, is that vb doesn't define scope and interface
access correctly...since most other oop languages do give access to
traversing underlying classes...i.e. "::" ?
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:up**************@TK2MSFTNGP14.phx.gbl...
| "Henry Padilla" <pa******@hotmail.com> schrieb:
| >I realize that MyBase.MyBase is illegal, so how DO I get to
| > the Parent of MyBase?
|
| You cannot. This could lead to unintended use of a class.
|
| --
| Herfried K. Wagner [MVP]
| <URL:http://dotnet.mvps.org/>

Nov 21 '05 #9
Thanks! This is exactly what I needed, and why.

Tons of help.

I am going to have to take the time and implement my base class correctly to
begin with.

Henry Padilla

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:u5**************@TK2MSFTNGP11.phx.gbl...
Hi ste,

"steve" <a@b.com> schrieb:
so what you're saying herf, is that vb doesn't define scope and interface access correctly...since most other oop languages do give access to
traversing underlying classes...i.e. "::" ?


In VB.NET, C#, and Java access is resticted to the direct base class to
prevent inconsistencies in an object's state. Consider this sample:

\\\
Public Class A
Private m_Sum As Integer

Public Overridable Sub Add(ByVal Number As Integer)
m_Sum += Number
End Sub
End Class

Public Class B
Inherits A

Private m_Checksum As Integer

Public Overrides Sub Add(ByVal Number As Integer)
MyBase.Add(Number)
m_Checksum = ...
End Sub
End Class

Public Class C
Inherits B

' Objects of type 'C' are objects of type 'B' too. 'B' guarantees
' that the checksum will be set properly. If there was a way to
' call 'A''s 'Add' method directly, the checksum set in 'B' would
' not be updated and thus the class' state would be inconsistent.
End Class
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: DraguVaso | last post by:
Hi, I have my custom Inherited DataGrid. I override the OnPaint-event to speed up things and avoid flikkering using Double Buffering. To draw the normal things of the DataGrid I have to call the...
9
by: Dennis | last post by:
When a class (myownclass) inheirits another class, how can I get an object reference to the underlyng MyBase class instance from within myownclass. The base class has a method that I want to...
1
by: Support | last post by:
Hello: I have an application that I wish to update upon login via login script but since the application is in the start-up menu, I cannot override the exe, so, I wrote a function that iterates...
5
by: TheBee | last post by:
Hello, I have seen the following routines in a class and don't understand how they work. For one, why two new() routines? Which is executed? Why not just use one routine? What does the mybase...
4
by: Sugan | last post by:
Hi, i came across custom usercontrols in VB 2005 and i'm not clear about the difference between "Me" and "MyBase". 1. What is the difference between the two keywords in a UserControl. 2....
2
by: shapper | last post by:
Hello, Could somebody tell me what is the difference between MyBase and Me? For example, should I use Page_Init(....) Handles MyBase.Init Or Page_Init(....) Handles Me.Init
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.