Udostępnij za pośrednictwem


Initializers on structure members are valid only for 'Shared' members and constants

A structure member variable was initialized as part of its declaration.

Error ID: BC31049

To correct this error

  • Use a constant instead of a variable.

  • Add a parameterized constructor to the structure. For example:

    Structure TestStruct
       Public t As Integer
       Sub New(ByVal Tval As Integer)
          t = Tval
       End Sub
    End Structure
    

See Also

Tasks

How to: Declare a Structure

Other Resources

Constants and Enumerations in Visual Basic