LibreOffice 25.2 Súgó
A tulajdonság, más néven mező vagy attribútum, egy adott objektumot vagy információt jellemez. A tulajdonságok az adatokhoz való hozzáférés szabályozására használhatók. Gyakori, hogy a tulajdonságok beállításakor vagy olvasásakor utasításokat is tartalmaznak. A kód az egyszerű hozzárendeléstől az összetett, kontextusfüggő rutinokig terjedhet. A Get, Let vagy Set hozzáférők használata szükség esetén kikényszeríti a tulajdonságok konzisztenciáját.
This statement requires Option Compatible to be placed before the executable program code in a module.
       
         [Private | Public] Property Get name[char | As typename]
         End Property
             
         [Private | Public] Property [Let | Set] name[char] [([Optional [ByRef | ByVal]]value[char | As typename])] [As typename]
         End Property
      name: The property name.
argument: Value to be passed to the Property setter routine.
Property setters often use a single argument. Multiple arguments are equally accepted.
      Option Compatible
      Sub Main
          ProductName = "Office"
          Print ProductName ' displays "LibreOffice"
      End Sub
      
      Private _office As String
      Property Get ProductName As String
          ProductName = _office
      End Property
      Property Let ProductName(value As String)
          _office = "Libre"& value
      End Property
      In the absence of Property Let or Property Set, Property Get helps define protected information, which can not be accidently altered by a foreign module:
      Option Compatible
      Public Property Get PathDelimiter As String ' Read-only variable
          Static this As String
          If this = "" Then : Select Case GetGuiType()
              Case 1 : this = ";" ' Windows
              Case 4 : this = ":" ' Linux or macOS
              Case Else : Error 423 ' Property or method not defined: PathDelimiter
          End Select : End If
          PathDelimiter = this
      End Property ' read-only PathDelimiter
      
      Sub Main
          PathDelimiter = "a sentence" ' does nothing
      End Sub
      Use Let or Set when handling UNO services or class objects:
      Option Compatible
      Sub Main
          'Set anObject = CreateUnoService( "com.sun.star.frame.Desktop" )
          anObject = CreateUnoService( "com.sun.star.frame.Desktop" )
          Print anObject.SupportedServiceNames(0) ' displays "com.sun.star.frame.Frame"
      End Sub
      
      Property Get anObject As Object
          Set anObject = _obj
      End Property
      
      Private _obj As Object
      
      'Property Set anObject(value As Object)
          'Set _obj = value.CurrentFrame
      'End Property
      Property Let anObject(value As Object)
          Set _obj = value.CurrentFrame
      End Property