470,632 Members | 2,041 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,632 developers. It's quick & easy.

Overriding/Inheriting Class Constructor Methods...

I've been programming exclusively in C# for the last few years but am now
working on a project where I am required to write all code in VB.NET.

I'm trying to create a class with multiple overrideable contructor methods.
The problem is that I don't know how to even define a contructor in VB.NET,
let alone inherit the default contructor. Here is what I have so far:

Public Class AppSnippets
Private _instances As Integer
Private _appProcess As Process
Private _sysProcesses As Process()

Sub New()
Me._instances = 0
End Sub

Sub New(ByVal appProcess As Process)
MyBase.New()
Me._appProcess = appProcess
End Sub
End Class

I don't really know if "Sub New()" is the constructor. If it is, I need the
constructor that accepts the Process parameter to call the previous
constructor first. Any help and clarification would be greatly appreciated.

carl
Nov 21 '05 #1
1 1810
Carl,
| I don't really know if "Sub New()" is the constructor.
Yes "Sub New" is the constructor.
| If it is, I need the
| constructor that accepts the Process parameter to call the previous
| constructor first. Any help and clarification would be greatly
appreciated.
You can use MyBase.New to call your parent's constructor.

You can use MyClass.New to call one of your constructors.

For example:

| Sub New(ByVal appProcess As Process)
| MyClass.New()
| Me._appProcess = appProcess
| End Sub
| End Class

Hope this helps
Jay

"Carl Fenley" <clfenley-X-@-X-wcpci.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
| I've been programming exclusively in C# for the last few years but am now
| working on a project where I am required to write all code in VB.NET.
|
| I'm trying to create a class with multiple overrideable contructor
methods.
| The problem is that I don't know how to even define a contructor in
VB.NET,
| let alone inherit the default contructor. Here is what I have so far:
|
| Public Class AppSnippets
| Private _instances As Integer
| Private _appProcess As Process
| Private _sysProcesses As Process()
|
| Sub New()
| Me._instances = 0
| End Sub
|
| Sub New(ByVal appProcess As Process)
| MyBase.New()
| Me._appProcess = appProcess
| End Sub
| End Class
|
| I don't really know if "Sub New()" is the constructor. If it is, I need
the
| constructor that accepts the Process parameter to call the previous
| constructor first. Any help and clarification would be greatly
appreciated.
|
| carl
|
|
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Samer | last post: by
17 posts views Thread by Bob Weiner | last post: by
2 posts views Thread by Jim Heavey | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.