View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech[_2_] Jim Rech[_2_] is offline
external usenet poster
 
Posts: 533
Default Array Memory Size

Start with UBOUND position and iterate backwards to find the last used
element?

--
Jim
"Trip" wrote in message
...
| Hello All,
|
| I'm hoping to find a Win32 API which will provide me the memory size
| of a safe array dimmed in VBA.
|
| Here's what I am trying to solve...
|
| I currently calculate a moving average of the last x elements stored
| within an array. Step one is to find the last element used within the
| array, for which I currently use a self-written binary search. Next,
| I use a Win32 api to copy the segment of memory (CopyMemory)
| containing the elements I want to average into another array so that I
| can execute:
|
| Avg = Application.Average(arrayTwo)
|
| The slowest part of this oppoeration is the binary search. So, I was
| hoping to get the size of the memory used by the array and then devide
| the returned value by the number of bytes per element to determin the
| number of the last element used within the array. (Please note,
| Ubound only gives me the upper bound of the array, not the last used
| element in the array).
|
| Any ideas??
|
| Thanks!
|
| Trip