473,805 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inheriting constructors in vb.net

Books online says that constructors are not inherited in vb.net (grrr - why
not?)

I have a series of classes that share the same constructors and find myself
cutting and pasting when i make changes to them ... a sure sign of something
badly wrong.

How do you all deal with sharing this code?
I can't seem to find any sort of #include feature
Is there some option?

thanks!

brad
Nov 20 '05 #1
4 1978
> I have a series of classes that share the same constructors and find
myself
cutting and pasting when i make changes to them ... a sure sign of something badly wrong.
How do you all deal with sharing this code?
I can't seem to find any sort of #include feature
Is there some option?
you can call the base class constructor by means of the MyBase class. Here'
an example:
public class TheBase
public sub New()

end sub
end class

public class TheDerived : Inherits TheBase
public sub New()
MyBase.New()
end sub
end class
thanks!
HTH
brad


--
..A [Microsoft MVP .NET]
UGIdotNET - User Group Italiano .NET
http://www.ugidotnet.org
Read my blog at: http://www.ugidotnet.org/4.blog
Nov 20 '05 #2
> I have a series of classes that share the same constructors and find
myself
cutting and pasting when i make changes to them ... a sure sign of something badly wrong.
How do you all deal with sharing this code?
I can't seem to find any sort of #include feature
Is there some option?
you can call the base class constructor by means of the MyBase class. Here'
an example:
public class TheBase
public sub New()

end sub
end class

public class TheDerived : Inherits TheBase
public sub New()
MyBase.New()
end sub
end class
thanks!
HTH
brad


--
..A [Microsoft MVP .NET]
UGIdotNET - User Group Italiano .NET
http://www.ugidotnet.org
Read my blog at: http://www.ugidotnet.org/4.blog
Nov 20 '05 #3

"Andrea Saltarello [MVP][UGIdotNET]" <pa************ *********@phase it.com>
wrote in message news:OM******** ******@TK2MSFTN GP11.phx.gbl...
I have a series of classes that share the same constructors and find myself
cutting and pasting when i make changes to them ... a sure sign of

something
badly wrong.
How do you all deal with sharing this code?
I can't seem to find any sort of #include feature
Is there some option?

you can call the base class constructor by means of the MyBase class.

Here' an example:
public class TheBase
public sub New()

end sub
end class

public class TheDerived : Inherits TheBase
public sub New()
MyBase.New()
end sub
end class


that's what i'm doing now - but I have 10 subclasses and ~8 different
constructors
so i'm cutting and pasting the mybase stuff 10 times...
ugly
Nov 20 '05 #4

"Andrea Saltarello [MVP][UGIdotNET]" <pa************ *********@phase it.com>
wrote in message news:OM******** ******@TK2MSFTN GP11.phx.gbl...
I have a series of classes that share the same constructors and find myself
cutting and pasting when i make changes to them ... a sure sign of

something
badly wrong.
How do you all deal with sharing this code?
I can't seem to find any sort of #include feature
Is there some option?

you can call the base class constructor by means of the MyBase class.

Here' an example:
public class TheBase
public sub New()

end sub
end class

public class TheDerived : Inherits TheBase
public sub New()
MyBase.New()
end sub
end class


that's what i'm doing now - but I have 10 subclasses and ~8 different
constructors
so i'm cutting and pasting the mybase stuff 10 times...
ugly
Nov 20 '05 #5

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

Similar topics

3
2527
by: sureshsundar007 | last post by:
Hi all, I'm trying to inherit the SimpleWorkerRequest class but cant able to do so. I'm getting an error called "System.Web.Hosting.SimpleWorkerRequest.SimpleWorkerRequest()' is inaccessible due to its protection level" I tried my dervived class with public,internal and private
2
6925
by: SpotNet | last post by:
Hi Newsgroup, Reconstructing my common dialog assembly using C# 2.0 .NET Framework 2.0. I have the following; public class FileDialogBase: System.Windows.Forms.FileDialog { //No constructor seem to do me any justice.... }
2
1627
by: Jim Heavey | last post by:
I amd playing around with inheritance a little in VB.Net If I create a new class which inherits from ListViewItem and I am only wanting to override the ToString Method. In this situation, If I only override the "ToString" method, I find that I only have a single constructor. Do I have to clone all of the constructor methods and then execute the MyBase.New(....) methods for each of those constructors? If I am inheriting all methods and...
0
226
by: Brad Langhorst | last post by:
Books online says that constructors are not inherited in vb.net (grrr - why not?) I have a series of classes that share the same constructors and find myself cutting and pasting when i make changes to them ... a sure sign of something badly wrong. How do you all deal with sharing this code? I can't seem to find any sort of #include feature Is there some option?
4
1200
by: elziko | last post by:
I would like to do the following: Create a class that inherits from a usercontrol. Then add a control to the designer Call this new class ClassA. Many controls I need will start off like this so I'd like to create all controls form now on from this base control. So, for example, I inherit from this base control and add the further controls required to form this part of my UI. Call this ClassB
2
4857
by: TCook | last post by:
Hello All, First I tried to inherit from the TabPageCollection class but received the following error message: No overload for method 'TabPageCollection' takes '0' arguments I also tried implementing a custom collection and the tabpages show up during design time in the properties but the tabs are never visible during design or runtime. The collection contains classes inherited from a tabpage
2
2246
by: Christof Warlich | last post by:
Hi, I'd like to define a class that should behave as much as posible like std::string, but that has some small additional property: class ExtendedString: public std::string { public: void someExtendedFunctionality(void) {} };
0
1048
by: Jack Jackson | last post by:
There is a class (over which I have no control) that has no public constructors - new instances are created via a Static function. I would like to modify the behavior of one of the methods of this class, but I can't inherit from it because it has no public constructors. Is there any other way to modify the behavior of one of the class's methods?
4
1296
by: Thomas Wittek | last post by:
Hi! I'm relatively new to Python, so maybe there is an obvious answer to my question, that I just didn't find, yet. I've got quite some classes (from a data model mapped with SQL-Alchemy) that can be instatiated using kwargs for the attribute values. Example: class User(object): def __init__(self, name=None):
4
1701
by: AalaarDB | last post by:
struct base { int x, y, z; base() {x = 0; y = 0; z = 0;}; base(int x1, int y1, int z1) {x = x1; y = y1; z = z1;}; }; struct intermediate1 : public virtual base {}; struct intermediate2 : public virtual base
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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
10607
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
10359
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...
0
10104
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9182
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...
1
7645
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4317
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

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.