For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > March 2005 > Best practice in addressing properties?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Best practice in addressing properties?
Stan Hilliard

2005-03-14, 4:02 pm

Which is the best practice in addressing properties of a form from
within that form?

I have a choice of two methods to assign or read a form's properties
from within that form:

1) To use the module level private name to address the property
directly.
(Example: m_VariableName=X)

2) To use the public name of the property to go through the
property-get or property-set procedure.
(Example: VariableName=X)

Stan Hilliard
Veign

2005-03-14, 4:02 pm

Are these custom properties add to the form? If not why not just address
the forms properties directly? (like Me.Width)...

I guess I'm a bit on the exact question or the problem you're
having...

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/


"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in message
news:kdbb31t6crteqqa9jc2jj79ru29uc9j5tg@
4ax.com...
> Which is the best practice in addressing properties of a form from
> within that form?
>
> I have a choice of two methods to assign or read a form's properties
> from within that form:
>
> 1) To use the module level private name to address the property
> directly.
> (Example: m_VariableName=X)
>
> 2) To use the public name of the property to go through the
> property-get or property-set procedure.
> (Example: VariableName=X)
>
> Stan Hilliard



J French

2005-03-14, 4:02 pm

On Mon, 14 Mar 2005 09:44:06 -0600, Stan Hilliard
<usenetreplyMS@samplingplansNOTSPAM.com> wrote:

>Which is the best practice in addressing properties of a form from
>within that form?
>
>I have a choice of two methods to assign or read a form's properties
>from within that form:
>
>1) To use the module level private name to address the property
>directly.
>(Example: m_VariableName=X)
>
>2) To use the public name of the property to go through the
>property-get or property-set procedure.
>(Example: VariableName=X)


Neither, and both

m_VariableName=X
m.VariableName=X

Spot the difference

Using the public property name of the private field ensures that all
'triggers' are triggered
Jeff Johnson [MVP: VB]

2005-03-14, 4:02 pm


"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in message
news:kdbb31t6crteqqa9jc2jj79ru29uc9j5tg@
4ax.com...

> Which is the best practice in addressing properties of a form from
> within that form?
>
> I have a choice of two methods to assign or read a form's properties
> from within that form:
>
> 1) To use the module level private name to address the property
> directly.
> (Example: m_VariableName=X)
>
> 2) To use the public name of the property to go through the
> property-get or property-set procedure.
> (Example: VariableName=X)


In my case it depends on whether or not the property procedure does anything
beyond assigning a value to the internal variable. If it doesn't, I
generally use the internal variable directly. If it does, I use the
property.

I'm sure someone will come around and say "Why not use the property all the
time so that you never have to think about it?" Well, I just like the idea
of saving those few nanoseconds incurred by the function call to the
property procedure. Some day all of us who were raised on <1MHz computers
will die and this way of thinking will go with us.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com