Class properties not seen

pmg

Member
Licensed User
Longtime User
I am using B4A 2.71

I have a class, Person. According to my understanding of the documentation, when I have an instance of Person in another module, a popup should appear for FirstName and LastName when I try to autocomplete with control/space

All I am seeing is Class_Globals, FullName, Initialize and isInitialized.

Any help/comments would be appreciated.

Peter



' Class Person module
Sub Class_Globals
Private FirstName
Private LastName
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(tFirstName As String,tLastName As String,tLastLoanDate As Long)
FirstName = tFirstName
LastName = tLastName
Log("Initialized Person")
End Sub

' get the full Name
Sub FullName As String
Return FirstName & " " & LastName
End Sub

'get the FirsName
Sub getFirstName As String
Return FirstName
End Sub
'set the FirsName
Sub setFirstName(tFirstName As String)
FirstName = tFirstName
End Sub
Sub getLastName As String
Return LastName
End Sub
 

klaus

Expert
Licensed User
Longtime User
The problem is that private variable names are the same as the property names.
Change the private variable names to cFirstName and cLastName then you'll see the properites.
The code below woks:
B4X:
' Class Person module
Sub Class_Globals
    Private cFirstName As String
    Private cLastName As String
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(FirstName As String,LastName As String,LastLoanDate As Long)
    cFirstName = FirstName
    cLastName = LastName
Log("Initialized Person")
End Sub

'get the full Name
Sub getFullName As String
    Return cFirstName & " " & cLastName
End Sub

'get or set the FirstName
Sub getFirstName As String
    Return cFirstName
End Sub

Sub setFirstName(FirstName As String)
    cFirstName = FirstName
End Sub

'get or set LastName
Sub getLastName As String
    Return cLastName
End Sub

Sub setLastName(LastName As String)
    cLastName = LastName
End Sub
Best regards.
 
Top