Tulong sa LibreOffice 24.8
Ang isang ari-arian, na tinatawag ding field o attribute, ay nagpapakilala sa isang ibinigay na bagay o piraso ng impormasyon. Maaaring gamitin ang mga katangian upang kontrolin ang pag-access sa data. Karaniwang gamit na isama ang mga tagubilin sa pagtatakda o oras ng pagbabasa ng mga property. Maaaring mag-iba ang code mula sa simpleng pagtatalaga hanggang sa mga kumplikadong nakadepende sa konteksto na gawain. Gamit Kunin , Hayaan o Itakda ipinapatupad ng mga accessor ang pagkakapare-pareho ng mga ari-arian kung kinakailangan.
Ang pahayag na ito ay nangangailangan Katugmang Pagpipilian na ilalagay bago ang executable program code sa isang 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
pangalan: Ang pangalan ng ari-arian.
argumento: Halaga na ipapasa sa Ari-arian setter routine.
Ari-arian ang mga setter ay madalas na gumagamit ng isang argumento. Ang maramihang mga argumento ay pantay na tinatanggap.
Option Compatible
Sub Main
ProductName = "Office"
Ipinapakita ng Print ProductName ' ang "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
Sa kawalan ng Ari-arian Hayaan o Ari-arian Itakda , Ari-arian Kunin tumutulong na tukuyin ang protektadong impormasyon, na hindi aksidenteng mababago ng isang dayuhang module:
Option Compatible
Public Property Kunin ang PathDelimiter Bilang String ' Read-only na variable
Static this As String
If this = "" Then : Select Case GetGuiType()
Case 1 : this = ";" ' Windows
Case 4 : this = ":" ' Linux o macOS
Case Else : Error 423 ' Hindi tinukoy ang property o method: PathDelimiter
End Select : End If
PathDelimiter = this
End Property ' read-only PathDelimiter
Sub Main
Ang PathDelimiter = "isang pangungusap" ' ay walang ginagawa
End Sub
Gamitin Hayaan o Itakda kapag humahawak ng mga serbisyo ng UNO o mga bagay ng klase:
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