473,666 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9245
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******@hotma il.com> wrote in message
news:_D******** **********@news svr33.news.prod igy.com...
|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.supe rnews.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******@hotma il.com> wrote in message
news:_D******** **********@news svr33.news.prod igy.com...
|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******@hotma il.com> wrote in message
news:vy******** **********@news svr17.news.prod igy.com...
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.supe rnews.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******@hotma il.com> wrote in message
news:_D******** **********@news svr33.news.prod igy.com...
|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******@hotma il.com> wrote in message
news:_D******** **********@news svr33.news.prod igy.com...
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******@hotma il.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...sin ce 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******** ******@TK2MSFTN GP14.phx.gbl...
| "Henry Padilla" <pa******@hotma il.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...sin ce 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(Numb er)
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...sin ce 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.supe rnews.com... so what you're saying herf, is that vb doesn't define scope and interface
access correctly...sin ce 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******** ******@TK2MSFTN GP14.phx.gbl...
| "Henry Padilla" <pa******@hotma il.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******** ******@TK2MSFTN GP11.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...sin ce 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(Numb er)
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
2422
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 MyBase.OnPain(pe). But in my opinion it doesn't seem to be painted on the buffer. Everything works fine, but I think it should work better if my MyBase.OnPaint also painted in my buffer. Am I wrong? And how should I do this? I kind of need to...
9
2101
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 utilize in myownclass but the method is private and can't be inheirited. I need to utilize that base class method. -- Dennis in Houston
1
1179
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 through all the instances of this application and kills the one instance that is not itself and then shuts itself down. The idea is that in a batch file , I could run <applicationname> shutdown which would create a new instance of the...
5
2315
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 do in this case? Bit confusing! :) Thanks '<remarks/> Public Sub New() MyBase.New() Me.Url =
4
11874
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. Even if they are different, is there any harm in using it interchangeably?
2
4192
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
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8783
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8552
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.