Oops, what I gave you in my first response was the usual way that you use
varying scope:
Private _FieldValue As <some type>
Public Property Something As <some type>
Get
Return _FieldValue
End Get
Private Set
_FieldValue = value
End Set
End Property
what you might do in your case is something like:
Private _FieldValue As <some type= Nothing
Public ReadOnly Property Something As <some type>
Get
If _FieldValue Is Nothing Then
_FieldValue = GetFieldValueFr omSomewhere()
End If
Return _FieldValue
End Get
End Property
and of course the details of how your code tells whether the value has been
set depends on your data.
Tom Dacon
Dacon Software Consulting
"Brad Pears" <bradp@truenort hloghomes.comwr ote in message
news:Oa71I3AnIH A.1204@TK2MSFTN GP03.phx.gbl...
varying scope:
Private _FieldValue As <some type>
Public Property Something As <some type>
Get
Return _FieldValue
End Get
Private Set
_FieldValue = value
End Set
End Property
what you might do in your case is something like:
Private _FieldValue As <some type= Nothing
Public ReadOnly Property Something As <some type>
Get
If _FieldValue Is Nothing Then
_FieldValue = GetFieldValueFr omSomewhere()
End If
Return _FieldValue
End Get
End Property
and of course the details of how your code tells whether the value has been
set depends on your data.
Tom Dacon
Dacon Software Consulting
"Brad Pears" <bradp@truenort hloghomes.comwr ote in message
news:Oa71I3AnIH A.1204@TK2MSFTN GP03.phx.gbl...
>I have a class that has readonly properties in it. I am fairly new to OO
>design and development so please let me know if this doe snot make sense...
>
The reasopn why I have these read only porperties is becasue these
particular properties are not set programatically - they are as a result
of a calualtion of two other properties as shown below...
>
public readonly property PSFLiveFactored () as decimal
Get
return PSFLiveFactored = PSFLive * 1.5
end get
end property
>
I have one readonly property that is derived from an SQL Stored procedure
(called when the object is instantiated) which selects a row from a view.
This particular view includes some calculated rows - one of which I want a
few of my read only properties to contain - as opposed to the way I am
setting them above. Since I cannot (and do not want anyone to) set this
property in code (hence a readonly property), how do I actaully set an
initial value for a read only property?
>
Would I have to call a private method in the "Get" area that would then
retrieve the data from the DB and use that returned value to set the
property?
>
>
Thanks, Brad
Thanks, Brad
>
>design and development so please let me know if this doe snot make sense...
>
The reasopn why I have these read only porperties is becasue these
particular properties are not set programatically - they are as a result
of a calualtion of two other properties as shown below...
>
public readonly property PSFLiveFactored () as decimal
Get
return PSFLiveFactored = PSFLive * 1.5
end get
end property
>
I have one readonly property that is derived from an SQL Stored procedure
(called when the object is instantiated) which selects a row from a view.
This particular view includes some calculated rows - one of which I want a
few of my read only properties to contain - as opposed to the way I am
setting them above. Since I cannot (and do not want anyone to) set this
property in code (hence a readonly property), how do I actaully set an
initial value for a read only property?
>
Would I have to call a private method in the "Get" area that would then
retrieve the data from the DB and use that returned value to set the
property?
>
>
Thanks, Brad
Thanks, Brad
>