当前位置: 代码迷 >> C# >> C#编写的COM dll,用VB6调用的有关问题,无法传递数组参数
  详细解决方案

C#编写的COM dll,用VB6调用的有关问题,无法传递数组参数

热度:93   发布时间:2016-05-05 03:45:02.0
C#编写的COM dll,用VB6调用的问题,无法传递数组参数
c# 源代码为:
    public int GetData(int StartAddr, int Length, ref int[] Datas)
        {
            Datas[0] = 5224;
            Datas[1] = 999;
            Datas[2] = 9789;
            Datas[3] = 2529;
            Datas[4] = -999;
            Datas[5] = 4999;
            Datas[6] = StartAddr;
            Datas[7] = Length;
            return 0;
        }

VB6调用的源代码为:
   Private Sub Command8_Click()
Dim data(12) As Integer
MyClass.GetData add, length, data
MsgBox UBound(data)
   End Sub
执行到 MyClass.GetData add, length, data  实时错误13,报类型不匹配
求高手帮忙!
------解决思路----------------------
Dim data(12) As Integer
不对
VB的Integer相当于C#的short
VB的Long才是C#的int
  相关解决方案