ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change LBound of array (https://www.excelbanter.com/excel-programming/329568-change-lbound-array.html)

R Avery[_2_]

Change LBound of array
 
I have a (1,1) based array which i want to turn into (0,0) based array,
how do I do this quickly? I think it should simply be a matter of
changing some parameters in the corresponding SAFEARRAY structure, but
I don't know how to do this without causing crashes.

Doing this any other way that actually requires moving the data of the
array in memory is unacceptable. Any help would be appreciated!


Jim Thomlinson[_3_]

Change LBound of array
 
Have you tired Option Base. Here is a link to the article

http://msdn.microsoft.com/library/de...OptionBase.asp

HTH

"R Avery" wrote:

I have a (1,1) based array which i want to turn into (0,0) based array,
how do I do this quickly? I think it should simply be a matter of
changing some parameters in the corresponding SAFEARRAY structure, but
I don't know how to do this without causing crashes.

Doing this any other way that actually requires moving the data of the
array in memory is unacceptable. Any help would be appreciated!



R Avery[_2_]

Change LBound of array
 
This happens when i do

dim rng as excel.range
dim vnt as variant

set rng=selection
vnt=rng

then vnt will be a (1,1) based array, regardless of the OPTION BASE
statement.


Alan Beban[_2_]

Change LBound of array
 
R Avery wrote:
This happens when i do

dim rng as excel.range
dim vnt as variant

set rng=selection
vnt=rng

then vnt will be a (1,1) based array, regardless of the OPTION BASE
statement.

Why is it unacceptable to "move the data of the array in memory" to make
the change to 0 base in both dimentions?

Alan Beban

R Avery[_2_]

Change LBound of array
 
because i know that its possible with a few API calls to change the
base of the SAFEARRAY without having to move the actual data in memory
anywhere. The reason its unacceptable is that it's too slow. I'm
loading like 100 MB of Excel data at a time into an array, many times,
and copying the data to a whole new array would impact performance.

It has to be zero-based because i force all my objects to have
zero-based collections and arrays in order to avoid confusion.



All times are GMT +1. The time now is 08:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com