5

I'm working with threedimensional arrays and it would be neat if I could name the array dimensions. The question marks in the example below are giving me the idea that this is possible.

Is it, and if so, how does it work? I can't seem to find it anywhere.

Example

6
  • The questions marks are asking you to specify the count of the dimensions. Commented Jan 8, 2016 at 16:15
  • Your question isn't clear -- what would it mean to "name" the dimensions? You could probably do something with a custom datatype with three fields. Commented Jan 8, 2016 at 16:17
  • Haha should have known that, I guess I have to change my (24,5,8) to (0 To 25, 0 To 5, 0 To 8) in my dim in that case. Commented Jan 8, 2016 at 16:18
  • With naming I mean like when you for example call a sub you see which variables are required Commented Jan 8, 2016 at 16:19
  • Being explicit about the lower bounds doesn't make the question marks go away Commented Jan 8, 2016 at 16:24

1 Answer 1

4

The three question marks are showing you that this array has three dimensions. If there was only one question mark, it would mean that the variable was declared as one dimensional. This is built in to VB and can't be change, as far as I know.

I think there's real value into making your code more readable and self-documenting. If I had a three dim array, I would probably create some custom class modules to model the objects that I was using.

If your first dimension is a SchoolID, your second dimension is a ClassID, and your third dimension is a StudentID, then code using custom class modules like this

Debug.Print Schools(10).Classes(3).Students(7).Name

is more readable than

Debug.Print arrLeeftijdenG5(10,3,7)

I don't know what you're storing, so it's just an example. Consider using custom class module to model the real-world objects your code is manipulating. There's a bit more set up involved, but it pays dividends down the road.

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.