BC31043: Arrays declared as structure members cannot be declared with an initial size
An array in a structure is declared with an initial size. You cannot initialize any structure element, and declaring an array size is one form of initialization.
Error ID: BC31043
Example
The following example generates BC31043:
Structure DemoStruct
Public demoArray(9) As Integer
End Structure
To correct this error
Define the array in your structure as dynamic (no initial size).
If you require a certain size of array, you can redimension a dynamic array with a ReDim Statement when your code is running. The following example illustrates this:
Structure DemoStruct Public demoArray() As Integer End Structure Sub UseStruct() Dim struct As DemoStruct ReDim struct.demoArray(9) Struct.demoArray(2) = 777 End Sub
See also
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for