Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maximum array size

Status
Not open for further replies.

sagitt

Technical User
Dec 2, 2009
8
IE
Hi All,

Does anybody know what is the maximum size (length) for one dimensional array?

I have declared an array as Variant and array index as Long, however when I try to populate the array with a data it gives me an Overflow error (number 6) when it reach 32768 - which my understanding is a maximum limit for an Integer type variables.

I can write procedure that will empty the array to a file but I'd like to avoid that situation if I could.

Does anybody know how to solve this problem?

Here is the code, it works, but if you change lndx value to be one greater (32768) it gives an overflow error.

Sub Main
dim lNdx as variant
dim arr() as variant

lndx = 32767
redim preserve arr(lndx)
msgbox ubound(arr)

End Sub

regards, Dom
 
Assuming Extra Basic.

Array subscript is limited to the scope of the integer Data Type which ranges from -32768 to 32767.

dim arr(32768) as variant
Produces the same result your expieriencing when overflowing the integer.

[small]Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black[/small]
 



One technique that you could use to 'expand' the array size, would be to set your lower bound to a negative number, within the limits. This way, you could get 65536 array values.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
After a long battle I got my task done this way:

I needed capacity of approx 80 000 entries, so anyway one dimensional array would not do the job for me. So I started some experiments with 2D arrays. For unknown to me reasons extra basic is limited to 65000 values for 2D array; the best configuration for subscripts I managed is 200 x 325. To be honest I have not tried to make negative values for subscripts (I presume if it is possible for 1D array it should work for 2D as well). To overcome the limit of 65000 I set up two semi-parralel 2D arrays. I know that solution does not look good, but it works for me. So at the end I deal with two arrays 2D each and I can have up to 130000 values, which is more than enough for me.

thanks for replays and advises,
regards, sagitt
 
Skip,

I use Extra 8.0 and I tried to create array with negative subscripts and all I get is an error of subscript out of range any time I use negative values.

How can I manage to get it done on Extra Basic?
Here is my code:

Sub Main

dim i as long
dim tmp() as variant
i = -1
redim preserve tmp(i)
tmp(i) = a
End sub

regards, sagitt
 


Sorry. My mistake. The lower bound of an array can only be 0 or 1, depending on Option Base.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top