Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ParamArray Not Working With COM

I have a Class Library that is exposed to COM like this:

<ComClass(SomeClass.ClassId, SomeClass.InterfaceId, SomeClass.EventsId)>
Public Class SomeClass

    Public Const ClassId As String = "GUID1"
    Public Const InterfaceId As String = "GUID2"
    Public Const EventsId As String = "GUID3"

    Public Sub SomeMethod(ByVal ParamArray values() As Object)
        ''//Some Code Here    
    End Sub
End Class

I then used regasm /tlb /codebase to to register it. All methods and properties seem to work correctly in VBA/VB6 but when I try to access the Method with a ParamArray it won't event compile. I get the error:

Compile error:

Function or interface marked as restricted, or the function uses an Automation type not suppport in Visual Basic.

What do I need to do to properly expose this Method so I can use it like this?:

SomeClass.SomeMethod 1, 2, 3
like image 508
Oorang Avatar asked Apr 08 '26 14:04

Oorang


1 Answers

the function uses an Automation type not supported in Visual Basic.

The buck stops there, there is no equivalent of parameter arrays in VB6. Drop the ParamArray keyword. The VB6 code has to pass an array of Variants. Unpleasant, consider redesigning your class.

like image 200
Hans Passant Avatar answered Apr 12 '26 10:04

Hans Passant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!