弄了一晚上都没成功,非要用VB来做显示
Private Declare Function ArrayTest Lib "test.dll" (Arr1 As Long, Arr2 As Long, ByVal nSize As Long) As Long
Private Sub Command1_Click()
Dim I, Arr1(1 To 5), Arr2(1 To 5) As Long
For I = 1 To 5
    Arr1(I) = I
    Arr2(I) = I + 10
Next
MsgBox Arr1(2)
MsgBox Arr2(2)
Call ArrayTest(Arr1(1), Arr2(1), 5)
MsgBox Arr1(2)
MsgBox Arr2(2)
End Sub__declspec(dllexport) int __stdcall ArrayTest(int *, int *, int);__declspec(dllexport) int __stdcall ArrayTest(int *arr1, int *arr2, int n)
{
int i;
for(i = 0; i < n; i++)
arr2[i] = arr1[i];
for(i = 0; i < n; i++)
arr1[i] = 100;
return 0;
}输出是2,12,2,0
不知道什么原因
VC调试看arr1[]的值都不对,但地址根VB里数组的首地址是一样的

解决方案 »

  1.   

    Private Declare Function ArrayTest Lib "test.dll" (Arr1() As Long, Arr2() As Long, ByVal nSize As Long) As LongCall ArrayTest(Arr1, Arr2, 5)
      

  2.   

    Private Declare Function ArrayTest Lib "Alg.dll" (Arr1() As Long, Arr2() As Long, ByVal nSize As Long) As Long
    Private Sub Command1_Click()
    Dim I, Arr1(1 To 5), Arr2(1 To 5) As Long
    For I = 1 To 5
        Arr1(I) = I
        Arr2(I) = I + 10
    Next
    MsgBox Arr1(2)
    MsgBox Arr2(2)
    Call ArrayTest(Arr1, Arr2, 5)
    MsgBox Arr1(2)
    MsgBox Arr2(2)
    End Sub
    这样的结果是Type mismatch: array or user-defined type expected
      

  3.   

    @@
    我的VB6用你原来的代码能通过,VB .Net 2005 用我给你的代码能通过不知道你那里怎么了?
      

  4.   

    如果不是给别人做指定VB,界面也用VC那就远不用这么麻烦了
      

  5.   

    没辙了,你再试下这个
    Private Declare Function ArrayTest Lib "Alg.dll" Alias "ArrayTest" (byref Arr1() As Long, byref Arr2() As Long, ByVal nSize As Long) As Long
      

  6.   

    http://support.microsoft.com/kb/207931