Dear Mr. Jay B. Harlow.
Many thanks for your consultation. Following your guidelines, we have made:
We want to export myArrayVB (2000, 2) of VB .NET 2003 in myArrayVó [2000, 2]
of VC++ .NET 2003 on scheme "component - client". But there is an error.
For development of a component in VB .NET 2003 we make: File, New, Project,
Visual Basic Projects, Class Library, name of project: ComponentVB. We write
the code:
Public Function myFunction1()
Dim i, j As Integer
Dim N_x As Integer = 2000
Dim N_y As Integer = 1
Dim myArrayVB(N_x, N_y) As Single
For i = 0 To N_x
For j = 0 To N_y
myArrayVB(i, j) = 1
Next
Next
Return myArrayVB
End Function
For development of the client in VB .NET 2003 we make: File, New, Project,
Visual Basic Projects, Windows Application, name of project: ClientVB. On
Form1 we place control PictureBox. We add: Project, Add Reference,
ComponentVB.dll. And we write the code:
Private Sub PictureBox1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles PictureBox1.Paint
Dim i, j As Integer
Dim N_x As Integer = 2000
Dim N_y As Integer = 1
Dim myArrayVB_Client(N_x, N_y) As Single
Dim myObject As New ComponentVB.Class1
For i = 0 To N_x
For j = 0 To N_y
myArrayVB_Client(i, j) = myObject.myFunction1(i, j)
Next
Next
MsgBox("myArrayVB_Client(0,0 ) = " _
& myArrayVB_Client(0, 0)) ' = 1, ok.
End Sub
Export of an array from VB in VB we have fulfilled without errors.
For development of the client in VC++ .NET 2003 we make: File, New, Project,
Visual C++ Projects, (.NET), Windows Forms Application (.NET), name of
project: ClientVC. On Form1 we place control PictureBox, and we write the
code:
#using <mscorlib.dll>
#using "Debug\ComponentVB.dll"
private:
System::Void pictureBox1_Paint(System::Object * sender,
System::Windows::Forms:
aintEventArgs * e)
{
ComponentVB::Class1* myObject = new ComponentVB::Class1();
int i, j;
int N_x = 2001;
int N_y = 2;
float myArrayVC __gc[,] = new float __gc[N_x, N_y];
for (int i = 0 ; i <= N_x - 1; i++)
for (int j = 0 ; j <= N_y - 1; j++)
myArrayVC[i, j] = myObject->myFunction1(i, j); //Error.
}
Inform, please, how to correct this code C++, to export myArrayVB in
myArrayVC?
Beforehand many thanks for the answer, Dr. Zharkov V.A., Moscow, Russia.