Ask Your Question
0

Array in libreoffice macro

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

Fede gravatar image

updated 2017-01-27 15:54:33 +0200

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 close merge delete

1 Answer

Sort by » oldest newest most voted
0

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
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 609 times

Last updated: Jan 27 '17