Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating base class with Sub New(with parameters)
Message
From
01/10/2004 06:28:59
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Creating base class with Sub New(with parameters)
Miscellaneous
Thread ID:
00947856
Message ID:
00947856
Views:
117
Ok, so I have this class that I want some other classes to inherit from.
Public MustInherit Class MyParentClass
    Protected WithEvents _Caller As MyBaseClass

    Public Sub New(ByVal oObj As MyBaseClass)
        If Not oObj Is Nothing Then
            _Caller = oObj
        End If
    End Sub
End Class
Then, there is a class that derives from the parent:
Public Class MyChildClass
    Inherits MyParentClass
    Public Sub run(ByVal parms As Object)
        Dim str As String
        ...
    End Sub
End Class
And the call in code would ideally look something like this
Dim oClass As MyChildClass = New MyChildClass(MyCaller)
As you can see, I want the Sub New() of derived class objects to take a caller object as a parameter in order to set a reference to it. However, this isn't working that easy as I am getting a message:

'MyChildClass' must declare a 'Sub New()' because its base class 'MyParentClass' does not have an accessible 'Sub New' that can be called with no arguments.'

Is there a way to get this done without having to declare Sub New in each of the derived classes?

Thanks
Danijel
Next
Reply
Map
View

Click here to load this message in the networking platform