VBA Code Protection > Supported VBA syntax by compiler > Arrays


The compiler offers basic support for array constructors and variant arrays. To construct an array, use "[" and "]" chars. You can construct multi-index array nesting array constructors. You can then access arrays using indexes. If array is multi-index, separate indexes using ",".

If variable is a variant array, the compiler automatically supports indexing in that variable.

Arrays in the compiler are 0-based index. Some examples:

NewArray = [ 2,4,6,8 ]

Num = NewArray[1] //Num receives "4"

MultiArray = [ ["green","red","blue"] , ["apple","orange","lemon"] ]

Str = MultiArray[0,2] //Str receives 'blue'

MultiArray[1,1] = "new orange"


Dynamic arrays:

Sub MyProtectedSub(Param1)


' Create a dynamic array

DIM PTIM = VarArrayCreate([0,3000,0,5], 12)

' Assign a value:

PTIM[1,2] = 1530 

'Show the value:

MsgBox (PTIM[1,2]) 

End Sub


If statements


Copyright © 2023 G.D.G. Software