如何使用List <string>返回COM方法的类型

时间:2019-03-21 11:11:25

标签: c# comobject

我有COM someName.tlb

public interface Packet_Interface
{
    [DispId(1)]
    string operName { get; set; }
    [DispId(2)]
    List<string> parameters { get; set; }
}
[Guid("C7CC0CEF-F839-48FA-BBAE-9D0FF50D3E5A")]
public interface VRNGO_Interface
{
    [DispId(1)]
    Packet ExchangeOperation(string param1, string param2);
}

在Excel中,我添加了该tlb并尝试使用此对象

Dim srv As VRNGO.VRNGO_Class
Dim answer As VRNGO_Packet
Dim param As Object
Dim inn As String
Dim c As Integer
Set srv = CreateObject("VRNGO.VRNGO_Class")
For Each rw In Selection.Rows
    inn = rw.Cells(1, 3).Value
    Set answer = srv.ExchangeOperation("DUBLIUL", inn)
    rw.Cells(1, 7).Value = answer.operName
    Set param = answer.Parameters(0)

Next
End Sub

运行此代码时,在Set param = answer.Parameters(0)行出现错误:

  

参数数量错误或属性无效。

我应该如何访问“参数”属性?

0 个答案:

没有答案