Results 1 to 4 of 4

Thread: Problems with Arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    1

    Unhappy

    I don't know if anyone could help me with this problem but if they could i would appreciate it.

    Anyway I have set up a dynamic 2Dimensional array. I found that it can only be re-sized once and after that I get a subscript out of range. 1D Arrays re-size ok in the same situation. Am I doing something wrong or is this simply a bug with Vb and anyone know a way round it

    This bit would go in the genral declerations
    Dim MyArray() As Variant

    Command1_Click() 'you get the idea
    ReDim MyArray(1,1) As Variant 'This works
    ReDim MyArray(2,2) As Variant

    'The second dimming of the array brings up the error out of subscript

    Right for anyone who is interested I now know the problem which is a limitation of 2d Arrays when you re-size them
    Only the last dimension can be altered. So an Array can be changed from (1,1) to (1,2) for example but not (1,1) to (2,1).

    thanks for everyones help

    This below doesn't work either

    ReDim MyArray(1,1)
    ReDim MyArray(2,2)

    Or if i use variables instead of numbers

    [Edited by eble1 on 09-10-2000 at 10:59 AM]

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    let's see a sampling of the code causing the problem please!
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    How about:
    Code:
    Dim MyArray() As Variant
    Public Sub Command1_Click()
        ReDim MyArray(1,1)
        ReDim My Array(2,2)
    End Sub
    Don't redefine the array's type.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Talking Not expert, but try this

    What if in the Gen Dec area, you use

    Public MyArray as Variant.

    Also have you tested only the 2D Array (redim marray(2,2)) by itself?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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