Printer Friendly Version      Send     
Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio .NET
Reference
Keywords
F-O Keywords
 New
This page is specific to
Microsoft Visual Studio 2003/.NET Framework 1.1

Other versions are also available for the following:
Visual Basic Language Reference
New

The New keyword introduces a New clause, which creates a new object instance. The New clause must specify a defined class from which the instance can be created. You can use New in a declaration statement or an assignment statement. When the statement is executed, it calls the constructor of the specified class, passing any arguments you have supplied:

Dim Obj As Object
Obj = New SomeClass("String required by constructor")
' ...
Dim MyLabel As New Label()

Since arrays are classes, New can create a new array instance:

Dim MyArray As Integer()
MyArray = New Integer() {0, 1, 2, 3}

The common language runtime throws an OutOfMemoryException error if there is insufficient memory to create the new instance.

The New keyword is used in this context:

Dim Statement

See Also

Visual Basic Language Keywords | Object Lifetime: How Objects Are Created and Destroyed | Using Constructors and Destructors | OutOfMemoryException Class

© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker