Hi,
I have a situation where I have a Parent Object (Company) which has several
public properties. The Company Object also creates an Employees object
which has its ow set of functions and properties. I am trying to figure out
how to access the Parent properties from the child object.
Simplified example:
Class Company
Public ReadOnly Property Employees() As Employees
Public Sub New(ByVal CompanyID As String)
_CompanyID = CompanyID
_Employees = New Employees(_CompanyID)
End Sub
Get
Return _Employees
End Get
End Property
Public ReadOnly Property CompanyID() As String
Get
Return _CompanyID
End Get
End Property
Public Property DateLow() As Date
Get
Return _DateLow
End Get
Set(ByVal Value As Date)
_DateLow = Value
End Set
End Property
Public Property DateHi() As Date
Get
Return _DateHi
End Get
Set(ByVal Value As Date)
_DateHi = Value
End Set
End Property
End Class
Class Employees
>>>How do I get at the CompanyID Property of the Company Parent Object??
End Class
Thanks,
Ron 8 6545
Add a reference to the Company in the Employees class. When you create the
Employees class, fill in reference with the parent that created it.
Robin S.
------------------------------
"RSH" <wa*************@yahoo.comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
Hi,
I have a situation where I have a Parent Object (Company) which has
several public properties. The Company Object also creates an Employees
object which has its ow set of functions and properties. I am trying to
figure out how to access the Parent properties from the child object.
Simplified example:
Class Company
Public ReadOnly Property Employees() As Employees
Public Sub New(ByVal CompanyID As String)
_CompanyID = CompanyID
_Employees = New Employees(_CompanyID)
End Sub
Get
Return _Employees
End Get
End Property
Public ReadOnly Property CompanyID() As String
Get
Return _CompanyID
End Get
End Property
Public Property DateLow() As Date
Get
Return _DateLow
End Get
Set(ByVal Value As Date)
_DateLow = Value
End Set
End Property
Public Property DateHi() As Date
Get
Return _DateHi
End Get
Set(ByVal Value As Date)
_DateHi = Value
End Set
End Property
End Class
Class Employees
>>>>How do I get at the CompanyID Property of the Company Parent Object??
End Class
Thanks,
Ron
How exactly do I do that from a childs perspective?
Thanks
Ron
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:2e******************************@comcast.com. ..
Add a reference to the Company in the Employees class. When you create the
Employees class, fill in reference with the parent that created it.
Robin S.
------------------------------
"RSH" <wa*************@yahoo.comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
>Hi,
I have a situation where I have a Parent Object (Company) which has several public properties. The Company Object also creates an Employees object which has its ow set of functions and properties. I am trying to figure out how to access the Parent properties from the child object.
Simplified example: Class Company Public ReadOnly Property Employees() As Employees Public Sub New(ByVal CompanyID As String)
_CompanyID = CompanyID
_Employees = New Employees(_CompanyID)
End Sub Get
Return _Employees
End Get
End Property
Public ReadOnly Property CompanyID() As String
Get
Return _CompanyID
End Get
End Property
Public Property DateLow() As Date
Get
Return _DateLow
End Get
Set(ByVal Value As Date)
_DateLow = Value
End Set
End Property
Public Property DateHi() As Date
Get
Return _DateHi
End Get
Set(ByVal Value As Date)
_DateHi = Value
End Set
End Property
End Class
Class Employees
>>>>>How do I get at the CompanyID Property of the Company Parent Object??
End Class Thanks,
Ron
You don't. If the child doesn't have the information, it doesn't. You
have to put the information there from the parents perspective.
You can add a reference to the company as a parameter to the constructor
of the Employees collection.
RSH wrote:
How exactly do I do that from a childs perspective?
Thanks
Ron
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:2e******************************@comcast.com. ..
>Add a reference to the Company in the Employees class. When you create the Employees class, fill in reference with the parent that created it.
Robin S. ------------------------------ "RSH" <wa*************@yahoo.comwrote in message news:%2******************@TK2MSFTNGP04.phx.gbl. ..
>>Hi,
I have a situation where I have a Parent Object (Company) which has several public properties. The Company Object also creates an Employees object which has its ow set of functions and properties. I am trying to figure out how to access the Parent properties from the child object.
Simplified example: Class Company Public ReadOnly Property Employees() As Employees Public Sub New(ByVal CompanyID As String)
_CompanyID = CompanyID
_Employees = New Employees(_CompanyID)
End Sub Get
Return _Employees
End Get
End Property
Public ReadOnly Property CompanyID() As String
Get
Return _CompanyID
End Get
End Property
Public Property DateLow() As Date
Get
Return _DateLow
End Get
Set(ByVal Value As Date)
_DateLow = Value
End Set
End Property
Public Property DateHi() As Date
Get
Return _DateHi
End Get
Set(ByVal Value As Date)
_DateHi = Value
End Set
End Property
End Class
Class Employees
>>How do I get at the CompanyID Property of the Company Parent Object?? End Class Thanks,
Ron
--
Göran Andersson
_____ http://www.guffa.com
Thank you. That would explain it.
Everything works now.
Ron
"RSH" <wa*************@yahoo.comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
Hi,
I have a situation where I have a Parent Object (Company) which has
several public properties. The Company Object also creates an Employees
object which has its ow set of functions and properties. I am trying to
figure out how to access the Parent properties from the child object.
Simplified example:
Class Company
Public ReadOnly Property Employees() As Employees
Public Sub New(ByVal CompanyID As String)
_CompanyID = CompanyID
_Employees = New Employees(_CompanyID)
End Sub
Get
Return _Employees
End Get
End Property
Public ReadOnly Property CompanyID() As String
Get
Return _CompanyID
End Get
End Property
Public Property DateLow() As Date
Get
Return _DateLow
End Get
Set(ByVal Value As Date)
_DateLow = Value
End Set
End Property
Public Property DateHi() As Date
Get
Return _DateHi
End Get
Set(ByVal Value As Date)
_DateHi = Value
End Set
End Property
End Class
Class Employees
>>>>How do I get at the CompanyID Property of the Company Parent Object??
End Class
Thanks,
Ron
RSH wrote:
I have a situation where I have a Parent Object (Company) which has several
public properties. The Company Object also creates an Employees object
which has its ow set of functions and properties. I am trying to figure out
how to access the Parent properties from the child object.
Something like this:
Class Parent
Public Sub New(name As String)
m_sName = name
End Sub
Public Function GetEmployee(empNo as String) as Employee
Return New Employee(Me, empNo)
End Function
Public ReadOnly Property Name() as String
Get
Return m_sName
End Get
End Property
Private m_sName as String = "Bogus Co."
End Class
Class Employee
' Prevent access to default constructor
Private Sub New()
End Sub
Friend Sub New(parent as Company, empNo as String)
m_oParent = parent
m_empNo = empNo
End Sub
Public ReadOnly Property Company() as Company
Get
Return m_oParent
Get
End Property
Public ReadOnly Property Name() as String
Get
Return m_sName
End Get
End Sub
Private m_oParent as Company
Private m_sName as String
End Class
.... then ...
Dim c as New Company( "Bogus Co." )
Dim e as c.GetEmployee( "ABC123" )
? c.Company.Name
"Bogus Co."
HTH,
Phill W.
"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:es**********@south.jnrs.ja.net...
RSH wrote:
>I have a situation where I have a Parent Object (Company) which has several public properties. The Company Object also creates an Employees object which has its ow set of functions and properties. I am trying to figure out how to access the Parent properties from the child object.
Something like this:
Class Parent
Public Sub New(name As String)
m_sName = name
End Sub
Public Function GetEmployee(empNo as String) as Employee
Return New Employee(Me, empNo)
End Function
Public ReadOnly Property Name() as String
Get
Return m_sName
End Get
End Property
Private m_sName as String = "Bogus Co."
End Class
Class Employee
' Prevent access to default constructor
Private Sub New()
End Sub
Friend Sub New(parent as Company, empNo as String)
m_oParent = parent
m_empNo = empNo
End Sub
Public ReadOnly Property Company() as Company
Get
Return m_oParent
Get
End Property
Public ReadOnly Property Name() as String
Get
Return m_sName
End Get
End Sub
Private m_oParent as Company
Private m_sName as String
End Class
... then ...
Dim c as New Company( "Bogus Co." )
Dim e as c.GetEmployee( "ABC123" )
? c.Company.Name
"Bogus Co."
HTH,
Phill W.
Nice job.
Robin S.
RobinS wrote:
"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:es**********@south.jnrs.ja.net...
>RSH wrote:
>>I have a situation where I have a Parent Object (Company) which has several public properties. The Company Object also creates an Employees object which has its ow set of functions and properties. I am trying to figure out how to access the Parent properties from the child object.
Something like this:
Class Parent Public Sub New(name As String) m_sName = name End Sub
Public Function GetEmployee(empNo as String) as Employee Return New Employee(Me, empNo) End Function
Public ReadOnly Property Name() as String Get Return m_sName End Get End Property
Private m_sName as String = "Bogus Co."
End Class
Class Employee ' Prevent access to default constructor Private Sub New() End Sub
Friend Sub New(parent as Company, empNo as String) m_oParent = parent m_empNo = empNo End Sub
Public ReadOnly Property Company() as Company Get Return m_oParent Get End Property
Public ReadOnly Property Name() as String Get Return m_sName End Get End Sub
Private m_oParent as Company Private m_sName as String
End Class
... then ...
Dim c as New Company( "Bogus Co." ) Dim e as c.GetEmployee( "ABC123" )
? c.Company.Name "Bogus Co."
HTH, Phill W.
Nice job.
Robin S.
Lousy employer, though ...
Sure, their employees have Names, not numbers, but what about Salary!!
;-)
Many Thanks,
Phill W.
"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:es**********@south.jnrs.ja.net...
RobinS wrote:
>"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message news:es**********@south.jnrs.ja.net...
>>RSH wrote:
I have a situation where I have a Parent Object (Company) which has several public properties. The Company Object also creates an Employees object which has its ow set of functions and properties. I am trying to figure out how to access the Parent properties from the child object. Something like this:
Class Parent Public Sub New(name As String) m_sName = name End Sub
Public Function GetEmployee(empNo as String) as Employee Return New Employee(Me, empNo) End Function
Public ReadOnly Property Name() as String Get Return m_sName End Get End Property
Private m_sName as String = "Bogus Co."
End Class
Class Employee ' Prevent access to default constructor Private Sub New() End Sub
Friend Sub New(parent as Company, empNo as String) m_oParent = parent m_empNo = empNo End Sub
Public ReadOnly Property Company() as Company Get Return m_oParent Get End Property
Public ReadOnly Property Name() as String Get Return m_sName End Get End Sub
Private m_oParent as Company Private m_sName as String
End Class
... then ...
Dim c as New Company( "Bogus Co." ) Dim e as c.GetEmployee( "ABC123" )
? c.Company.Name "Bogus Co."
HTH, Phill W.
Nice job.
Robin S.
Lousy employer, though ...
Sure, their employees have Names, not numbers, but what about Salary!!
;-)
Many Thanks,
Phill W.
LOL.
Robin S. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: pablo |
last post by:
Dear NewsGroupers,
I am relatively new to OOP and cannet get my head around this problem.
I have two classes. Class Child extends Parent.
There is no constructor for the Child class. So when I...
|
by: Gerry Abbott |
last post by:
Access allows all objects, tables, forms, queries, macros, modules, to be
documented with common object properties, including Description, Type,
modified and created dates, owner, and some...
|
by: Ric |
last post by:
Please forgive me if i dont explain this situation correctly. i'll try
to do my best.
because the arraylist.add method only accepts one argument, i created
an object with several public...
|
by: David L Wright II |
last post by:
I am trying to access a mdi parent form's properties and methods outside of
the mdi parent form's class module. I keep getting "Reference to a
non-shared member requires an object reference"...
|
by: Joăo Rezende |
last post by:
Hello,
I have two objects implemented with CollectionBase framework, say MyParent
and MyChild.
MyChild object is embedded into MyParent and I need to bind some MyChild
properties via MyParent....
|
by: RSH |
last post by:
I have a situation where I have developed a user control that contains
several ImageButtons with hardcoded values.
In the codebehind I have a property that is setup to receive a string value...
|
by: anujzcool |
last post by:
Is there any way of accessing and modifying configuration properties at runtime.
|
by: Maximiliano |
last post by:
Hello, I have an asp.net project that calculates a general tax. Ok,
this tax is a big object formed with another child objects (as a
mather of fact 15 another child object within it), like Ship,...
|
by: Max |
last post by:
Hi, there,
Is there a good way to get an Object's properties' names.
eg. obj={a:"aa",b:"bB",c:"Cc"};
All I mean is to get the names of "a", "b", "c". but not the values
"aa", "bB", "Cc".
...
|
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...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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,...
|
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...
| |