Results 1 to 1 of 1
  1. #1
    Join Date
    Oct 2002
    Posts
    19

    Question Unanswered: help about 2D array

    I am trying to pass a 2D array from VB5 to a Visual C++ DLL. I wanto to use pointer to ponter for passing an 2D array and pointer to function for a 1D array

    In VB iI call the dll


    declare public sub foo Lib foo32.dll" (ByRef MyArray As Double, ByVal N As Long, ByRef MyVector As Double)

    .
    .
    .
    .
    foo(MyArray(1, 1), Dimension, MyVector(1))

    'I pass MyVector as an empty vector


    c dll is:

    void __stdcall foo ( double* *MyArray, int N, double *MyVector)

    {

    int i, l, ii, k;

    double g, f;

    i=N;
    for( ii=2;ii<=N;ii++)
    {
    l=i-2;
    f=MyArray[i][i-1];
    g=0.0;
    while(l>=1)
    {
    for( k=1;k<=l;k++)
    {
    g+=MyArray[i][k]*MyArray[i][k];
    }

    }
    }

    if(g<=0.0000001)
    {
    MyVector[i]=0.0;
    }
    .
    .
    .
    .

    }



    There are no problem with the compiler and I get compiled dll with neither error nor warnings.
    It seems C doesn't get the values the right way, as values in stead of an address.
    When I run this program, VB hangs up when debugging I can see that MyArray shows an memory address and doesn't any value.

    have I to use static variables in dll?
    are there a problem with memory allocation?
    Please, anyone can help me?
    Thanks advanced
    Last edited by byte2002; 11-22-02 at 09:01.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •