在对象引用变量前面放一个感叹号 (!) 有什么作用? [英] What does putting an exclamation point (!) in front of an object reference variable do?

查看:64
本文介绍了在对象引用变量前面放一个感叹号 (!) 有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Basic 6.0 中将感叹号 (!) 放在对象引用变量前有什么作用?

What does putting an exclamation point (!) in front of an object reference variable do in Visual Basic 6.0?

例如,我在代码中看到以下内容:

For example, I see the following in code:

    !RelativePath.Value = mstrRelativePath

! 是什么意思?

推荐答案

几乎可以肯定是 With 块中的语句:

It is almost certainly a statement inside a With block:

  With blah
    !RelativePath.Value = mstrRelativePath
  End With 

这是

  blah("RelativePath").Value = mstrRelativePath

这是

  blah.DefaultProperty("RelativePath").Value = mstrRelativePath

其中DefaultProperty"是一个由字符串索引的 dispid 为零的属性.类似于 ADO Recordset 对象的 Fields 属性.

where "DefaultProperty" is a property with dispid zero that's indexed by a string. Like the Fields property of an ADO Recordset object.

糖不可避免地会导致蛀牙.这就是您必须在 VB6 和 VBA 中使用 Set 关键字的原因.因为没有它,编译器不知道您是要复制对象引用还是对象的默认属性值.在 vb.net 中被淘汰.

Somewhat inevitable with sugar is that it produces tooth decay. This is the reason you have to use the Set keyword in VB6 and VBA. Because without it the compiler doesn't know whether you meant to copy the object reference or the object's default property value. Eliminated in vb.net.

这篇关于在对象引用变量前面放一个感叹号 (!) 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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