PRB: Out of Stack Space Error Caused by Property ProcedureLast reviewed: October 30, 1995Article ID: Q129940 |
The information in this article applies to:
SYMPTOMSUsing a non-reserved Visual Basic keyword within a Property Procedure of the same name creates a recursive call to that Property statement resulting in this error:
Out of Stack Space Error. CAUSEVisual Basic allows you to define Properties and Methods that have the same name as non-reserved keywords because many keywords (such as Left) in previous versions of Visual Basic are used frequently by OLE servers. If you take advantage of this in your own Class, an "Out of Stack Space error" can occur in a Property Get Procedure when both of the following conditions are met:
RESOLUTIONTypically, if one of the following conditions is true, Visual Basic can determine whether to call the Property Get procedure or the non-reserved keyword:
Property Get Left() as String Left = Left("Hello World",10) ' Visual Basic Left function called End PropertyBecause the Property Get Procedure expects 0 parameters and the Visual Basic function expects 2, the Visual Basic Left function is called. If, however, the Property Get Procedure returns either a Variant or an Object, the Property Get Procedure is called, regardless of the number of Parameters the Property Procedure expects. This occurs because Objects, which are now supported in Variants, can have a default property, which can take parameters themselves. When you call a function that returns a Variant or Object, and you pass the incorrect number of parameters, Visual Basic realizes that you intended to pass the parameters to the default property of the Object, so it generates a call to the default property with those parameters. In this case, the "Incorrect Number of Parameters" message is not generated because it is not necessarily known how many parameters are expected by the default property.
STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
|
Additional reference words: 4.00 vb4win vb4all
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |