473,804 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1995
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******** ********@tk2msf tngp13.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
6833
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 in the constructor of your derived class. As far as I know a constructor cannot be overridden only overloaded, is this a mistake or have I been mislead.
4
1463
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, only on a class declaration. Can you explain what is going on here. Is it that the implementation of the method that is overriding the base's method simply uses the base's implementation all along (if so, why override the method to begin with?)?
17
2922
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 when the Poodle is upcast to the Dog (in its wildest dreams) it then says "bow wow" where the bernard always says "woof" (see code). Basically, it appears that I'm hiding the poodle's speak method from everything except the poodle. Why would I...
2
1626
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...
18
4753
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 class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
10
529
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 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...
6
27818
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 was anyway to force a class to call a base class's method that it is overriding? Almost the same way you have to call a base class's constructor if it has arguments. (example ** assuming the Person class's constructor has (string FirstName) as...
10
105210
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 make use of these methods assume that the methods obey these contracts so it is necessary to ensure that if your classes override these methods, they do so correctly. In this article I'll take a look at the equals and hashCode methods. ...
4
5561
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> class A
0
9591
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
10343
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...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9166
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
7631
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
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.