Hi guys!!!
How can I convert a RGB value to hexadecimal and viceversa?
Printable View
Hi guys!!!
How can I convert a RGB value to hexadecimal and viceversa?
It seems that VB uses a 4-byte long integer to represent color, the high byte being 0 and the three lower bytes being, from lowest onward, RRGGBB, i.e., &HBBGGRR. So RGB(255,255,255) = &HFFFFFF; RGB(123,0,33) = &H21007B, and so on. &H80 in the high byte represents a Windows system color.
Hope it helps.
You can easily convert numbers into hex using either the Hex() (returns variant), or Hex$() (returns a string) functions. Converting from hex to some other base requires an algorithm however. If you really want it, I have one, but if you look you can probably find one faster than I can dig mine up at home :).
Thank you very much!!!