Problem with RGB and ARGB functions

CodeDancer

Member
Licensed User
Longtime User
No one seems to be having problems with these functions but me.
The following code gives me a result of -8421505 instead of 8355711.

Dim R,G,B,XColor As Int

R=127:G=127:B=127

XColor = Colors.RGB (R,G,B) 'should be 8355711 (0x7f7f7f)

Log (XColor) 'returns -8421505

What am I doing wrong?
 

CodeDancer

Member
Licensed User
Longtime User
Problem solved

Thanks Klaus.

I guess that the alpha byte is kicking the RGB value negative.
I am porting some code from VB6 and I guess Microsoft takes care of the internal stuff and always returns positive RGB values.
So it's not a bug, just something to go into the B4A vs VB6 difference list.
You need to subtract 16777216 from the VB6 RGB to get the B4A RGB.
 
Last edited:
Top