LibreOfficeDev 25.2 Help
BWufp‖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
uDGEZ‖The New operator can be used either during variable declaration or in an assignment operation.
r6osC‖The following example uses the New operator to create an instance of the PropertyValue Uno struct.
nPNvc‖' Instantiating the object during variable declaration
Dim oProp1 as New com.sun.star.beans.PropertyValue
oProp1.Name = "Some name"
oProp1.Value = 100
Ts8iC‖' The same can be accomplished with an assignment
Dim oProp2 as Object
oProp2 = New com.sun.star.beans.PropertyValue
oProp2.Name = "Other name"
oProp2.Value = 200
6RJcJ‖The example below creates a new type Student and instantiates an object of this type:
Type Student
FirstName as String
Program as String
End Type
Sub TestObjects
Dim oStudent1 as New Student
oStudent1.FirstName = "John"
oStudent2.Program = "Computer Science"
End Sub