• How to Qualify Objects with ! and .

    Author
    Topic
    #460553

    How to quality objects with ! (exclamation) and . (period)?
    In particular, when should ! (exclamation be used?
    Thanks.
    Armstrong

    Viewing 1 reply thread
    Author
    Replies
    • #1165144

      The bang or exclamation mark ! is used to indicate a member of a collection. For example Forms!frmMain specifies frmMain as a member of the Forms collection.

      The period . is used to indicate a property or method of an object. For example Forms!frmMain.Caption is the Caption property of the form frmMain.

      Controls on a form are both members of the form’s Controls collection and properties of the form. Since Controls is the default property of the form, the following are equivalent:

      Forms!frmMain.Controls!txtLast
      Forms!frmMain!txtLast
      Forms!frmMain.txtLast

      • #1165149

        Controls on a form are both members of the form’s Controls collection and properties of the form. Since Controls is the default property of the form, the following are equivalent:

        Forms!frmMain.Controls!txtLast
        Forms!frmMain!txtLast
        Forms!frmMain.txtLast

        HansV,
        Thanks to your crystal clear enlightenment, now I realize the period (.) is meant for property/method.
        It’s the latter I was confused. Different authors of different books use ! and . arbitrarily. It turns out to be they’re equivalent. That’s interesting.
        Thanks for your help.
        Armstrong

    • #1165150

      If you use . when typing code you will get the Intellisense – this will save you from mispelling a control name. It also means that if you rename a control on the form, the code will not compile until you change all references to that renamed control in code.

    Viewing 1 reply thread
    Reply To: How to Qualify Objects with ! and .

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: