Arrays problem Dim My(-1,-1) as String

Dim My(-1,-1) as String

My(0,0)=“Name”
My(0,1)=“Home”

i have error OutOfBounds way

What else could you expect? You haven’t specified any space for the array.

In the same way,

Dim My(-1)
My(0) = “Name”

Gives an OutOfBounds error as well, just like it should.

You at least need

Dim My(0,1)
My(0,0) = “Name”
My(0,1) = “Home”

ok
thanks

hi Tim

I do not know which is the maximum number of items

so how i can make the array for unlimited number of items

You can always increase the values later and it shouldn’t remove the contents.

Gotta love it when the Xojo Engineer uses the word “shouldn’t” :smiley: instead of “won’t”

[quote=238551:@Alexis Colon Lugo]hi Tim

I do not know which is the maximum number of items

so how i can make the array for unlimited number of items[/quote]

You just append the new items to the array.

But you should know that if you have read the documentation on array. THAT should be the first thing you do when you have a problem (look in the documentation), not posting on the forum.

You can’t append to a multi dimensional array. You have to redim.

Dim My(-1,-1) as String Redim My(0,1) My(0,0)="Name" My(0,1)="Home"

I use multidimensional arrays SO rarely and the fact that I’m not in front of my computer this week, i just couldn’t check for sure. So yeah, shouldn’t instead of won’t.

To add to what Greg said, we’re all on vacation right now and shouldn’t be answering forum posts ;).

Shouldn’t :wink: