Results 1 to 3 of 3

Thread: Revere the RGB function?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100
    Does anyone know how I get the value from the RGB function back to R,G,B values?

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Sure thing!
    Code:
    Public Function GetRGB(pColor as long) as String
        Dim intBlue As Integer
        Dim intRed As Integer
        Dim intGreen As Integer
        Dim lngColor As Long
        
        
        intBlue = Int(pColor / 65536)
        intGreen = Int((pColor - (65536 * intBlue)) / 256)
        intRed = pColor - (intBlue * 65536) - (intGreen * 256)
    
        GetRGB = "RGB(" & intRed & "," & intGreen & "," & intBlue & ")"
    End Function
    Then you can do something like this to text it:

    Code:
    Private Sub Command1_Click()
        MsgBox GetRGB(RGB(10, 50, 35))
    End Sub
    [Edited by Serge on 09-15-2000 at 02:09 PM]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100
    Hey.. I have already figured it out..
    R = x * 1
    G = x * 256
    B = x * 65536

    Now.. just get the value and count backwards..

    sorry for your time..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width