Android Question Giving a Variable Name to a Color in B4X

bocker77

Active Member
Licensed User
Longtime User
In B4A I can give a variable name to a color by doing this.
B4X:
    Dim Cornstalk As Int = Colors.RGB(255, 248, 220)

But I get an error when I code this.
B4X:
    Dim Cornstalk As Int = xui.Color_RGB(255, 248, 220)

Error:
B4XMainPage - 107: This sub should only be used for variables declaration or assignments of primitive values. (warning #29)

Same error when I tried changing Int to Object and just for giggles to B4XView. Can someone inform me what type to use please or even if I can even do this? I can't find any information on the Forum on how to proceed.
 

aeric

Expert
Licensed User
Longtime User
It is a warning, not error.
The project still compiles.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
If this works for you in B4A without warning, why not continue to use it?
B4X:
Dim Cornstalk As Int = Colors.RGB(255, 248, 220)

If you also want to use this in B4i and B4J, then better assign the exact Int value like this:
B4X:
Dim Cornstalk As Int = -1828
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You can also use literals 0xaarrggbb so Red would be 0xFFFF0000 (Not so easy converting the numbers to hex though)
 
Upvote 0

bocker77

Active Member
Licensed User
Longtime User
Yes you are correct, it still compiles. And yes I am getting it possibly ready for B4I. So I am glad that I posed the question for I would never have known about the assignment required for IOS. Thanks.
 
Upvote 0
Top