first you need to decide on the size of your grid cubes and the number of cubes...say a 10*10*10 3d grid, where each grid cube is 10(or whatever) units wide, then dimension an array like grid(1000,3)

the first dimension to control each grid number, and the next dimension actually shows the x,y,z coords of a grid point. You only need to define one grid point per grid cube. Because since you know your grid cube size you can infer that later on when placing opbjects

to actually store the grid number and coords.. simply loop through the array from 0 to however many grid units you want.