Shamil Salakhetdinov
shamil at smsconsulting.spb.ru
Fri Apr 15 14:54:31 CDT 2011
Hi John --
<<<
Call both whatever you want, just please do not attempt
to tell me that they are the same thing, they clearly are not
>>>
But they are the same from *technical* (VBA/VB6/COM) point of view - that is
what Drew is telling...
IOW: they are looking the same for outer world.
Drew doesn't care about their internal implementation or high level
concepts...
Nobody argues here when one or another coding style/approach should be used
or that one is better than another one because of ...
OA: They are the same from *technical* point of view/perspective of
VBA/VB6/COM.
Try the following VBA/VB6 code:
------------- cut here -----
' class MyClass
Public MyTestVar As String
Private m_myTestVar2 As String
Property Get MyTestVar2() As String
MyTestVar2 = m_myTestVar2
End Property
Property Let MyTestVar2(ByVal v As String)
m_myTestVar2 = v
End Property
------------- cut here -----
' standard module - MyTestModule
Public Sub MyTest()
Dim c As MyClass
Set c = New MyClass
Dim result As String
CallByName c, "MyTestVar", VbLet, "MyTestValue"
result = CallByName(c, "MyTestVar", VbGet)
Debug.Print "Result from public variable = " + result
CallByName c, "MyTestVar2", VbLet, "MyTestValue2"
result = CallByName(c, "MyTestVar2", VbGet)
Debug.Print "Result from public variable2 = " + result
End Sub
------------- cut here -----
Thank you.
--
Shamil
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: 15 ?????? 2011 ?. 23:26
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] First real stumble with using VB.Net over VB
So what you are saying (and I have no reason to disbelieve this) is that a
public variable is a private variable wrapped in an invisible property call.
If that is truly the case (and they are identical) then why does he see
value / property differences?
And everything that I said below stands. A variable (field when placed in a
class) is a structure on the heap (apparently then wrapped in something to
return the value to make it public), whereas a property is a keyword and a
real function which can contain other stuff and does not contain any storage
of it's own. I defy you to show me a variable running code to wipe your
disk, but I can do so with a property.
They are *not* the same thing. The fact that a public class variable "kinda
sorta" emulates a private variable with a property wrapper does not make it
a private variable with a real property returning the value.
I truly don't give a rat's patuty if you or Drew wants to call a public
variable a property.
Apparently Drew desperately wants to do so - reason unknown. As I am not a
VB6 person I have no vested interest either way, I am just pointing out the
quite obvious problem with trying to apply the same name to two objects that
perform quite differently and have quite different capabilities.
I use properties and I often times have code in them which performs
calculations or tests. I have never managed to do that with a variable of
any kind. I have had properties which did not wrap a variable at all.
A property (keyword / function) does not have any specific storage assigned
to it unless you do so, intentionally, with more code. A variable ALWAYS
has storage assigned on the stack / heap.
Call both whatever you want, just please do not attempt to tell me that they
are the same thing, they clearly are not.
I will continue to call variables in a class a field and I will continue to
call properties (keyword / function) a property. Everybody except Drew will
understand me.
John W. Colby
www.ColbyConsulting.com