Wish Get & Set

Jorge M A

Well-Known Member
Licensed User
Longtime User
+1
In the meantime we have a good Helper:
 

Jorge M A

Well-Known Member
Licensed User
Longtime User
(the class) cannot check-validate values, instead using properties you can.
I honestly don't see the difference in a class module ?, whereas it's more obvious in a Custom View.
Could you show me with a simple example what you mean please?
 

LucaMs

Expert
Licensed User
Longtime User
Could you show me with a simple example what you mean please?
B4X:
' MyClass1
Process_Globals
    Public Value As Int


' If Value was Zero, error.
' You could check it here, of course, but Value could be used also in many other routines.
Public Sub Divide(Num As Int) As Single
    Return Num / Value
End Sub

B4X:
' MyClass2
Process_Globals
    Private mValue As Int = 1

Public Sub setValue(V as Int)
    If V >= 0 Then
        mValue = V
    Else
        '...
    End If
End Sub
Public Sub getValue As Int
    Return mValue
End Sub

' mValue will never be zero.
Public Sub Divide(Num As Int) As Single
    Return Num / mValue
End Sub

not ideal example, but I'm watching the news ?
 

Jorge M A

Well-Known Member
Licensed User
Longtime User
ooooh! i see my mistake!!!!
I understood exactly the opposite, sorry!
(it's early morning here, lack of coffee and also watching news)
 

Jorge M A

Well-Known Member
Licensed User
Longtime User
By the way, proudly Mexican, of Lebanese descent. We almost shared our National Flags!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…