How can I pass a checkbox by reference?
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
.)
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
MyMethod(ByRef MyCheckBox as CheckBox)
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.
精彩评论