VBA 和 MS-Access 中的 Bang Notation 和 Dot Notation [英] Bang Notation and Dot Notation in VBA and MS-Access

查看:20
本文介绍了VBA 和 MS-Access 中的 Bang Notation 和 Dot Notation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读我正在记录的应用程序时,我已经在访问对象属性/方法等时遇到了一些 bang 表示法的示例,在其他地方,他们使用点表示法来实现看似相同的目的.

While perusing an application that I'm documenting, I've run across some examples of bang notation in accessing object properties/methods, etc. and in other places they use dot notation for what seems like the same purpose.

使用其中一种是否有区别或偏好?一些简单的谷歌搜索只能揭示有关该主题的有限信息,有些人实际上在相反的情况下使用它.也许某处的MS有一个编码标准部分表明了疯狂的方法?

Is there a difference or preference to using one or the other? Some simple googling only reveals limited information on the subject with some people actually using it in opposite cases. Perhaps there is a coding standards section from MS somewhere that indicates the method of madness?

推荐答案

尽管(以前)已接受此问题的答案,但 bang 实际上不是成员或集合访问运算符.它做了一件简单而具体的事情:bang 运算符提供对对象默认成员的后期绑定访问,方法是将 bang 运算符后面的文字名称作为字符串参数传递给该默认成员.

Despite the (formerly) accepted answer to this question, the bang is not in fact a member or collection access operator. It does one simple and specific thing: The bang operator provides late-bound access to the default member of an object, by passing the literal name following the bang operator as a string argument to that default member.

就是这样.对象不必是集合.它不必具有称为 Item 的方法或属性.它所需要的只是一个 Property GetFunction 可以接受一个字符串作为第一个参数.

That's it. The object doesn't have to be a collection. It doesn't have to have a method or property called Item. All it needs is a Property Get or Function which can accept a string as the first argument.

有关更多详细信息和证明,请参阅我的博客文章讨论此问题:<强>砰!VBA 中的(感叹号)

For much more detail and proof, see my blog post discussing this: The Bang! (Exclamation Operator) in VBA

这篇关于VBA 和 MS-Access 中的 Bang Notation 和 Dot Notation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆