New (keyword)

Syntax 1

Dim ObjectVariable As New ObjectType

Syntax 2

Set ObjectVariable = New ObjectType


Creates a new instance of the specified object type, assigning it to the specified object variable.


The New keyword is used to declare a new instance of the specified data object. This keyword can only be used with data object types.

At runtime, the application or extension that defines that object type is notified that a new object is being defined. The application responds by creating a new physical object (within the appropriate context) and returning a reference to that object, which is immediately assigned to the variable being declared.

When that variable goes out of scope (that is, the Sub or Function procedure in which the variable is declared ends), the application is notified. The application then performs some appropriate action, such as destroying the physical object.

See Also

Dim (statement); Set (statement).

More information