473,508 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transferring arrays from C DLL's to VB.Net

Transferring arrays from C DLL's to VB.Net

I have a DLL written in C. This DLL reads a text file and creates a several
very large arrays, 500,000 points and even larger. I would like the get the
data in VB.Net so that I can plot it. Presently I am creating an equally
sized array in VB and copying the data from the DLL's array into the VB
array.

There must be a better way. I looked into using a SAFEARRAY but it looks to
me that VB.Net doesn't use them as a native array structure.

Can I get the DLL's pointer to the array and use it in VB.Net?
Can I otherwise package the array in the DLL so that I do not need to
duplicate it?

################################
Details:

The VB.Net program is just a UI for the DLL's and allows the user to select
the file to process and will get the data and plot it, so the VB is just a
shell for the real work being done in the C DLL's.

The DLL's are used in a test system. The data is read from a text file and
processed, so the arrays are not the data in the text file, but rather an
analysis of that data. C Dll's are used so that I can be platform
independent, that is, I need to be able to use this DLL code in other test
systems like National Instruments Labview and Agilent Vee.

I have the system working now, except that it is slower and uses more
resources because of the arrays, there are 30 in all. I usually duplicate 2
at a time, but now I find myself re-reading the same arrays several times
and I am looking for a way to improve performance.

Nov 17 '05 #1
1 4142
You can create a managed C++ class that implements an appropriate collection
interface,
wrapping up a pointer to the array.

If you do not require random access to the array elements you can get away
with
implementing either System::Collections::IEnumerable or
System::Collections::ICollection.
If you require random access to the array you would need to implement
System::Collections::IList, or add an indexer to your class.

"Michael Fitzpatrick" <mm*****@DO-NOT-SPAM-codeinsight.com> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
Transferring arrays from C DLL's to VB.Net

I have a DLL written in C. This DLL reads a text file and creates a several very large arrays, 500,000 points and even larger. I would like the get the data in VB.Net so that I can plot it. Presently I am creating an equally
sized array in VB and copying the data from the DLL's array into the VB
array.

There must be a better way. I looked into using a SAFEARRAY but it looks to me that VB.Net doesn't use them as a native array structure.

Can I get the DLL's pointer to the array and use it in VB.Net?
Can I otherwise package the array in the DLL so that I do not need to
duplicate it?

################################
Details:

The VB.Net program is just a UI for the DLL's and allows the user to select the file to process and will get the data and plot it, so the VB is just a
shell for the real work being done in the C DLL's.

The DLL's are used in a test system. The data is read from a text file and
processed, so the arrays are not the data in the text file, but rather an
analysis of that data. C Dll's are used so that I can be platform
independent, that is, I need to be able to use this DLL code in other test
systems like National Instruments Labview and Agilent Vee.

I have the system working now, except that it is slower and uses more
resources because of the arrays, there are 30 in all. I usually duplicate 2 at a time, but now I find myself re-reading the same arrays several times
and I am looking for a way to improve performance.

Nov 17 '05 #2

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

Similar topics

1
368
by: Dave A | last post by:
The following C code specifies the interface into a DLL. I need to access it from C#. How do I do declare it? I have done simple ones before but this particular API requires a pointer to a struct...
34
3643
by: Dennis | last post by:
I would like to dynamically allocate in a sub a 2 dimensional Array float *myarray = new float ; of course I get an error. How do you allocate a 2D array using the New operator? I...
9
1616
by: Merrill & Michele | last post by:
What follows is an adaptation of the second program in K&R §5.10. The changes are to elucidate (validate) the difference (sameness) of char * and char**. I cannot for the life of me understand...
33
3823
by: Peter Seaman | last post by:
I understand that structures are value types and arrays and classes are reference types. But what about arrays as members of structures i.e. as in C struct x { int n; int a; }
1
3427
by: Kurt Richardson | last post by:
Hi all Sorry to bother you with what is probably a really trivial question for you C++ experts. My programming skill are pretty amateur, but I'm pretty good at VB.NET. However, I'm wanting to...
2
1925
by: Michael Fitzpatrick | last post by:
I have a DLL written in C. This DLL reads a text file and creates a several very large arrays, 500,000 points and even larger. I would like the get the data in VB.Net so that I can plot it....
15
5060
by: http://www.visual-basic-data-mining.net/forum | last post by:
Does anyone have any idea how to transferring data from TextBox1 in form1 to textBox2 in form2..... That means after i fill in any data in textBox1 and click Next button... It will bring me to...
10
4968
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I...
1
3584
by: joesfer | last post by:
I'm trying to develop a graphical user interface for a renderer i've got written in an unmanaged C++ DLL with C#. During the rendering process, several images are sent to a delegate as float*...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
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,...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.