Results 1 to 6 of 6

Thread: changing colors to RRR,GGG,BBB

  1. #1
    Guest

    Post

    how can i change the decimal colors returned by the color dialog into colors like 255,255,255?

  2. #2
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455

    Post

    Hello sailbrdr,

    Try this source:

    Dim Str As String
    Dim N As Integer
    Dim Rdec, Gdec, Bdec As Single
    Dim Rhex, Ghex, Bhex As String

    'N is the variable to convert

    N = Val("&H" + "fF")
    Str = Right("00000" + Hex(N), 6)

    Rhex = "&H" + Left(Str, 2)
    Rdec = Val(Rhex)

    Ghex = "&H" + Mid(Str, 3, 2)
    Gdec = Val(Ghex)

    Bhex = "&H" + Right(Str, 2)
    Bdec = Val(Bhex)

    Good luck,

    Michelle

  3. #3
    Guest

    Post

    What about going back?

  4. #4
    Lively Member
    Join Date
    May 1999
    Posts
    100

    Post

    Test this

    Dim iR as Integer
    Dim iG as Integer
    Dim iB as Integer
    Dim sRHex as String
    Dim sGHex as String
    Dim sBHex as String

    If Len(Hex(iR)) < 2 Then
    sRHex = "0" & Hex(iR)
    Else
    sRHex = Hex(iR)
    End If

    If Len(Hex(iG)) < 2 Then
    sGHex = "0" & Hex(iG)
    Else
    sGHex = Hex(iG)
    End If

    If Len(Hex(iB)) < 2 Then
    sBHex = "0" & Hex(iB)
    Else
    sBHex = Hex(iB)
    End If

  5. #5
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455

    Post

    Maybe this:

    Dim N As Long
    Dim Rdec, Gdec, Bdec As Single
    Dim Rhex, Ghex, Bhex As String
    Dim STR As String

    'N is the variable to convert

    N = Val("&H" + "FF01FF")
    STR = Right("00000" + Hex(N), 6)

    Rhex = "&H" + Left(STR, 2)
    Rdec = Val(Rhex)

    Ghex = "&H" + Mid(STR, 3, 2)
    Gdec = Val(Ghex)

    Bhex = "&H" + Right(STR, 2)
    Bdec = Val(Bhex)

    Rhex = Trim(Left(STR, 2))
    Ghex = Trim(Mid(STR, 3, 2))
    Bhex = Trim(Right(STR, 2))

    '------------------------------------------

    Rhex = Right(("0" + Rhex), 2)
    Ghex = Right(("0" + Ghex), 2)
    Bhex = Right(("0" + Bhex), 2)

    N = Val("&H" + Rhex + Ghex + Bhex)


    Good luck,

    Michelle.

  6. #6
    Guest

    Post

    Thanks a bunch

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