Home > Language Reference > Operators
New Operator
Creates a new instance of the specified class.
Syntax
Result = New Type
| Parameter | Description |
| Result | Result of the operation. |
| Type | Name of the class to instantiate. |
Remarks
The New operator creates a new instance of the specified class, and returns a reference to it. The Type argument specifies the class to instantiate, and must be the name of a class whose Instantiable property is set to True. For example:
Private Sub Button1_Click() Dim c As Collection Set c = New Collection ' Creates a new collection c.Add New MyClass, "Key" ' Creates a new instance of MyClass and add it to the collection End Sub
Note: the Type argument is the name of the class to instantiate, not a string variable containing the name of the class. If you need to implement a class factory (ie a function that creates different classes depending on the value of a parameter), you should use the CreateInstance function.
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | - |
| Windows CE | Windows CE 3.0 | - |