Passing Multidimensional Array in VB.net

Passing Multidimensional Array in VB.net

meck
Collaborator Collaborator
2,271 Views
5 Replies
Message 1 of 6

Passing Multidimensional Array in VB.net

meck
Collaborator
Collaborator

Hi everyone,

I'm trying to create a .DLL to access a database from within iLogic. I'm new to VB.net so I'm having some trouble. I need to pass a multidimensional array as an argument to the DLL, but when I try to run the code I get an error that says "Number of indices exceeds the number of dimensions of the indexed array."

I've search the web for VB.net help, but all of the examples I've found are doing what I'm doing.

Any suggestions would be appreciated!

 

Here is my code..

The errors occur on the sData(0,i) and the sData(1,i)

I left all the database code off, because passing the array is the big issue I believe.

 

Public sub AddRecord(ByRef sData() As String)

    For i = 0 to FieldQty

         rst.Fields.Item(sData(0,i).Value = sData(1,i)

    Next

End Sub

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
2,272 Views
5 Replies
Replies (5)
Message 2 of 6

meck
Collaborator
Collaborator
I have discovered that unlike VB6 you must put a comma to indicate the number of dimensions in the array you are passing. Public sub AddRecord(ByRef sData(,) As String) Thanks for reading. Meck
Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
Message 3 of 6

Anonymous
Not applicable

a sample loop for accessing multi diemsional array

 

For i = 0 To strArr.GetUpperBound(0)
  For j = 0 To strArr.GetUpperBound(0)
    MsgBox(strArr(i, j))
  Next
Next

 

full source code

 

http://net-informations.com/vbprj/programflow/multi-dimensional-array.htm

 

antonio.

 

0 Likes
Message 4 of 6

mgorecki
Collaborator
Collaborator

Hello,

I'm trying to send a dll an array (it's only a 2D array) and I've looked all over the internet, but I can't find anything that helps.  I have found a couple of posts saying it can't be done, but I don't believe that.

I have a program that launches AutoCad.  It is then supposed to create an array and then launch another program in AutoCad and pass it the array.  The last program will take the array and run with it.

 

Is there a way to do that?  If so, can you explain?

I'm using AutoCad 2010.

 

Thanks

0 Likes
Message 5 of 6

philippe.leefsma
Alumni
Alumni

Hi Mgorecki,

 

It is not clear what you are looking for, you would need to provide a bit more context... From my understanding you are trying to pass an array between two .Net applications but what kind of interprocess communication are you using? If you use COM then you will have to use COM-supported types. If your 2 exes are .Net you may want to choose a different kind of communication than COM.

 

That question doesn't seem like an Autodesk-specific topic, unfortunately we focus here on queries that are directly related to the use of our APIs. You will have more chances asking this on a general purpose programming forum. Here is a link I found while googling "passing array com .net", it may be relevant for you:

 

http://stackoverflow.com/questions/2863779/passing-a-safearray-from-c-sharp-to-com

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 6 of 6

mgorecki
Collaborator
Collaborator

I have a .dll that launches AutoCad and will create a drawing based on the input from the array passed to it.

What I don't have, is the way to pass the array from an exe to my dll.

0 Likes