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

Inherited functions not visible?

P: n/a
Hi,

I've created a MasterForm which all my forms in my project must derive from.

In my MasterForm, I've overloaded the New event with this code:
Public Sub New(ByVal SomeText As String)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call
'Do something with SomeText...
End Sub
I've add an inherited form MyForm which inherits from my MasterForm.

Here's my question....

Why can't I write Dim MyNewForm As New MyForm("Just a test") ?

The overloaded New(ByVal SomeText As String) is not visible when I'm
creating a new MyForm (which inherits from MasterForm).

What am I doing wrong?

Thanks.

M O J O

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> schrieb
Hi,

I've created a MasterForm which all my forms in my project must
derive from.

In my MasterForm, I've overloaded the New event with this code:
Public Sub New(ByVal SomeText As String)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent()
call 'Do something with SomeText...
End Sub
I've add an inherited form MyForm which inherits from my
MasterForm.

Here's my question....

Why can't I write Dim MyNewForm As New MyForm("Just a test") ?

The overloaded New(ByVal SomeText As String) is not visible when I'm
creating a new MyForm (which inherits from MasterForm).

What am I doing wrong?


Constructors are not inherited. They can not be inherited because the
constructor is tied to the specific instance of a class. In other words, the
constructors determine how you can create an instance of the class they
belong to.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
M O J O
In addition to Armin's comments.

Constructors are never inherited! As you may have the case where the derived
class requires a different set of constructors then the base class, hence it
is left up to the designer of the derived class to implement the correct set
of constructors for the derived class.

Basically its (IMHO) "cleaner" to need to add the constructors you need to
the derived class, rather then have some syntax to remove constructors that
may have been inherited and you don't need, especially when a new
constructor could be added to the base, and you missed "removing" that
constructor from the derived class...

You sample reminds me that the base form needs to call the base form's
InitializeComponent, and the derived form needs to call the derived form's
InitializeComponent! Which further highlights why constructors are never
inherited.

Hope this helps
Jay

"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I've created a MasterForm which all my forms in my project must derive from.
In my MasterForm, I've overloaded the New event with this code:
Public Sub New(ByVal SomeText As String)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call
'Do something with SomeText...
End Sub
I've add an inherited form MyForm which inherits from my MasterForm.

Here's my question....

Why can't I write Dim MyNewForm As New MyForm("Just a test") ?

The overloaded New(ByVal SomeText As String) is not visible when I'm
creating a new MyForm (which inherits from MasterForm).

What am I doing wrong?

Thanks.

M O J O

Nov 20 '05 #3

P: n/a
Thanks!

So it's not me going crazy! :o))

M O J O

Armin Zingler wrote:
"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> schrieb
Hi,

I've created a MasterForm which all my forms in my project must
derive from.

In my MasterForm, I've overloaded the New event with this code:
Public Sub New(ByVal SomeText As String)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent()
call 'Do something with SomeText...
End Sub
I've add an inherited form MyForm which inherits from my
MasterForm.

Here's my question....

Why can't I write Dim MyNewForm As New MyForm("Just a test") ?

The overloaded New(ByVal SomeText As String) is not visible when I'm
creating a new MyForm (which inherits from MasterForm).

What am I doing wrong?

Constructors are not inherited. They can not be inherited because the
constructor is tied to the specific instance of a class. In other words, the
constructors determine how you can create an instance of the class they
belong to.


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.