G
Guest
I have a base (MustInherit/abstact) class that looks like:
Public MustInherit Class BaseClass
End Class
Then I have three derived classes:
Public Class DerivedA
Inherits BaseClass
End Class
Public Class DerivedB
Inherits BaseClass
End Class
Public Class DerivedC
Inherits BaseClass
End Class
Since each of these classes are handled differently I have three Shared
Overloaded Sub's
Public Shared Sub BuildMessage(ByVal Product As DerivedA)
End Sub
Public Shared Sub BuildMessage(ByVal Product As DerivedB)
End Sub
Public Shared Sub BuildMessage(ByVal Product As DerivedC)
End Sub
When I compile I get:
Overload resolution failed because no accessible 'BuildMessage' can be
called with these arguments:
'Public Shared Sub BuildMessage(Product As DerivedA)':
Option Strict On disallows implicit conversions from 'BaseClass' to
'DerivedA'.
'Public Shared Sub BuildMessage(Product As DerivedB)':
Option Strict On disallows implicit conversions from 'BaseClass' to
'DerivedB'.
'Public Shared Sub BuildMessage(Product As DerivedC)':
Option Strict On disallows implicit conversions from 'BaseClass' to
'DerivedC'.
This type of thing is done all the time with C# and C++. Since I am
relatively new to VB I am not sure how to get around this error. I would
rather not globally turn 'Option Strict' off, but if that is the only way
then I guess I must. Suggestions?
Thank you.
Kevin
Public MustInherit Class BaseClass
End Class
Then I have three derived classes:
Public Class DerivedA
Inherits BaseClass
End Class
Public Class DerivedB
Inherits BaseClass
End Class
Public Class DerivedC
Inherits BaseClass
End Class
Since each of these classes are handled differently I have three Shared
Overloaded Sub's
Public Shared Sub BuildMessage(ByVal Product As DerivedA)
End Sub
Public Shared Sub BuildMessage(ByVal Product As DerivedB)
End Sub
Public Shared Sub BuildMessage(ByVal Product As DerivedC)
End Sub
When I compile I get:
Overload resolution failed because no accessible 'BuildMessage' can be
called with these arguments:
'Public Shared Sub BuildMessage(Product As DerivedA)':
Option Strict On disallows implicit conversions from 'BaseClass' to
'DerivedA'.
'Public Shared Sub BuildMessage(Product As DerivedB)':
Option Strict On disallows implicit conversions from 'BaseClass' to
'DerivedB'.
'Public Shared Sub BuildMessage(Product As DerivedC)':
Option Strict On disallows implicit conversions from 'BaseClass' to
'DerivedC'.
This type of thing is done all the time with C# and C++. Since I am
relatively new to VB I am not sure how to get around this error. I would
rather not globally turn 'Option Strict' off, but if that is the only way
then I guess I must. Suggestions?
Thank you.
Kevin