Why Isn't MyBase.New() Working Here? 
Author Message
 Why Isn't MyBase.New() Working Here?

Why Isn't MyBase.New() Working Here?

Hello Everyone.

Please help.

I have some code, excerpted below, that contains a default constructor and
a parameterized constructor.

I am trying to "do the right thing" and call MyBase.New() in the
parameterized constructor, which, at least in this is, is exactly what I
want to do.

However, if I set a breakpoint on the declaration of the parameterized
constructor and then step through the code from the there line by line, I
notice that control flow does not jump to the default constructor when then
MyBase.New() line executes.

Why?

(The side-effect of this is that a class member object never gets
initialized and I NEED to make sure that it get initialized.)

What am I missing?

Please advise.

Thank you.

--Mark.

#Region " Class Members "
    'This class member must exist at all times.
    Private m_objUtility As Worker
    Private m_objInvoiceSummary As InvoiceSummary
#End Region

#Region " Properties "

Public ReadOnly Property Utility() As Worker
    Get
        Return m_objUtility
    End Get
End Property

Public ReadOnly Property InvoiceSummary() As InvoiceSummary
    Get
        Return m_objInvoiceSummary
    End Get
End Property

#End Region

#Region " Constructors "

'This method is the default constructor.
Public Sub New()
    m_objUtility = New Worker()
End Sub

'The method is a parameterized constructor.
Public Sub New(ByRef thisInvoiceSummary As InvoiceSummary)
    ''''THIS CALL SHOULD RUN
    ''''THE DEFAULT CONSTRUCTOR
    ''''AND INITIALIZE THE CLASS
    ''''MEMBER OBJECT.
    MyBase.New()
    m_objInvoiceSummary = thisInvoiceSummary
    CreateInvoiceSummaryTable(thisInvoiceSummary)
End Sub



Sat, 07 May 2005 02:29:07 GMT  
 Why Isn't MyBase.New() Working Here?

Quote:
> Why Isn't MyBase.New() Working Here?

Because it calls the constructor of the base class. You want to call the
constructor in the same class:

    MyClass.New()

Armin



Sat, 07 May 2005 02:47:22 GMT  
 Why Isn't MyBase.New() Working Here?
Oooohhhhhhhh!

I get it.

Thank you very much, Armin.



Quote:
> Why Isn't MyBase.New() Working Here?

Because it calls the constructor of the base class. You want to call the
constructor in the same class:

    MyClass.New()

Armin



Sat, 07 May 2005 03:10:12 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Why isn't my code working?

2. Why isn't my filter working in the Common Dialog ShowOpen Function

3. why isn't this api working?

4. why isn't this api code working?

5. Why isn't this working??

6. Why isn't this working?

7. why isn't this working?

8. Why isn't this working

9. Why isn't this working?

10. Why isn't this working?

11. why isn't this working

12. Why isn't any API code working

 

 
Powered by phpBB® Forum Software