Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested Arrays

Status
Not open for further replies.

geoffKaman

Programmer
Jul 12, 2001
1
US
I am trying to creat a Dynamic Menu that Builds Catagories and Catagory Items. For Example

Departments
Department 1
Department 2

Programs
Program 1
Program 2

I am trying to use the elements in the Catagory Array to point to another Array. The CatagoryItems Array. I would think it would look like this.

Dim Catagory(2)
Catagory(0) = Departments
Catagory(1) = Programs
Catagory(2) = Syllabus

Dim Departments(2)
Departments(0) = "Finance"
Departments(1) = "Marketing"
Departments(2) = "Managment"

Dim Programs(2)...

Dim Syllabus(3)...

When I use the elements in Catagory(2), I get the Error of Object not collection. What am I doing wrong? Can I index arrays within arrays, if so what is the correct syntax?

I appriciate the time to reveiw my problem.

Thank you.

Geoff
 
Havent done this stuff in a WHILE! Relational tables make this an obsolete orphan (and UnLovely?).

It is more common to use a "UDT" to manipulate this type of structure. See the "snippet" of code:

Code:
Public Function basMyArrayOfArrays()

    'Debug.Print basMyArrayOfArrays
    'Finance
    'Marketing
    'Managment
    'Operations

    Dim Category(3) As CategoryType

    Category(0).Syllabus(0) = "Finance"
    Category(0).Syllabus(1) = "Marketing"
    Category(0).Syllabus(2) = "Managment"
    Category(0).Syllabus(3) = "Operations"

    For Idx = 0 To UBound(Category(0).Syllabus)
        Debug.Print Category(0).Syllabus(Idx)
    Next Idx

End Function

In this scenario, you can re deminsion Category within a procedure.

I'm not sure this is what you are attempting, but it is at least one approach. If you need each 'Array' to be an element of the next 'higher' object in the heirarchy, you can do the same - just making each UDT as element within the Next object.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top