3

I've got an array declaration which results in 144 slots. I don't understand how I've got to this number. Also, what means all those commas between numbers?

Dim arr4(1, 5, 5, 0 To 1) As Long
    Debug.Print ArraySize(arr4)

1 Answer 1

10

The , denotes a new dimension. So arr4 has 4 dimensions.

When using 0 to 1 it is saying that the fourth dimension has two, 0 and 1

When using just one number 5 then the starting point is assumed 0 unless changed in the settings, so there are 6 in that dimension: 0,1,2,3,4,5

The reason there are 144 is because 2*6*6*2=144

Think of it this way.

1st dimension is rows with two row (0,1)
2nd dimension is columns with 6 columns (0,1,2,3,4,5)
3rd dimension create 6 sheets of the above configuration (0,1,2,3,4,5)
4th dimension create 2 workbooks with each having 6 sheets with 12 cells (0,1)

Thus there is 144 cells in which to put data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.