Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Who created this instance?

Status
Not open for further replies.

JaseUK

IS-IT--Management
Jun 19, 2001
21
GB
In VB is there anyway of telling WHO created "this" instance of an object? ie: Was it publically created or was it created by a friend? Short of adding a friend property that can set a flag to indicate whether or not this was the case?
 
I don't know of any, short of the WhosYourDaddy property.

I'm seeing two different objects. Maybe just two different entities. Nope, that's definately two different objects, derrived from a common ancestor.

Your public users make the common object while friends make a specialized version with added functionality.

You can embed your base class object in the specialized class wrapping the public members making it look like they belong to your specialized class. VB provides an inherits statement that leaves a little to be desired but still helps you along this path.

Leave the Common/Base class creatable but make the specialized class non-creatable. Refraining from using the public version within your project gives you the functionality you want by allowing your to tell them apart by their TypeName. This is true even if the specialized version doesn't really add any functionality. Since each has a similar interface, they can be used almost interchangably, you know, within the object framework.
[tt]
Class1:
Private x as string
Public Property Get It() As String
It = x
End Property
Public Property Let It(s As String)
x = s
End Property
=====
Class2:

Private x as string
Private oBase as NEW Class1
Public Property Get It() As String
It = oBase.x
End Property
Public Property Let It(s As String)
oBase.x = s
End Property
Public Function SpecialFunc()
' Work Work, More Work
End Function
[/tt]


Wil Mead
wmead@optonline.net

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top