Excel VBA Compile Error when dimensioning jagged array

E

EngPhys_Bate

I am getting the error: "Compile Error: Expected: End of Statement"
when attempting to declare a public (inside the module) 2D jagged
array inside a module. The code, as follows, is declared at the top
of the module:

Dim testStages()() as clsTestStage '2D-array holding tests

Here clsTestStage is a class I have created. I have also tried the
following to see if it was an issue with my custom object:

Dim myString()() as string

and get the same error.

Any ideas as to what could be causing the error? The plan was to go
on and use the ReDim Preserve commands to resize the jagged array
dynamically. I was previously using a dynamic 2D array, but utilizing
a jagged array would be much cleaner and faster in my application.

Any help is greatly appreciated.

Cheers,

bb
 
K

Keithlo

The examples I've seen of multi-dimmensional arrays have only had one set of
parentheses, with dimmensions separated by commas, as in this example from
VBA Help:

"In Visual Basic, you can declare arrays with up to 60 dimensions. For
example, the following statement declares a 2-dimensional, 5-by-10 array.

Dim sngMulti(1 To 5, 1 To 10) As Single"

Not sure if this helps you, but hope so.

Keith
 
E

EngPhys_Bate

The examples I've seen of multi-dimmensional arrays have only had one set of
parentheses, with dimmensions separated by commas, as in this example from
VBA Help:

"In Visual Basic, you can declare arrays with up to 60 dimensions. For
example, the following statement declares a 2-dimensional, 5-by-10 array.

Dim sngMulti(1 To 5, 1 To 10) As Single"

Not sure if this helps you, but hope so.

Keith

This is not a multidimensional array, but an array of arrays, known as
a "jagged" array. I've seen many examples of implementations as I
showed above, but I seem to always get the same error. Any
suggestions?

Cheers,

Bruno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top