Set Statement

Sets an object reference on a variable.

语法:

Set Statement diagram


   [Set] variable = [New] object

参数:

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

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

object: Object that the variable refers to.

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

note

Set keyword is optional. Nothing is the default value for objects.


示例:


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

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


请支持我们!