Ask Your Question
0

Array in libreoffice macro [closed]

asked 2017-01-27 15:50:43 +0200

Fede gravatar image

updated 2020-09-21 23:49:01 +0200

Alex Kemp gravatar image

Hello!

I would like to define (in ooo macro) an integer array from 0 to N with "pitch" egual to 10;

For example: [0 10 20 30 .... N]

Could I automate this? Becouse the extrem term N is not costant, it can be change.

Thanks in advance

Fede

LO 5.2 SO Windows 10

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-09-21 23:49:09.810515

1 Answer

Sort by » oldest newest most voted
1

answered 2017-01-27 16:12:30 +0200

JohnSUN gravatar image

updated 2017-01-27 16:13:51 +0200

Do you mean something like this?

Function getNewArray(N As Integer) As Variant
Dim i As Integer
Dim aResult(1 To 1) As Integer
    aResult(1) = 0
    If N > 0 Then 
        ReDim aResult(1 To N)
        For i = 1 To N
            aResult(i) = (i-1)*10
        Next i
    EndIf
    getNewArray = aResult
End Function

Call it as

myArray = getNewArray(5)
edit flag offensive delete link more

Comments

Yes :D Thanks

Fede gravatar imageFede ( 2017-01-28 19:46:55 +0200 )edit

Question Tools

1 follower

Stats

Asked: 2017-01-27 15:50:43 +0200

Seen: 1,508 times

Last updated: Jan 27 '17