Hi I am new to Libre Office Basic. I do have some background in Visual Basic.net, but it has been many years ago. What I am trying to accomplish in part is to get the values of a range of cells into a one-dimensional array. I declared the array thus:
Dim Data(14) as Single
inside a For Next loop. I want the array to be reset every time through the loop.
So the pertinent code is as follows:
Sub Main
Dim i, j As Integer
For i = 3 To shtCount Step 3
Rem I want Data() to be reset every time through the loop
rem Dim i as Integer
Dim Data(14) as Single
oSheet = ThisComponent.Sheets(i)
Rem oRng = oSheet.getCellrangeByPosition(3,33,19,33) 'D34:S34(left, top,right,bottom)
oRng = oSheet.getCellRangeByName(“D34:S34”)
Rem oRng = oSheet.Range(“D34:S34”)
Data = oRng.Data
j = myMatch(array(Data))
(subsequent code omitted)
End Sub
I’ve also tried to get the Range with the Rem’ed out code:
oRng = oSheet.getCellrangeByPosition(3,33,19,33) 'D34:S34(left, top,right,bottom)
So when I watch Data in the watch window, before the line
Data - oRng.Data is executed, Data is a one-dimensional array populated with zeros as expected. After execution of the line, Data becomes a two-dimensional array with the expected values in the second dimension. My question is why, and how do I keep a second dimension from being added and get the values in the first dimension as expected?
Another question would be why when I enter the Function myMatch (in this same module the parameter is missing?
Function MyMatch(matchData() as Single) as Integer
Dim i as Integer
Dim mPosition as Integer
Dim theMax as Single
theMax = 0
mPosition = 0
For i = LBound(matchData) to UBound(matchData)
If matchData(i) > theMax Then
theMax = matchData(i)
mPosition = i
end If
next i
myMatch = mPosition
End Function
Do you need anymore information?