Results 1 to 4 of 4
  1. #1
    Ellpee is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    80

    2D Array -- What's Wrong with This?

    Why does this give me a subscript out of range error on the second line? Seems super-simple, so I must be having a brain fart. Just trying to understand how to put values in the array and then get them out …..


    Public Sub Testing3()
    Dim TestArray(5, 2) As Variant
    TestArray(0, 0) = 5
    TestArray(0, 1) = "Fish"


    Debug.Print TestArray(0, 1) & " " & TestArray(0, 2)
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    It may be 1 based and not 0 based: testarray(1,1) = 5
    also, use collections. Arrays died in the 90s.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I do not get an error when I execute Sub Testing3().
    Also, there is no data in TestArray(0, 2) - it is empty.

  4. #4
    Ellpee is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    80
    Big Duhhh to me, had set up a small db for testing and set it to base 1. And yes, nothing in 0,2, cause it doesn't exist. Thanks to both for breaking my brainlock.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-26-2019, 07:27 PM
  2. CSV into array
    By jasonvanwyk in forum Import/Export Data
    Replies: 7
    Last Post: 02-03-2018, 10:05 PM
  3. Need help with array
    By programmingbeginner in forum Programming
    Replies: 14
    Last Post: 08-28-2014, 01:30 PM
  4. export to a 2D array
    By pradeep.sands in forum Forms
    Replies: 4
    Last Post: 07-24-2013, 08:59 AM
  5. Array will not ReDim...
    By yeah in forum Programming
    Replies: 1
    Last Post: 10-08-2011, 06:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums