PRB: Certain Settings Of MaxLength Property Closes Visual FoxPro

Last reviewed: December 2, 1997
Article ID: Q166180
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 5.0, 5.0a

SYMPTOMS

One of the following may cause Visual FoxPro to quit or cause a system error:

  • Opening a form containing an EditBox control or control based on the EditBox control
  • Placing a class based on the EditBox control on a form.

The form or class that causes this behavior does not cause a problem in version 3.x of Visual FoxPro for Windows.

CAUSE

This is known to happen if the MaxLength property of a class based on the EditBox control is set to the following:

   LEN(EVAL(This.ControlSource))

RESOLUTION

Remove the offending functions from the MaxLength property of the class definition for the subclassed EditBox control. If the MaxLength property must be set to LEN(EVAL(This.ControlSource)), set it after placing the instance of the class on a form.

STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

This is not a problem in Visual FoxPro 3.x for Windows or Visual FoxPro 3.0b for Macintosh.

Note that when entering LEN(EVAL(This.ControlSource))in the Expression Builder, if the Verify button is pushed, the following error messages are returned:

In Visual FoxPro 5.x:

   Missing expression.

In Visual FoxPro 3.x for Windows and for Macintosh:

   THIS can only be used within a method.

Steps to Reproduce Behavior

Warning: The following steps will crash Visual FoxPro and even possibly the computer's operating system. Make sure anything important is saved and closed.

  1. Create a new class based on the EditBox base class or issue the following command in the Visual FoxPro Command window:

          CREATE CLASS editcrash OF test.vcx AS editbox
    

  2. Set the MaxLength property to the following:

          LEN(EVAL(This.ControlSource))
    

  3. Save and close the class.

  4. Create a new form.

  5. Add an instance of the Editcrash class to the new form. To do this, click the View Classes button on the Form Controls toolbar. Choose Add in the Shortcut menu that is displayed. Open the Test.vcx class library file. The buttons on the Form Controls toolbar should now show the classes in the Test.vcx library. There should only be one in the Test.vcx. Place the mouse pointer over the buttons until the tooltip displays "editcrash." Click on this button and then click on the form.

  6. Visual FoxPro should crash at this point.

  7. An alternate way to reproduce the crash is to create the class but not set the MaxLength property. Then place the class on a form. Save and close the form. Modify the class set the MaxLength property to the following and save it.

          LEN(EVAL(This.ControlSource))
    

Then try opening the form.
Keywords          : FxprgClassoop vfoxwin
Version           : 5.0 5.0a
Platform          : WINDOWS
Issue type        : kbprb


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.