Larry Linson said:
Help me understand, if you're not _just_ raising objections: what approach
do you suggest that is more "efficient"? I've used the normal method
I would not call ! the "normal" method. The normal method would be to use .
like everywhere else in the language.
of addressing controls (to which you object) since Access 1.1, and never
suffered any discernable performance hit from it.
Most likely in access you won't notice any performance hit. However, compare
the methods:
Using Me.MyControlName.Value
- this gets a direct reference to the control
- calls Value early bound so is as quick as you can get in access.
Using Me!MyControlName.Value
- this will get a reference to the controls collection
- enumerate through the controls collection comparing on the string
"MyControlName"
- then return an object
- then iterate through all the methods on the control looking for one called
Value, again a string comparison.
- then convert all parameters to variant (in this case only 1 param) and
call invoke (a hidden method).
- or alternatively search for the default method if the .Value is not used.
All of this is pretty inefficent. Sure it might not make that much
difference unless it's in a loop but there is no gain using ! so why not
just use a dot?
And, if you have something that is more efficient, in how large a loop
would it have to be tested to show a measurable performance improvement?
The loop wouldn't have to be that big really but probably several thousand.
However speed is not really the main issue here. Using the ! means errors in
your code will be detected at runtime and not compile time and it is always
better to have the compiler pick up errors instead of the programmer, or
even worse the user.
Michael