如何通过引用传递复选框?
我在 VB6 中遇到了一个奇怪的问题。我将一个复选框传递给带有签名 MyMethod(ByRef object)
的方法,并将其调用为 myClass.MyMethod chkMyCheckbox
。然而,VB6 拒绝传递复选框本身,而是将对 1
的引用传递给我的方法。我猜测这与 VB6 如何指定对象的默认属性有关。如何才能传递整个对象,而不仅仅是 .Value
?我无法关闭默认属性,因为大量遗留代码严重依赖它们。
如您所见,ChkCalFault
是一个复选框,而不是一个整数,但正在评估并作为其整数值传递。 (在此屏幕截图 0
中。)
I've run into what seems to be an odd quirk with VB6. I'm passing a checkbox to a method with the signature MyMethod(ByRef object)
and calling it as myClass.MyMethod chkMyCheckbox
. VB6, however, refuses to pass the checkbox itself, but instead passes a reference to 1
to my method. I'm guessing that this has something to do with how VB6 specifies an object's default properties. How can I get the entire object to be passed, not just .Value
? I cannot turn off default properties, as a large amount of the legacy code relies heavily on them.
As you can see, ChkCalFault
is a Checkbox and not an integer, but is being evaluated and passed as its integer value. (Which is in this screenshot 0
.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看不到你想对代码做什么,所以如果这是偏离基础的,我很抱歉,但是修改你的方法签名
对你有用吗?如果没有,未记录的 VarPtr 将获取您的复选框对象的地址,但我也不知道这是否为您指明了正确的方向。
I can't see what your trying to do with the code so I apologize if this is off-base, but would modifying your methods signature to
work for you? If not, the undocumented VarPtr will get the address of your checkbox object, but I don't know if that points you in the right direction either.