Microsoft KB Archive/223104

= FIX: ParentControls.Count May Fail on Windows NT 4, Service Pack 4 =

Article ID: 223104

Article Last Modified on 5/13/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q223104



SYMPTOMS
Under Windows NT Service Pack 4, if a Usercontrol accesses the ParentControls.Count property and there are 32 or more controls on the form, including the Usercontrol and any controls on the Usercontrol, the Visual Basic app might crash.

NOTE: This bug does not occur on Windows NT 4.0 Service Pack 5 or on Windows 2000 machines.



CAUSE
This is caused by an error in Visual Basic's heap allocation mechanism.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Visual Studio 6.0 Service Pack 3.

For more information about Visual Studio 6.0 Service Packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed



Steps to Reproduce Behavior
 Create a new Standard EXE project in Visual Basic 6.0. Form1 is created by default. Click Add Project on the File menu and add a new ActiveX Control project. UserControl1 is created by default. Add a CommandButton to the UserControl.  Place the following code in the Click event of the CommandButton: MsgBox UserControl.ParentControls.Count  Close the designer window for UserControl1. Place a UserControl1 control on Form1 of the Standard EXE Project.</li> Add 30 TextBox controls to Form1 of the Standard EXE project.</li> Press the F5 key to run the project.</li> Click the CommandButton of the UserControl.</li></ol>

After clicking the button in the last step, an Application Error occurs in VB6.exe.

<div class="references_section">