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 (832676)



The information in this article applies to:

  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0

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:
  1. 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
    
  2. 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.

MORE INFORMATION

Steps to reproduce the behavior

  1. Start Visual Basic 6.0.
  2. Create a new ActiveX Control project.

    By default, the UserControl1.ctl file is created.
  3. 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
    
  4. On the File menu, click Make Project1.ocx.

    The Project1.ocx file is created.
  5. Create a new Standard EXE project.

    By default, the Form1.frm file is created.
  6. Add a CommandButton control to the Form1.frm file.
  7. 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.
  8. Add the UserControl1 control to the Form1.frm file.
  9. 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
  10. On the Debug menu, click Start.
  11. In the Form1 window, click the Command1 button.

    You receive one of the error messages that are mentioned in the "Symptoms" section of this article.

REFERENCES

For more information, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:3/12/2004
Keywords:kbConsole kbControl kbbug KB832676 kbAudDeveloper