mE7Wc‖

PaNUT‖Set Statement

qNuUW‖Sets an object reference on a variable.

FVEx2‖Syntax:

AQj9V‖ Set Statement diagram


   QfXmo‖[Set] variable = [New] object

WADQ4‖Parameters:

DYFP7‖ variable: a variable or a property that requires an object reference.

iKwsW‖ expression: A computable combination of terms such as a formula or an object property or method.

j9GVn‖ object: Object that the variable refers to.

HBfCA‖ Nothing - Assign Nothing to a variable to remove a previous assignment.

note

4WqJK‖Set keyword is optional. Nothing is the default value for objects.


EFSA4‖Example:


Sub ExampleSet
    Dim obj As Object
    Set obj = ThisComponent
    Print obj.Title
 
    obj = New com.sun.star.beans.PropertyValue
    With obj
        .Name = "key" : .Value = 594.34
        Print .Name, .Value
    End With
End Sub
tip

9GzzW‖New creates UNO objects or class module objects, before assigning it to a variable.