Somebody might wonder why anyone would want to use an array or multi-dimentioned array in a type. This might give you an idea, one that I've used before.
Suppose you need to collect data from a system very 15 minutes, every hour of every day of the year. The largest interval of time that cazn always be subdivided in the same manner is the week. Each week has seven days, each day has 24 hours, and each hour has just 4 15-minute intervals within it.
Of course you have approximately four weeks per month, 12 months a year, nearly 52 weeks in a year, and also approximately 365.2425 days in a year. So as I said before, the inexactness of those considerations means that it is much easier to focus at the week level and not worry to much about the other.
If you could index the week of the year, day of the week, hour of the day, and quarter within that hour, you would have four sepearate indexes to contend with -- element(week,day,hour,quarter). You would have to dimension the array as element(53,7,24,4). Then if you wanted to progress in sequence through each quarter hour, you would have to run four separate FOR loops like so:
For a=0 To 52 ;reference the week in the year
For b=0 To 6 ;reference the day in the week
For c=0 To 23 ;reference the hour in the day
For d=0 To 3 ;reference the quarter of the hour
;now you can reference the element(a,b,c,d)
Next
Next
Next
Note that we had to allow for 53 weeks, even though generally a year is only considered to have 52. But if you multiply 52*7, the result is 364 - you come with slightly more than one day that cannot be supported, since the year is roughly 365 and 1/4th days long.
Now if you only have a single dimensional array, you would have to size the whole thing to include all the subindexes you would normally use, which in this case would be to dimension elements(53*7*23*4). Your index would consist only of a single For loop. and range from 0 to 365.25*25*4-1, which would encompass just the valid quarter hours in the interval. Of course you could also go from 0 to 365*24*4-1 for non-leapyears, and 0 to 366*24*4-1 during any leap years.
Note that you can predetermine any of these values ane enter them as constants in the program: For instance, 24*4 is 96, and 365*96 is 35040, and 35040-1 is 35039.
How would you determine what week, day, hour, or quarter hours an index valu of, say, 20132 would represent? It takes a bit of finessing with the Int() function, but this is how it would generally be done:
week=Int(20132/(7*96)) ;it would be week 29
temp=20132-week*7*86 ;temp is equal to 644
day=Int(temp/96) ;day of week is 6 (Saturday)
temp=temp=day*96 ;temp is equal to 68
hour=Int(temp/4) ;hours is 17 (17:00, or 5 pm)
quarterhr=temp=hour*4 ;qharter hour is 0 (1st quarter hour)
Since the process of breaking out subindexes is almost trivial, and could be handled easily by a function, there is no particular problem with using a single dimension in place of a multidimensioned array. In fact, for some straight forward processes, the ability to use a single index in place of multiple ones can provide something of an n advantage -- you don't need multiple For statements to range through all the possible combinations.