21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Arrays 20<br />

ReDim Preserve MyArray(20) As Integer ' Increase in<br />

' data field, while<br />

' retaining content<br />

When you use Preserve, ensure that the number of dimensions and the type of variables<br />

remain the same.<br />

Unlike VBA, where only the upper limit of the last dimension of a data field can be changed through<br />

Preserve, <strong>OpenOffice</strong>.<strong>org</strong> Basic lets you change other dimensions as well.<br />

If you use ReDim with Preserve, you must use the same data type as specified in the<br />

original data field declaration.<br />

Defining values for arrays<br />

Values for the Array fields can be stored like this:<br />

MyArray(0) = "somevalue"<br />

Accessing Arrays<br />

Accessing values in an array works like this:<br />

MsgBox("Value:" & MyArray(0))<br />

Array Creation, value assignment and access<br />

example<br />

And example containing all steps that show real array usage:<br />

Sub TestArrayAxess<br />

Dim MyArray(3)<br />

MyArray(0) = "lala"<br />

MsgBox("Value:" & MyArray(0))<br />

End Sub<br />

Source: http:/ / <strong>wiki</strong>. services. openoffice. <strong>org</strong>/ w/ index. php? title=Documentation/ <strong>BASIC</strong>_<br />

<strong>Guide</strong>/ Arrays&oldid=105637<br />

Principal Authors: Jdpipe, Fpe, Ccornell, TJFrazier, HenningSprang

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!