INFO: Differences Between Exclamation Mark (!) & Dot (.) SyntaxLast reviewed: September 29, 1997Article ID: Q129287 |
The information in this article applies to:
SUMMARYIn Visual Basic version 4.0, the exclamation mark (!) syntax is for collection lookup, and the dot (.) syntax is for properties and methods. However, a control can be accessed as a property, and Visual Basic has a Controls collection on a form. Because the Controls collection is the default property of a form, you can access a control from a Form using by using the exclamation mark (!) syntax.
MORE INFORMATIONTo obtain direct access to the Ctrl1 property on the form, type this:
Form1.Ctrl1.Text = "Hello"This line:
Form1!Ctrl1.Text = "Hello"translates into this code:
Form1.Controls.Item("Ctrl1").Text = "Hello"Visual Basic for Applications has a specific optimization for Forms that allows the compiler to translate this syntax:
Form1!Ctrl1.Text = "Hello"into this code:
Form1.Ctrl1.Text = "Hello"Therefore the performance of the two statements should be identical. Note that this optimization is specific to controls on Visual Basic version 4.0 forms. It will not work with any other collection. WARNING: This optimization may not occur in future versions of Visual Basic forms.
Steps to Reproduce Behavior in Visual Basic 4.0
|
Additional query words: bang
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |