My question is simple: Is it possible to, like I would do in C++, to retrieve two parts of an array in VBA by reference? It’s been a while since I coded in C++, so I can’t quite remember how I do it right now. Maybe if I remember, I’ll have an example.
What I am trying to do is sort an array of objects by a single Double-type property. I’ve done it before in C++, just don’t have the source code anymore.
I doubt that there is a predefined function to use for this, but if anybody knows a better solution, it’ll be welcomed greatly. 😉
This is basically what I want:
source array(0, 1, 2, 3, 4, 5)
split source array in two
array a(0, 1, 2)
array b(3, 4, 5)
set array a(0) = 4
array a(4, 1, 2)
array b(3, 4, 5)
source array(4, 1, 2, 3, 4, 5)
Of course this is only an abstract description.
I apologize if there already is a question dealing with this, I then have not found it.
Yes, you can. You will have to construct a SAFEARRAY descriptor manually though, so that it points to a subset of the original array’s data.
Module:
Usage:
Be sure to manually destroy the child arrays before the original array variable gets destroyed by either
Eraseor going out of scope.However, it might be simpler to just pass the whole an array by reference to a subroutine and also provide the index number from which to start processing.