on
I am getting an overflow message when loading a list box with 32000 records can someone help please.
For i = 0 To arrsize
combinedarray(i) = frmsort.List2.List(i)
Next

Thanks
Comment
Watch Question

Do more with

EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Software Developer

Commented:

Hi there.

Try

For i = 0 To arrsize - 1
combinedarray(i) = frmsort.List2.List(i)
Next

As you are using zero-based arrays, the start index being 0, you must use the '- 1' at the end of the For i = 0 line.

Hop this helps.
Jas.

Commented:
Your code sample does not match the problem description
>  combinedarray(i) = frmsort.List2.List(i)

This code doesn't load a listbox, it assigns a value to an array.

Commented:
Have you tried:

For i = 0 To arrsize
ReDim Preserve combinedarray(i)
combinedarray(i) = frmsort.List2.List(i)
Next

Commented:
dancebert is correct I had loaded my list box with the values I am writing them out to an array.  So that would mean my array is not big enough?

below is my  code to make the array the same size at the list box

i = i - 1
x = i
Dim arrsize As Long
arrsize = i
Do

If i = "10" Then
MsgBox ("here")
End If
i = i - 1
Loop While (i <> 0)
Dim probelistvariable
' write to array from list

ReDim combinedarray(frmsort.List2.ListCount )
For i = 0 To arrsize
combinedarray(i) = frmsort.List2.List(frmsort.List2.ListCount)
Next

Commented:
I don't see where you original dim combinedarray.  What data type are you using?  If you did

dim combinedarray() as integer

You'd get an overflow error if you attempted to assign a value that was larger than the largest integer.
Commented:

Dim i As Integer, combinedarray() As String

For i = 0 To frmsort.List2.ListCount - 1
ReDim Preserve combinedarray(i)
combinedarray(i) = frmsort.List2.List(i)
Next i

Commented:
Is the record count exactly 32k or is it going over integer limit, hence making i to overflow.

Commented:
What was combinedarray dim'd as before you changed it to string?
What datatypes are you storing in the array?

If you're storing numbers into a string that will cure your overflow error.  So would have my solution, which was offered first.

Do more with