INFO: Multiple vbCancel Constants Defined with VB 4.0Last reviewed: September 30, 1997Article ID: Q147663 |
The information in this article applies to:
SUMMARYBoth the Visual Basic and the Visual Basic For Applications type libraries define a constant called vbCancel. The value for this constant is different in each type library.
MORE INFORMATIONThe value for the vbCancel constant defined in the "Visual Basic For Applications" type library is 2. The value defined in the "Visual Basic objects and procedures" type library is 0. The value that will be returned if vbCancel is used in code without a type library prefix is 2, because the VBA type library appears first in the list of references displayed in the References dialog. This can be an issue when the vbCancel constant is expected to return 0. For example, the Drag method can take a parameter named Action. To cancel a drag operation, the documentation instructs setting the Action parameter to vbCancel, where vbCancel is 0. Unfortunately, because the VBA type library exists before the Visual Basic type library, a value of 2 will be used instead of a value of 0. A value of 2 in the context of the Drag method indicates that the drag operation on the specified object is complete. If the string VB.vbCancel is used, the correct value of 0 will be substituted and the code will work properly.
Steps To Reproduce
Keywords : EnvtDes VB4ALL VB4WIN vbwin GnrlVb kbprg Technology : kbvba Version : WINDOWS:4.0 Platform : NT WINDOWS Issue type : kbinfo |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |