473,394 Members | 1,752 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,394 software developers and data experts.

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 1959
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Samer | last post by:
I'm writing a class that derives from ServiceBase and it says in the documentation for the constructor of ServiceBase that if you override the base class constructor, you should explicitly call it...
4
by: TS | last post by:
i have a class that i'm trying to understand that overrides BaseApplicationException's methods as follows. What i dont' understand is that i have never seen the inherit ":" on a method signature,...
17
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that...
2
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...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
10
by: Carl Fenley | last post by:
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...
6
by: bryanbabula | last post by:
I have a question about overriding i was wondering if anyone could help me with, or even suggesting a better/different way. I have no idea if this can even be done or not. I was wondering if there...
10
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that...
4
by: l.s.rockfan | last post by:
Hello, how do i have to call an inherited, templated class constructor from the initializer list of the inheriting, non-templated class constructor? example code: template<typename T>...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...

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.