Android Question Convert text string to b4a color

vecino

Well-Known Member
Licensed User
Longtime User
Hello, I'm having a lot of trouble to do something simple:
In an import I get a string of text, for example, like this: "$0000FFFF"
How can I convert that text string to b4a color number?
Thank you very much.
 
As B4A uses RGB values like this (The first 255 is the alpha value)

Code: Copy
Activity.Color=Colors.ARGB(255,100,149,237)

You need to convert the hex values to integers

Code: Copy
dim hex as String
dim intValue as Int
hex = "FF"
intValue = Bit.ParseInt(hex, 16);

Remove the '$' and use a loop to get 2 chars each for the conversion.

Nice tool: https://www.w3schools.com/colors/colors_converter.asp
 
Upvote 0
Back
Top