Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
When you declare an instance of a class, the New keyword must be followed by a type name or by With. For example, the following statements each declare client to be an instance of the Customer class. The type name Customer follows New.
' Dim client As New Customer()
' The next declaration uses an object initializer.
Dim client As New Customer() With {.Name = "Litware, Inc."}
Beginning with Visual Basic 2008, you can declare an object to be an instance of an anonymous type, in which case you do not specify a data type. In anonymous type declarations, the keyword With follows New.
Dim person = New With {.Name ="Mike Nash", .Age = 27}
Error ID: BC30988
To correct this error
- Change the declaration so that With or a type name follows New.
See Also
Concepts
Object Initializers: Named and Anonymous Types
Declaration Statements in Visual Basic