Android Question Code Module vs Class Module

realblue

Member
Licensed User
Longtime User
Hi Erel;

Can I use set/get properties in "Code Module" as in "Class Module"?

B4X:
'Code Module : MyModule
Sub setMyProperty(Value As Object)
    m_MyProperty=Value
End Sub

Sub getMyProperty As Object
    Return m_MyProperty
End Sub

. . .

'Activity module
MyModule.MyProperty = "value"
Log(MyModule.MyProperty)

. . .
 

Informatix

Expert
Licensed User
Longtime User
Hi Erel;

Can I use set/get properties in "Code Module" as in "Class Module"?

B4X:
'Code Module : MyModule
Sub setMyProperty(Value As Object)
    m_MyProperty=Value
End Sub

Sub getMyProperty As Object
    Return m_MyProperty
End Sub

. . .

'Activity module
MyModule.MyProperty = "value"
Log(MyModule.MyProperty)

. . .
Yes, you can declare a variable as private and expose only the getter/setter.
 
Upvote 0

joseluis

Active Member
Licensed User
Longtime User
I just tested it. You can create the public methods as Informatix said, e.g. getText / setText, but you wont have the associated Text property which is the syntatic sugar. Since properties are only for classes.
 
Upvote 0
Top