Results 1 to 6 of 6

Thread: Multidimension Array : Subscription out of range

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Multidimension Array : Subscription out of range

    Hi All,

    I have defined an Array in global with 2 Dimension.

    However, I'm getting error message "Subscription out of range"

    I did a search from internet I found there is not allowed to preserve the multi dimension array unless the row is fixed.

    Example,

    Dim MultiDimension() as string

    redim preserve MultiDimension (0,1) --> "ALLOWED"
    redim preserve MultiDimension (0,2) --> "ALLOWED"
    redim preserve MultiDimension (1,2) --> "not ALLOWED"

    Anyone here have resolution to overcome my problem?

    Mind to share it? Thank you very much.
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  2. #2
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Multidimension Array : Subscription out of range

    It's best if you know how many row/columns you need.

    i.e
    Dim MultiDimension(4,5) as string
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Multidimension Array : Subscription out of range

    you can only redimension the last dimension of a multi dimensional array with preserve

    from msdn
    If you use the Preserve keyword, you can resize only the last array dimension and you can't change the number of dimensions at all. For example, if your array has only one dimension, you can resize that dimension because it is the last and only dimension. However, if your array has two or more dimensions, you can change the size of only the last dimension and still preserve the contents of the array. The following example shows how you can increase the size of the last dimension of a dynamic array without erasing any existing data contained in the array.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: Multidimension Array : Subscription out of range

    Thanks all,

    If I want to store the values in multi dimension array or some others method as global variable.

    Any others way could be used?
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  5. #5
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Multidimension Array : Subscription out of range

    A multicolumned listview? But in that case you need a form to be always loaded on which the listview will be to use it "globaly" and at all times.

  6. #6
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Multidimension Array : Subscription out of range

    Typically a udt array will solve this problem. What kind of data are you trying to put in the array?

Posting Permissions

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



Click Here to Expand Forum to Full Width