Dear Mr. Cor.
Many thanks for your kind consent to help us. We have a program on Visual
Basic 2003 for construction and management (rotation) of a surface z=f (x,
y). I have tried to copy this program on Visual C++ 2003 by change of syntax
of language, but I do not have not enough qualification. Therefore I have
decided, that is necessary in the project on Visual Basic screen coordinates
of a surface to write down in an array myArrayVB (i, j) and to pass this
array in the project on Visual C++ 2003. The first variant of export of an
array through recording on a hard disk you to us have told, for what we are
once again very grateful to you.
Now we want to try the second variant of export of 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 (on which we want to
build a surface z=f(x,y) as myArrayVB with the help of method DrawLine), 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, to export myArrayVB in myArrayVC?
Beforehand many thanks for the answer, Dr. Zharkov V.A., Moscow, Russia.