BUG: Dynamically-Added OCX Event Parameter Is Not Passed ByRef (192682)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q192682 SYMPTOMS
When working with an ActiveX control that is added dynamically at run-time,
an event procedure passes a Variant parameter by reference (ByRef) to the
client, but any changes made by the client are not returned to the control.
CAUSE
This occurs when the event procedure is written to pass a Variant, but the
variable being passed by the control is not a Variant. This causes Visual
Basic to create a temporary Variant to use as the event parameter. When the
client code makes changes to the parameter, the changes are made to this
temporary copy and not to the original variable.
Under normal circumstances, Visual Basic updates the original variable with
any changes made to the Variant copy. However, this does not occur for
event procedures in a dynamically-loaded UserControl.
RESOLUTION
To avoid the problem, make sure the data types of your UserControl event
procedures are as specific as possible. Also, see that the parameters used
during a RaiseEvent call match the expected parameter types.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
REFERENCES
For additional information, please see the following article in the
Microsoft Knowledge Base:
190670
: HOWTO: Dynamically Add Controls to a Form with Visual Basic 6.0
Modification Type: | Major | Last Reviewed: | 5/13/2003 |
---|
Keywords: | kbbug KB192682 |
---|
|