Using a 3 Dimensional Array

Category:
Lists, Collections and Arrays
Type:
Snippets
Difficulty:
Intermediate
Author:
Ethan

Version Compatibility:

More information:
Most multi-dimensional arrays that are used are two dimensional arrays eg. databases with records and fields, screen coordinates with X and Y and recordsets with rows and columns, but there are greater multi-dimensional arrays. There is very little documentation on these arrays. Three dimensional arrays are basically multiple two dimensional arrays layered on top of each other.Three dimensional arrays have many uses eg. mapping 3d graphics, calendars (where days are the columns, the weeks are the rows and the months are the layers), or paging methods for reports and recordsets (as in the example I provided below).

The code shows how to:

  • Dimension a 3 dimensional array
  • Populate the array
  • Access each layers data seperately
  • Print the data
Directions: Paste the code below into a form with autoredraw set to true and a combo box

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: