Microsoft KB Archive/191864

= PRB: Error 743 Adding ActiveX Controls to Control Collection =

Article ID: 191864

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 Q191864



SYMPTOMS
When dynamically adding a large number of ActiveX controls into a Form's Controls Collection, you receive the following:

"Error 743. Unable to create or activate a new instance of ."



RESOLUTION
While this situation has been reported as a bug, this is an application design problem and the best solution is "Don't do this." If you have encountered this problem, you are probably using controls where you should be using objects. Consider using a Class, ActiveX DLL, or ActiveX EXE to create your objects. If you must use controls, consider using windowless controls as they are less resource-intensive.

Keep in mind that forms with hundreds of visible controls will be confusing for the end user. If the controls are not being displayed, then there is no reason to use a control. ActiveX controls have a great deal of "overhead" when compared to an object.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Start a new Standard EXE project in Visual Basic. Form1 is created by default. Choose Add Project from the File menu to add an ActiveX Control project. Place an instance of UserControl1 on Form1. Place a CommandButton on Form1.  Add the following code to the module of Form1: Private Sub Command1_Click Dim i As Integer On Error GoTo trap For i = 1 To 1000 Me.Controls.Add "project2.usercontrol1", "control" & i        Next Debug.Print "Finished" Exit Sub trap: If Err.Number = 743 Then Debug.Print "Error 743 loading control #" & i        End If      End Sub

 Run the project. You should see the message in the immediate window indicating that the error occurred.</li></ol>

Additional query words: kbDSupport kbDSD kbVBp kbVBp600 kbCtrl

Keywords: kbprb KB191864

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.