Microsoft KB Archive/832676

= BUG: You receive an error message when you use an Enum parameter in an ActiveX control method that you create in Visual Basic 6.0 =

Article ID: 832676

Article Last Modified on 4/25/2007

-

APPLIES TO


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

-





SYMPTOMS
When you use an Enum parameter in a Microsoft ActiveX control method that you create in Microsoft Visual Basic 6.0, you may receive the following error message if you run the application in the IDE:

Run-time error '-2147417848 (80010108)':

Method 'GetUpdateInfo' of object '_UserControl1' failed

You may receive the following error message if you run the application from a MS-DOS command prompt:

Run-time error '-2147417848 (80010108)': Automation error

The object invoked has disconnected from its clients.



RESOLUTION
To resolve this problem, put the Enum parameter last in the parameter list, as follows:   In the UserControl1.ctl file, replace the following code Public Sub GetUpdateInfo(ByVal UType As UpdateType, ByRef UpdateFiles As UpdateInfo, ByRef uIndex As Integer)

End Sub with: Public Sub GetUpdateInfo(ByRef UpdateFiles As UpdateInfo, ByRef uIndex As Integer, ByVal UType As UpdateType)

End Sub   In the UserControl1.ctl file, replace the following code UserControl11.GetUpdateInfo UpdateType.utHRDat, uf, uindex with: UserControl11.GetUpdateInfo uf, uindex, UpdateType.utHRDat 



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



Steps to reproduce the behavior
 Start Visual Basic 6.0. Create a new ActiveX Control project.

By default, the UserControl1.ctl file is created.  Add the following code to the UserControl1.ctl file: Option Explicit

Public Type UpdateInfo FileName As String Register As Boolean FileSize As Long End Type

Public Enum UpdateType utHRDat = 1 utHRUpdate = 2 End Enum

Public Sub GetUpdateInfo(ByVal UType As UpdateType, ByRef UpdateFiles As UpdateInfo, ByRef uIndex As Integer)

End Sub </li> On the File menu, click Make Project1.ocx.

The Project1.ocx file is created.</li> Create a new Standard EXE project.

By default, the Form1.frm file is created.</li> Add a CommandButton control to the Form1.frm file.</li> On the Project menu, click Components to add the Project1.ocx file control to the Toolbox window.

The UserControl1 ActiveX control is added to the Toolbox window.</li> Add the UserControl1 control to the Form1.frm file.</li>  Add the following code to the Form1.frm file: Option Explicit

Private Sub Command1_Click Dim uf As UpdateInfo Dim uindex As Integer uindex = -1 UserControl11.GetUpdateInfo UpdateType.utHRDat, uf, uindex MsgBox uindex End Sub </li> On the Debug menu, click Start.</li> In the Form1 window, click the Command1 button.

You receive one of the error messages that are mentioned in the &quot;Symptoms&quot; section of this article.</li></ol>

<div class="references_section">