473,406 Members | 2,713 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,406 software developers and data experts.

Sub in child class

Hi!

I have a small problem...

I have a base class that has several constructors but all of them
have some parameters. It looks something like that...

Class 1

'Some properties

Sub New (Param1 as Type1)
Sub New (Param2 as Type2)
Sub New (Param3 as Type3)
Sub New (Param4 as Type4)

Now I want to declare a new clase that inherits from this one. The
reason for this class is to add some extra properties that the parent
class doesn´t need to have, so I will do something like this...

Class2 inherits Class1

'Extra properties

But now .NET ask me to declare a Sub New because the parent class
doesn´t have any constructor without parameters.... I wonder how can I
do that??? Could anyone help me????

Thank you!!!

Feb 25 '07 #1
3 997
"Vmrincon" <vm******@gmail.comwrote in news:1172390261.345595.62490
@t69g2000cwt.googlegroups.com:
Class2 inherits Class1

'Extra properties

But now .NET ask me to declare a Sub New because the parent class
doesnït have any constructor without parameters.... I wonder how can I
do that??? Could anyone help me????
VB.NET doesn't not inherit the contstructors - you need to retype all the
parameterized constructors.

i.e.:

Sub New(ByVal Parameter as string)
MyBase.New(Parameter)
End Sub

Feb 25 '07 #2

"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Vmrincon" <vm******@gmail.comwrote in news:1172390261.345595.62490
@t69g2000cwt.googlegroups.com:
> Class2 inherits Class1

'Extra properties

But now .NET ask me to declare a Sub New because the parent class
doesnït have any constructor without parameters.... I wonder how can I
do that??? Could anyone help me????

VB.NET doesn't not inherit the contstructors - you need to retype all the
parameterized constructors.

i.e.:

Sub New(ByVal Parameter as string)
MyBase.New(Parameter)
End Sub
Also, be aware that if you put in a constructor with parameters, the
default constructor (for no params) is no longer created by .net, and you
have to include one if you want one.

Robin S.
Feb 26 '07 #3
On 26 feb, 02:32, "RobinS" <Rob...@NoSpam.yah.nonewrote:
"Spam Catcher" <spamhoney...@rogers.comwrote in message

news:Xn**********************************@127.0.0. 1...


"Vmrincon" <vmrin...@gmail.comwrote in news:1172390261.345595.62490
@t69g2000cwt.googlegroups.com:
Class2 inherits Class1
'Extra properties
But now .NET ask me to declare a Sub New because the parent class
doesnït have any constructor without parameters.... I wonder how canI
do that??? Could anyone help me????
VB.NET doesn't not inherit the contstructors - you need to retype all the
parameterized constructors.
i.e.:
Sub New(ByVal Parameter as string)
MyBase.New(Parameter)
End Sub

Also, be aware that if you put in a constructor with parameters, the
default constructor (for no params) is no longer created by .net, and you
have to include one if you want one.

Robin S.- Ocultar texto de la cita -

- Mostrar texto de la cita -
Thanks a lot to both, it was very useful and now is working fine!

Mar 6 '07 #4

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

Similar topics

14
by: pablo | last post by:
Dear NewsGroupers, I am relatively new to OOP and cannet get my head around this problem. I have two classes. Class Child extends Parent. There is no constructor for the Child class. So when I...
16
by: Suzanne Vogel | last post by:
Hi, I've been trying to write a function to test whether one class is derived from another class. I am given only id's of the two classes. Therefore, direct use of template methods is not an...
4
by: Grey Plastic | last post by:
I have several classes that all keep track of static data. However, the manner that they keep track of static data is identical, and so I'm using the template<class Child> class Parent { ... };...
4
by: Bonj | last post by:
Further to my last post, I have managed to get a child window to display. But its messages are routed to the same WNDPROC that the main window's messages are routed to - what is the way of...
10
by: Peter Oliphant | last post by:
Is there a way of defining a method in a base class such that derived classes will call their own version, EVEN if the derived instance is referred to by a pointer to the base class? Note that the...
4
by: Danny Tuppeny | last post by:
Hi all, I've been trying to write some classes, so when I have a parent-child relationship, such as with Folders in my application, I don't have to remember to add a parent reference, as well as...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
7
by: msxkim | last post by:
How to execute functions in the parent class first and then functions in the child class? For example, I have a parent class with functions 'ONE' and 'TWO' and child class has a function 'THREE'. ...
10
by: Goran Djuranovic | last post by:
Hi all, Does anyone know how to declare a variable in a class to be accessible ONLY from a classes instantiated within that class? For example: ************* CODE ***************** Public...
1
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
The code below is pretty simple. Calling Talker() in the parent returns "Parent", and calling Talker() in the child returns "Child". I'm wondering how I can modify the code so that a call to the...
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
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
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...
0
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,...
0
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...

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.