I need to define one Array, the element inside will be String, but I do not know how many elements at the beginning.
my code is :
Dim my_str_arr() As String
my_str_arr(1) = "Test_Str"
It will show error : Inadmissible value or data type. Index out of defined range.
It works if I define the Array with dimensions defined.
Dim my_str_arr(2) As String
my_str_arr(1) = "Test_Str"
A string array without specified dimensions
A string array without specified dimensions
OpenOffice.org.3.3.0
Re: A string array without specified dimensions
You can use
ReDim Preserve
to change the size of an array while preserving the content. Please see the Help section for information about that command.
ReDim Preserve
to change the size of an array while preserving the content. Please see the Help section for information about that command.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: A string array without specified dimensions
See https://wiki.openoffice.org/wiki/Docume ... ide/Arrays for ways of varying the number of elements in an array via REDIM, or see the section on empty arrays. Note that page also says "There are no practical limits on the indexes or on the number of elements in an array, so long as there is enough memory".
I suggest you read all of the page as you are likely to have other array questions which can be answered by reference to that page.
I suggest you read all of the page as you are likely to have other array questions which can be answered by reference to that page.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Re: A string array without specified dimensions
One Caution... because of some minor annoying faults with OO it can be better to declare my_str_arr() as Variant instead of string. If you're going to use the split function for example...
viewtopic.php?f=45&t=96665
viewtopic.php?f=45&t=96665
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)