BUG: Can't Check MDIChild Property of Forms in Forms Collection

Last reviewed: November 7, 1997
Article ID: Q176429
The information in this article applies to:
  • Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 5.0

SYMPTOMS

The following code worked in Visual Basic 4.0, but fails in Visual Basic 5.0 with an error "Error 380, Invalid Property Value" if an MDI parent form is in the project:

   Dim f As Form
   For Each f In Forms
      If f.MDIChild Then
         Form1.Print f.Name & "   MDI Child"
      Else
         Form1.Print f.Name & "   Not MDI Child"
      End If
   Next

CAUSE

MDI forms do not have an MDIChild property in either Visual Basic 4.0 or Visual Basic 5.0. Visual Basic 4.0 compensated for that in the specific case of looping through the forms collection and checking this property, but Visual Basic 5.0 does not.

RESOLUTION

The workaround is to determine if the form is an MDI form before checking the MDIChild property, which the following code demonstrates:

   Dim f As Form
   For Each f In Forms
     If Not TypeOf f Is MDIForm Then
       If f.MDIChild Then
         Form1.Print f.Name & "   MDI Child"
       Else
         Form1.Print f.Name & "   Not MDI Child"
       End If
     Else
       Form1.Print f.Name & "  Not MDI Child"
     End If
   Next

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

Keywords          : vb5all kberrmsg
Version           : WINDOWS:5.0
Platform          : WINDOWS
Issue type        : kbbug


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


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: November 7, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.