I have the following code:
REM ***** BASIC *****
Option Explicit
Sub Main
CreateArraySheet2
End Sub
Sub CreateArraySheet2
Dim Sheet as Object
Dim Cell as Object
Dim NumberOfDataPoints as Integer
Dim c as Integer
Dim d as Integer
Sheet = ThisComponent.Sheets.getByName("Sheet2")
Cell = Sheet.getCellByPosition(16,4)
NumberOfDataPoints = Cell.Value
Dim Array(1 to 3, 1 to NumberOfDataPoints) as Single
For c = 1 to 3
Cell = Sheet.getCellByPosition(c,4)
For d = 1 to Cell.Value
Cell = Sheet.getCellByPosition(c,d+6)
Array(c,d) = Cell.Value
Next d
Next c
End Sub
When Cell = Sheet.getCellByPosition(16,4) gets above 7000 the array will start filling the array in reverse order with the value in Array(1,1). the higher the Cell value goes the the more the array fills up with the first value. What is going on?
I changed the Macro to:
Sub CreateArraySheet2
Dim Sheet as Object
Dim Cell as Object
Dim NumberOfDataPoints as Integer
Dim Data as Object
Dim c as Integer
Dim d as Integer
Sheet = ThisComponent.Sheets.getByName("Sheet2")
Cell = Sheet.getCellByPosition(16,4)
NumberOfDataPoints = Cell.Value
Dim Array(1 to 3, 1 to NumberOfDataPoints) as Single
For c = 1 to 3
Cell = Sheet.getCellByPosition(c,4)
For d = 1 to Cell.Value
**Data = Sheet.getCellByPosition(c,d+6)**
**Array(c,d) = Data.Value**
Next d
Next c
End Sub
Still has the same behavior. This seems to be tied to the size of the Array. I did an Array(1 to 3, 1 to 100) with the first macro and It worked fine.
The behavior seems to start when Cell = Sheet.getCellByPosition(16,4) is equal to 5458.