Results 1 to 7 of 7

Thread: colour specs for HTML

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Question

    I'm trying to build an HTML editor for my brother - Colour selection is where I'm stuck. I want to build it so that it uses the RGB specs (#000000 to #FFFFFF) - and would like to combine it with a visual representaion of the actual colour. I can't figure out a way to make VB display colours in that format. What I'd really like to have is a colour wheel type of display - a big circle with all the gradients of colour in it. But if that's not possible I'd like to have text that I can display in that colour. If I can get that working I can figure out how to do it for the other code. I hope someone can help - even if it's to tell me that it can't be done. Thanks.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    How about something like this:
    Code:
    Function HTMLToLong(sHTML As String) As Long
        Dim lR As Long, lB As Long, lG As Long
    
        lR = CInt(Val("&h" + Mid(sHTML, 2, 2)))
        lG = CInt(Val("&h" + Mid(sHTML, 4, 2)))
        lB = CInt(Val("&h" + Mid(sHTML, 6, 2)))
    
        HTMLToLong = RGB(lR, lG, lB)
    End Function
    This takes a string of the form "#RRGGBB", and returns a long corresponding to the colour.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    It is a little known fact that VB does actually use HEX values for colours, just in the format &HRRGGBB& or something similar, hence white(FFFFFF) would be &HFFFFFF&!

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359
    Parksie - so I could use that function to change the color of a label and it would be the same colour the web would use? I'll try that - thanks.

    Cybersurfer - I'm not sure exactly what you mean - could you give me more info or is Parksie's example the sam thing?

    Thanks.

  5. #5
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    In Hexidecimal, The colour white is represented as FFFFFF. In Visual Basic, it adds &H at the start to identify the data as HEX, and a "terminating" & at the end. So if you wanted to type the Hex value for white in VB, it would be &HFFFFFF&. Likewise black would be &H000000&

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359
    CyberSurfer- cool - I understand now. Thanks.

  7. #7
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    S'OK, It took me a while to understand it as well!

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