Userform color to RGB values

  • Hi,


    I'm looking for a way (function) to convert the userform back color(example: &H8000000F) to RGB values.
    Reason is that i use sometimes a picture in a Userform button or Userform image.
    VBA doesn't accept a PNG picture but a BMP.
    BMP doesn't support tranparent colors, so i want to set the surrounding color (set as transparent color in GIF & PNG pictures) as close as the Userform backcolor, using Paint -> Edit Colors.



    I guess there's more than the RGB values only in this value ,i count 8 digits, but every color is represented by 2 digits (Decimal :0 -> 255 = Hex: 00 to FF).
    where are the remaining 2 digits used for?


    Any help in this mystery of colors is appreciated.
    For the moment, i'm just guessing the RGB values and use 242,242,242 .
    it's pritty close the the wanted color, but i'm wondering if this could be calculated using a function.


    Thanks for any help.


    Best regards,
    Ludo

  • Re: Userform color to RGB values


    The system colours will vary depending on the user's colour scheme but you can get the actual RGB values using API calls:



    To get the Red value, use:

    Code
    GetRGBfromHex("&H8000000F")(1)


    use 2 and 3 instead of 1 for the Green and Blue respectively.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: Userform color to RGB values


    @ Rory,


    Thanks a lot for the fast reply.
    it works great.
    the returned values for the &H8000000F = 240,240,240 -> pritty close to the guessed 242,242,242 values. :)


    pike,


    Will read this too, thanks too for the link. :)


    Best regards,
    Ludo

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!