![]() |
Excel VBA Compile Error when dimensioning jagged array
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 |
Excel VBA Compile Error when dimensioning jagged array
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 "EngPhys_Bate" wrote: 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 |
Excel VBA Compile Error when dimensioning jagged array
On Aug 21, 1:58 pm, Keithlo wrote:
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 "EngPhys_Bate" wrote: 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 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 |
All times are GMT +1. The time now is 01:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com