473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to export an array from VB .NET in VC++ .NET?


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(ByVal N_i As Integer, _

ByVal N_j As Integer) As Array

N_i = 2000

N_j = 2

Dim myArrayVB As Array = _

Array.CreateInstance(GetType(Single), N_i, N_j)

For ii As Integer = 0 To N_i - 1

For jj As Integer = 0 To N_j - 1

myArrayVB(ii, jj) = 1

Next

Next

Return myArrayVB(, )

End Function

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 Panel (on which we want to
build a surface myArrayVB with the help of method DrawLine), and we write
the code:

#using <mscorlib.dll>

#using "Debug\ComponentVB.dll"

private:

System::Void panel1_Paint(System::Object * sender,

System::Windows::Forms::PaintEventArgs * e)

{

ComponentVB::Class1* myObject =

new ComponentVB::Class1();

int N_i = 2000;

int N_j = 2;

float myArrayVC __gc[,] = new float __gc[N_i, N_j];

for (int i = 0; i <= N_i - 1; i++)

for (int j = 0; j <= N_j - 1; j++)

myArrayVC[i, j] =

myArrayVC->SetValue(myObject->myFunction1(2000, 2), 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.
Nov 20 '05 #1
11 2171
Cor
Hi Dr, Zharkov,

You can have a look what remoting can do for you, but if it will go I do not
know, this is a very special application.

I think, that in this cases the array is first written to disk and than
readed again.

Cor

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(ByVal N_i As Integer, _

ByVal N_j As Integer) As Array

N_i = 2000

N_j = 2

Dim myArrayVB As Array = _

Array.CreateInstance(GetType(Single), N_i, N_j)

For ii As Integer = 0 To N_i - 1

For jj As Integer = 0 To N_j - 1

myArrayVB(ii, jj) = 1

Next

Next

Return myArrayVB(, )

End Function

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 Panel (on which we want to
build a surface myArrayVB with the help of method DrawLine), and we write
the code:

#using <mscorlib.dll>

#using "Debug\ComponentVB.dll"

private:

System::Void panel1_Paint(System::Object * sender,

System::Windows::Forms::PaintEventArgs * e)

{

ComponentVB::Class1* myObject =

new ComponentVB::Class1();

int N_i = 2000;

int N_j = 2;

float myArrayVC __gc[,] = new float __gc[N_i, N_j];

for (int i = 0; i <= N_i - 1; i++)

for (int j = 0; j <= N_j - 1; j++)

myArrayVC[i, j] =

myArrayVC->SetValue(myObject->myFunction1(2000, 2), 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.

Nov 20 '05 #2
Dear Mr. Cor.

Many thanks for your answer.

Inform, please, what code writes on disk the myArrayVB(2000, 2) from VB .NET
2003,

and then copies myArrayVB(2000, 2) from disk on myArrayVC[2000][2] in VC++
..NET 2003?

Beforehand many thanks for the answer, Dr. Zharkov V.A., Moscow, Russia.
Nov 20 '05 #3
Cor
Hi Pan Zharkov,

The VB.net part
\\\
Dim sw As New StreamWriter("TestFile.txt")
sw.Write(myArrayVB(2000, 2).ToString)
sw.Close()
///

Cor
Nov 20 '05 #4
Dear Mr. Cor.
Many thanks for your very valuable consultation. Now we know, how to export
an array from project VB in the file ("D:\MyDocs\MyTest.txt") and to read
out this array from the file in project VC++. However is impossible to us
export of an array from VB in VC++ on scheme "component - client".

We want to export myArrayVB (2000, 2) of VB .NET 2003 in myArrayVó [2000, 2]
of VC++ .NET 2003 on scheme "component - client".

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::PaintEventArgs * 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.
Nov 20 '05 #5
Cor
Hi Pan Zharkov,

I think the big problem is that it is for me totally unclear what you want
to archieve.
(I told you how to write the datapart from the array you showed to disk, but
do absolutly not understand what you want to do with it).

Are there two programs working parallel or serial?

Do you want transport data to them?

And what data, a part of the table or the complete table?

Cor
Nov 20 '05 #6
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::PaintEventArgs * 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.
Nov 20 '05 #7
Cor
Hi Dr. Zharkov,

It is not easy, but I am afraid this goes to nothing,

I made a piece of program, a XML dataset that write the complete table to
disk.
My earlier sample did give you only one item as I asumed that was needed
from the table.

How you can read such a xml dataset in C++ I really do not know, so that you
can maybe ask as Jay B earlier adviced, ask in the VB group.

I did not tested, but it should make a dataset I think, but because I cannot
test it, I am not sure of that so you have to try it. When it is written to
disk, it should read as an XML file with in this sample 2 rows and 2001
items.

Private Sub PictureBox1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles PictureBox1.Paint
Dim ds As New DataSet
Dim dt As New DataTable("Zharkov")
Dim i, j As Integer
Dim N_x As Integer = 2000
Dim N_y As Integer = 1
For i = 0 To N_x
Dim dc As New DataColumn(Chr(i-tostring))
dc.DataType = System.Type.GetType("System.Single")
dc.GetType()
dt.Columns.Add(dc)
Next
Dim myObject As New ComponentVB.Class1
For i = 0 To N_x
Dim dr As DataRow
For j = 0 To N_y
dr = dt.NewRow
dr(i, j) = myObject.myFunction1(i, j)
Next
Next
ds.WriteXml("mypath")
///
End Sub
Nov 20 '05 #8
Cor,
How you can read such a xml dataset in C++ I really do not know, so that you can maybe ask as Jay B earlier adviced, ask in the VB group. Did you mean ask in the C++ group?

As he is asking in the VB group, and seems to have an answer for his C++
questions...

Jay

"Cor" <no*@non.com> wrote in message
news:ud**************@TK2MSFTNGP09.phx.gbl... Hi Dr. Zharkov,

It is not easy, but I am afraid this goes to nothing,

I made a piece of program, a XML dataset that write the complete table to
disk.
My earlier sample did give you only one item as I asumed that was needed
from the table.

How you can read such a xml dataset in C++ I really do not know, so that you can maybe ask as Jay B earlier adviced, ask in the VB group.

I did not tested, but it should make a dataset I think, but because I cannot test it, I am not sure of that so you have to try it. When it is written to disk, it should read as an XML file with in this sample 2 rows and 2001
items.

Private Sub PictureBox1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles PictureBox1.Paint
Dim ds As New DataSet
Dim dt As New DataTable("Zharkov")
Dim i, j As Integer
Dim N_x As Integer = 2000
Dim N_y As Integer = 1
For i = 0 To N_x
Dim dc As New DataColumn(Chr(i-tostring))
dc.DataType = System.Type.GetType("System.Single")
dc.GetType()
dt.Columns.Add(dc)
Next
Dim myObject As New ComponentVB.Class1
For i = 0 To N_x
Dim dr As DataRow
For j = 0 To N_y
dr = dt.NewRow
dr(i, j) = myObject.myFunction1(i, j)
Next
Next
ds.WriteXml("mypath")
///
End Sub

Nov 20 '05 #9
Doh!
As he is asking in the VB group, and seems to have an answer for his C++
questions... That should be "and no-one seems to ahve an answer for his C++ questions"...

Jay

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl... Cor,
How you can read such a xml dataset in C++ I really do not know, so that

you
can maybe ask as Jay B earlier adviced, ask in the VB group.

Did you mean ask in the C++ group?

As he is asking in the VB group, and seems to have an answer for his C++
questions...

Jay

"Cor" <no*@non.com> wrote in message
news:ud**************@TK2MSFTNGP09.phx.gbl...
Hi Dr. Zharkov,

It is not easy, but I am afraid this goes to nothing,

I made a piece of program, a XML dataset that write the complete table to disk.
My earlier sample did give you only one item as I asumed that was needed
from the table.

How you can read such a xml dataset in C++ I really do not know, so that

you
can maybe ask as Jay B earlier adviced, ask in the VB group.

I did not tested, but it should make a dataset I think, but because I

cannot
test it, I am not sure of that so you have to try it. When it is written

to
disk, it should read as an XML file with in this sample 2 rows and 2001
items.

Private Sub PictureBox1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles PictureBox1.Paint
Dim ds As New DataSet
Dim dt As New DataTable("Zharkov")
Dim i, j As Integer
Dim N_x As Integer = 2000
Dim N_y As Integer = 1
For i = 0 To N_x
Dim dc As New DataColumn(Chr(i-tostring))
dc.DataType = System.Type.GetType("System.Single")
dc.GetType()
dt.Columns.Add(dc)
Next
Dim myObject As New ComponentVB.Class1
For i = 0 To N_x
Dim dr As DataRow
For j = 0 To N_y
dr = dt.NewRow
dr(i, j) = myObject.myFunction1(i, j)
Next
Next
ds.WriteXml("mypath")
///
End Sub


Nov 20 '05 #10
Cor
Hi Dr Zharkov,

So much to type, and then I would write VC and type VB.

Luckily Jay B showed it to me, I mean of course VC newsgroup for the C++
Question.

Thanks Jay.

Cor
Nov 20 '05 #11
Dear Mr. Jay B. Harlow.

Dear Mr. Cor.

Many thanks for your help in the decision of my problems on export of an
array from Visual Basic in Visual C++. Mr. Cor has very much helped me to
write an array on a disk in project of VB and to read an array in project of
VC++. Mr. Jay B. Harlow has very much helped me to write correctly an array
as component of VB. Mr. Emad Barsoum from group : vc.libraries for 15.2.04
has very much helped me to write correctly a code for reading an array for
client of VC++ in the following kind:

int i, j;

int N_x = 2001;

int N_y = 2;

Array* myArray = (Array*)myObject->myFunction1();

float myArrayVC __gc[,] = new float __gc[N_x, N_y];

for (i = 0 ; i <= N_x - 1; i++)

for (j = 0 ; j <= N_y - 1; j++)

myArrayVC[i, j] =

System::Convert::ToSingle(myArray->GetValue(i,j));

Big many thanks. Dr. Zharkov V.A., Moscow, Russia.
Nov 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
32
by: Carson | last post by:
Hi , Is there a very efficient way to set a double array to 0 ? (I have tried memset, but the result doesn't look correct.) Carson
1
by: david | last post by:
I have a question (not sure if just a newbie one, or a stupid one) whose answer I couldn't find on the C# books and tutorials I could put my hands on. Consider the following useless class (could...
2
by: david | last post by:
Well, as a matter of fact I_HAD_MISSED a basic thing or two, anyway, although Ollie's answer makes perfectly sense when dealing with classes, it doesn't seem to me to apply as well if you have to...
15
by: Kueishiong Tu | last post by:
How do I convert a Byte array (unsigned char managed) to a char array(unmanaged) with wide character taken into account?
2
by: Todd | last post by:
Hello Folks I am trying to create an xml file from a class containing a polymorphic array. The example: AutoCompany contains an array of Vehicles(base class) which can either be Cars or...
4
by: Charles | last post by:
Hello Everyone, I have been gettting great feedback from microsoft.public.vc.language group but after doing more searching I think my post should be directed to this group. I am trying to make...
17
by: Fabry | last post by:
Hi All, I'm new of this group and I do not know if this is the correct group for my question. I have a DLL with its export library (.lib) wrote in Borland C++ 6. In borland everything is OK and...
6
by: Jeffrey Walton | last post by:
Hi All, Sorry about dropping thish on M.P.D.L.CSharp. There is no M.P.D.L.VC. So I hope someone has come across the issue... How does one export a function (not a class) in a managed Dll? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.