B4J Question Can a class has a property which is an int type?

Hanz

Active Member
I'm using v6.51. When the return type of the property is an Int, the entire sub name is presented in the instance of a class. For instance, the code is:
B4X:
public sub getNormalBalance

When you call the instance of the class, instead of presenting only the "NormalBalance", the entire sub name is presented which is "getNormalBalance." But it's not the case when I change the data type into a String. Is this a limitation or a bug?
 

DonManfred

Expert
Licensed User
Longtime User
Asuming your intvalue is mBalance inside the Class.
The sub signature of the getter method should be
B4X:
public sub getNormalBalance as Int ' <- Define the return type. Here Int
    return mBalance ' don´t forget to add a return 
end sub
In this case it is a read only property.
If you want to change the property too you need to create a setter method too.
B4X:
public sub setNormalBalance(balance as Int)
    mBalance = balance
end sub
 
Last edited:
Upvote 0

Hanz

Active Member
Oh, I see... So what is missing is the "As Int" after the sub name. You need to put it when the data type is not a string type. Thanks!!!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…