Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Long to RGB converting

Status
Not open for further replies.

andrey

Programmer
Jun 23, 2000
24
IL
How can I convert color(Long) to RGB?
Thank you.
 
I did this:
Code:
    Dim lngW As Long
    lngW = RGB(1, 0, 0)
    Debug.Print lngW
    lngW = RGB(0, 1, 0)
    Debug.Print lngW
    lngW = RGB(0, 0, 1)
    Debug.Print lngW
and got 1, 256, 65536
ergo
h00bbggrr& is your answer.
 
Long to RGB Values

Dim c_lng256 As Long = 256
Dim c_lng65536 As Long = 65536

Dim lngColor as Long
Dim intRed as Integer, intGreen as Integer, intBlue as Integer

intRed = lngColor Mod c_lng256
intGreen = (lngColor And &HFF00FF00) / c_lng256
intBlue = (lngColor And &HFF0000) / c_lng65536


RGB Values to Long
lngColor = RGB(intRed, intGreen,intBlue) _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top