Late array binding

I am seriously obsessed with it because I cannot find anything with late array binding in VBA. Is it possible? If so, how? If not, why?

Note. I do not mind, if possible, using relatives. Net / C # types like

Dim o as Object set o = CreateObject("System.Array") 

Even if System.Array is COM visible , creating it seems impossible.

Any idea how to bind the data type of an array in VBA late?

please do not mention dictionary or collections as this question is very specific to arrays


Additional Information:

This question is about the next question is my other question . Since it seems impossible to pass your own VBA array to the native .Net collection without loops, I just wonder if it is possible to later bind the array as shown by safearrays, which will mean that they are compatible and therefore pass the VBA array to a. A clean one would be possible - please correct me if I am completely mistaken.

+6
source share
1 answer
  set o = CreateObject("System.Array") 

System.Array is an abstract class. So no, it won’t work. Array types are special; they are usually created by the compiler. The backdoor is Type.MakeArrayType (), and you can create it.

Nothing you would like to use. Do not try so hard, any VBA array is already converted to System.Array. It's just a often inappropriate array that doesn't have its first element in index 0. VBA likes 1 unless you use syntax like Dim arr(0 To 3) As Double or have Option Base 0 . It is not always possible to use Array.GetValue () to access an inappropriate array. Check out your other question for a sample applet.

+3
source

Source: https://habr.com/ru/post/969591/


All Articles