+ Reply to Thread
Results 1 to 5 of 5

Change LBound of array

  1. #1
    R Avery
    Guest

    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!


  2. #2
    Jim Thomlinson
    Guest

    RE: 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!
    >
    >


  3. #3
    R Avery
    Guest

    Re: 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.


  4. #4
    Alan Beban
    Guest

    Re: 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

  5. #5
    R Avery
    Guest

    Re: 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.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1