Results 1 to 8 of 8

Thread: [RESOLVED] What Keyword is needed in a base class to FORCE child classes to call Mybase.New()?

  1. #1

    Thread Starter
    Fanatic Member MetalKid's Avatar
    Join Date
    Aug 2005
    Location
    Green Bay, Wisconsin
    Posts
    534

    Resolved [RESOLVED] What Keyword is needed in a base class to FORCE child classes to call Mybase.New()?

    I can't remember what keyword is needed to force people to call the parent's New. Any help would be appreciated!

  2. #2

    Thread Starter
    Fanatic Member MetalKid's Avatar
    Join Date
    Aug 2005
    Location
    Green Bay, Wisconsin
    Posts
    534

    Re: What Keyword is needed in a base class to FORCE child classes to call Mybase.New()?

    Or am I just crazy and there is nothing out there that does this?

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: What Keyword is needed in a base class to FORCE child classes to call Mybase.New()?

    Um, in the child class constructor, it would be mybase.new....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: What Keyword is needed in a base class to FORCE child classes to call Mybase.New()?

    If the base class has no default constuctor (parameterless) then the subclass is required to call the parameterized constructor.

  5. #5

    Thread Starter
    Fanatic Member MetalKid's Avatar
    Join Date
    Aug 2005
    Location
    Green Bay, Wisconsin
    Posts
    534

    Re: What Keyword is needed in a base class to FORCE child classes to call Mybase.New()?

    Well, this is what I'm asking. My base class has a Sub New(), and I have code in it that I want to run no matter what class inherits it. Now, I know the child class can call MyBase.New() in its constructor, but VB.NET doesn't force this. Is there a way to force the child class to always call MyBase.New() when it inherits from that base class?

  6. #6

    Thread Starter
    Fanatic Member MetalKid's Avatar
    Join Date
    Aug 2005
    Location
    Green Bay, Wisconsin
    Posts
    534

    Re: What Keyword is needed in a base class to FORCE child classes to call Mybase.New()?

    Nevermind... It looks like MyBase.New() automatically gets called due to the Inherits keyword. I guess programmers don't need to explicitly call that function in order for it to run.

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [RESOLVED] What Keyword is needed in a base class to FORCE child classes to call Mybase.New()?

    I dunno... when ever I create a new form, I always see a MyBase.New() called in there.... even though it Inherits Windows.Form.....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Fanatic Member MetalKid's Avatar
    Join Date
    Aug 2005
    Location
    Green Bay, Wisconsin
    Posts
    534

    Re: [RESOLVED] What Keyword is needed in a base class to FORCE child classes to call Mybase.New()?

    Well, I think C# requires that, but VB.NET doesn't. Of course, I'm also using VB .Net 2005 August CTP...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width