Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use a user defined type containing an array of strings which will be the inner array. Then you can use an array of this user defined type as your outer array.</p> <p>Have a look at the following test project:</p> <pre><code>'1 form with: ' command button: name=Command1 ' command button: name=Command2 Option Explicit Private Type MyArray strInner() As String End Type Private mudtOuter() As MyArray Private Sub Command1_Click() 'change the dimensens of the outer array, and fill the extra elements with "1" Dim intOuter As Integer Dim intInner As Integer Dim intOldOuter As Integer intOldOuter = UBound(mudtOuter) ReDim Preserve mudtOuter(intOldOuter + 2) As MyArray For intOuter = intOldOuter + 1 To UBound(mudtOuter) ReDim mudtOuter(intOuter).strInner(intOuter) As String For intInner = 0 To UBound(mudtOuter(intOuter).strInner) mudtOuter(intOuter).strInner(intInner) = "1" Next intInner Next intOuter End Sub Private Sub Command2_Click() 'change the dimensions of the middle inner array, and fill the extra elements with "2" Dim intOuter As Integer Dim intInner As Integer Dim intOldInner As Integer intOuter = UBound(mudtOuter) / 2 intOldInner = UBound(mudtOuter(intOuter).strInner) ReDim Preserve mudtOuter(intOuter).strInner(intOldInner + 5) As String For intInner = intOldInner + 1 To UBound(mudtOuter(intOuter).strInner) mudtOuter(intOuter).strInner(intInner) = "2" Next intInner End Sub Private Sub Form_Click() 'clear the form and print the outer,inner arrays Dim intOuter As Integer Dim intInner As Integer Cls For intOuter = 0 To UBound(mudtOuter) For intInner = 0 To UBound(mudtOuter(intOuter).strInner) Print CStr(intOuter) &amp; "," &amp; CStr(intInner) &amp; " = " &amp; mudtOuter(intOuter).strInner(intInner) Next intInner Print "" 'add an empty line between the outer array elements Next intOuter End Sub Private Sub Form_Load() 'init the arrays Dim intOuter As Integer Dim intInner As Integer ReDim mudtOuter(5) As MyArray For intOuter = 0 To UBound(mudtOuter) ReDim mudtOuter(intOuter).strInner(intOuter) As String For intInner = 0 To UBound(mudtOuter(intOuter).strInner) mudtOuter(intOuter).strInner(intInner) = CStr((intOuter + 1) * (intInner + 1)) Next intInner Next intOuter WindowState = vbMaximized End Sub </code></pre> <p>Run the project, and click on the form to display the contents of the arrays.</p> <p>Click on Command1 to enlarge the outer array, and click on the form again to show the results.</p> <p>Click on Command2 to enlarge an inner array, and click on the form again to show the results.</p> <p>Be careful though: when you redim the outer array, you also have to redim the inner arrays for all the new elements of the outer array</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload