473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Inherits question

YYZ
Can anyone explain how to do this, or if not, why I can't do this? <g>

I'm using (VB.Net 2003) and exposed API from a 3rd party -- it's
basically a way to get data out of the system, but not hit the DB
directly (I can't -- proprietary format). They have an object called a
Loan object -- fine and dandy, but to get most of the properties of
that loan, you have to access like this:

LoanVar.Fields("XX45").Value -- which really equates to Loan Amount,
say, but that isn't all that intuitive as you can imagine.

I'd like to Inherit this Loan class and add my own properites, such as
LoanAmount, and then in the property get, I'd just return
_Loan.Fields("XX45").Value...you know what I mean.

However, I'm hitting problems.

Public Class clsLoanFriendly
Inherits Loans.Loan
End Class

Tells me that clsLoanFriendly must declare a Sub New because its base
class does not have an accessible Sub New that can be called with no
arguments.

Okay, well, fine -- I need to actually have a real loan object to work
with anyway, so I'll make my constructor take a loan object as a
parameter. Added this to the above class:

Public Sub New(ByVal _Loan As Loans.Loan)
End Sub

Now it tells me that the first line in New must be Mybase.New() or
MyClass.New(). Then I get this error:

'Loans.Loan.Private Sub New(session As Session, dataMgr As j)' is not
accessible in this context because it is 'Private'.

Well, I have a session object, but I don't have a dataMgr object,
because that is hidden, not to mention that the entire New sub is
hidden from me.

How can I create an instance of my object and just USE an existing
object, but have my object inherit that other one? That is so
confusing.

Is the answer that I can't, but I can create an object that doesn't
inherit the Loan class, but basically duplicates its properties, and
has a Loan proerty itself that it will use to get all that data? Did
that make sense?

Matt

Nov 21 '05 #1
2 953
I think in your case, there is no need to inherit the existing class,
just make a wrapper around it. Your class would just contain an
instance of the Loans.Loan object:

Public Class clsLoanFriendly
Private _Loan As New Loans.Loan

Public Property LoanAmount As Decimal 'whatever
Get
Return _Load..Fields("XX45").Value
End Get
End Property

End Class

Nov 21 '05 #2
YYZ
Thanks -- I think I see why. I didn't want to have to re-produce the
same properties the loan object already has, but I guess I can without
too much trouble.

Thanks

Matt

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Random | last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I understand the purpose is so the developer can put classes within namespaces to essentially organize your code. And I...
2
by: Anthony Nystrom | last post by:
I am inheriting the System.Timers.Timer within my control in order to add timer functionality... I able to access both methods and Props, How do I access the tick event? Basically when this particulr...
6
by: tshad | last post by:
I am playing with Inheritance and want to make sure I understand it. I have the following Classes: ******************************************* Public Class AuthHeader:Inherits SoapHeader Public...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.