Re: Parent object question
- From: "Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 23 Jul 2007 11:37:24 -0400
I would think New should still work as expected. If you want to be sure,
post some code and we'll all have a look at it and see if we can figure out
why it doesn't seem to be working as you expect.
Rob
"Phil Hunt" <phung1010(remove this)@hotmail.com> wrote in message
news:uC6iRnTzHHA.3908@xxxxxxxxxxxxxxxxxxxxxxx
Thanks. That's what I ended up doing. There is other quirk also. The New
keyword on the does not work as I expected. But I can get around. THanks
"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23U72ACAzHHA.2312@xxxxxxxxxxxxxxxxxxxxxxx
If you want your OrderItem to be aware of the Order, typically you would
implement a property name either Order or Parent,
and then whenever you create an OrderItem, you would assign the parent
Order object to the property in the child class.
The trick here is that this creates a circular reference, which VB will
fail to handle. If you simply do something like this:
Set cOrder = Nothing
...there will still be a reference to cOrder held by cOrderItem, which
will create a memory leak. Your cOrderItem objects will not be cleaned
up properly. In order to clean them up properly, you would have to
specifically set the child's property to Nothing before setting the child
or any parent objects to Nothing.
Rob
"MikeD" <nobody@xxxxxxxxxxx> wrote in message
news:esgK4W5yHHA.3536@xxxxxxxxxxxxxxxxxxxxxxx
"Phil H" <phung1010@xxxxxxxxxxx> wrote in message
news:%23Rkr4g0yHHA.3696@xxxxxxxxxxxxxxxxxxxxxxx
I have the following 2 classical Classes setup:
Order class:
Private status as string
...
Private m_objOrderItem As New classOrderItem
...
...
Property Get objOrderItem() As classOrderItem
Set objOrderItem = m_objOrderItem
End Property
=================
After I create many new Order objects, is there a easy way to access
the correct parent Order from the OrderItem object ?
The conventional approach would be for your Order object to have an
OrderItems collection, to which you add all OrderItem objects (for that
order only). What you seem to be asking is the exact opposite of that.
--
Mike
Microsoft MVP Visual Basic
.
- Follow-Ups:
- Re: Parent object question
- From: Phil Hunt
- Re: Parent object question
- References:
- Parent object question
- From: Phil H
- Re: Parent object question
- From: MikeD
- Re: Parent object question
- From: Robert Morley
- Re: Parent object question
- From: Phil Hunt
- Parent object question
- Prev by Date: Re: decouple gui from bo
- Next by Date: Re: decouple gui from bo
- Previous by thread: Re: Parent object question
- Next by thread: Re: Parent object question
- Index(es):
Relevant Pages
|