Article ID: 195755 - Last Review: May 12, 2003 - Revision: 2.0 BUG: Parent Property Returns Invalid Object Type for UserControlThis article was previously published under Q195755 On This PageSYMPTOMS
Visual Basic intrinsic controls support a Parent property that returns the
object of the parent hosting the control. Currently, this property is typed
as returning a Form object. However, if the control is hosted on a Visual
Basic UserControl or UserDocument, a Form object is not returned.
CAUSE
Because the Parent property is strongly typed as Form, it is possible to
early-bind to the object and call methods/properties through the vtable,
even through the object returned may not be a valid Form object. This can
cause application errors to occur at run-time.
RESOLUTION
To avoid problems caused by a mismatched object type, always perform late
binding when calling a method or property of an object returned from the
Parent property. For example, do not make an early bound call in the
following form:
Instead, declare a standard object variable and set a reference first. This forces Visual Basic to use late binding and call each function by name rather than by vtable position: STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
MORE INFORMATIONSteps to Reproduce Behavior
APPLIES TO
| Article Translations
|
Back to the top
