View Single Post
Old Mar 2nd, 2005, 1:49 PM   #1
ChefBoiAreDee
Newbie
 
Join Date: Mar 2005
Posts: 5
Rep Power: 0 ChefBoiAreDee is on a distinguished road
For Each ... Next, Nested Array issues.

I am trying to perform a For Each Loop on a nested array and VB is yelling at me

The nested array structure is this.
MainArray(0)
    SubArray(0) = "Some String"
    SubArray(1) = "Some String"
    SubArray(2) = "Some String"
MainArray(1)
    SubArray(0) = "Some String"
    SubArray(1) = "Some String"
    SubArray(2) = "Some String"
...and so on.

Where SubArray always contains 3 total elements and MainArray can have any number of elements which are SubArray.

Here is what I have.
Private Sub ProcessArray(byref MainArray as Variant)

    For Each SubArray In MainArrary
        DoSomething SubArray(0), SubArray(1), SubArray(2)
    Next

End Sub
Upon attempting to compile I get this error.

For Each control variable must be Variant or Object

I've tried to declare SubArray before the loop like this.
Dim SubArray(2) as Variant
and even like this.
Dim SubArray() as Variant
But I can't get anything to work

Can this just not be done in VB?

Thanks in advance to anyone who posts.
ChefBoiAreDee is offline   Reply With Quote