Microsoft KB Archive/191718

= BUG: Error 13 Assigning Variable to UserControl in Same Project =

Article ID: 191718

Article Last Modified on 5/13/2003

-

APPLIES TO


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

-



This article was previously published under Q191718



SYMPTOMS
You receive a Type Mismatch Error (13) when assigning a UserControl to a variable if the UserControl is in the same project as the assigning code. The problem does not occur if the UserControl is in a different project or compiled.



RESOLUTION
Load the form containing the UserControl before assigning the UserControl to the variable. (See step 8 in Steps to Reproduce Behavior below.)



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 Start a new Standard EXE project in Visual Basic. Form1 is created by default. Add a UserControl to the project. Place an instance of the UserControl on Form1. Add a Standard Module to the project.  Insert the following code into Module1: Sub Main Dim x As UserControl1 Set x = Form1.UserControl11 End Sub

 Set the Startup Object of the project to Sub Main.</li> Run the project. You should receive "Run-time error 13. Type Mismatch."</li>  To resolve the problem, change the code in step 5 to: Sub Main Dim x As UserControl1 Load Form1 Set x = Form1.UserControl11 End Sub

</li></ol>

Additional query words: kbDSupport kbDSD kbVBp kbVBp600bug kbVBp500bug kbCtrl

Keywords: kbbug KB191718

-

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

© Microsoft Corporation. All rights reserved.