New Operator/text/sbasic/shared/new_keyword.xhpNew Operator
New Operator
Use the New operator to instantiate objects of user-defined types, as well as Uno services, structs and enumerations.
Dim oObj as New ObjectType
oObj = New ObjectType
The New operator can be used either during variable declaration or in an assignment operation.The following example uses the New operator to create an instance of the PropertyValue Uno struct.' Instantiating the object during variable declarationDim oProp1 as New com.sun.star.beans.PropertyValueoProp1.Name = "Some name"oProp1.Value = 100' The same can be accomplished with an assignmentDim oProp2 as ObjectoProp2 = New com.sun.star.beans.PropertyValueoProp2.Name = "Other name"oProp2.Value = 200The example below creates a new type Student and instantiates an object of this type:Type Student FirstName as String Program as StringEnd TypeSub TestObjects Dim oStudent1 as New Student oStudent1.FirstName = "John" oStudent2.Program = "Computer Science"End Sub