Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Passing Multidimensional Array in VB.net

5 REPLIES 5
Reply
Message 1 of 6
meck
1722 Views, 5 Replies

Passing Multidimensional Array in VB.net

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
5 REPLIES 5
Message 2 of 6
meck
in reply to: meck

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
Message 3 of 6
Anonymous
in reply to: meck

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.

 

Message 4 of 6
mgorecki
in reply to: meck

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

Message 5 of 6
philippe.leefsma
in reply to: mgorecki

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

Message 6 of 6
mgorecki
in reply to: philippe.leefsma

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report