Results 1 to 8 of 8

Thread: CommonDIalog1.Color -> to Hex? (for html)

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    How do I convert the # tha the common dialog gives for color into a Hex number for a web page?

    (if that is hex)

    <body bgcolor="#ffffff"
    which is white
    white = 16777215 in the common dialog....

    Thanks!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Never mind....I forgot about Hex()

    Testing...
    Code:
    Dim tmp As String 
    Open "c:\wordlist.txt" For Binary As #1 
    tmp = Space(LOF(1)) 
    Get #1, , tmp 
    Close #1 
    'this is a test....never mind I found the code
    words = Split(tmp, vbCrLf) 
    
    
    End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    ?????

    Never Mind that is not right?

    Anyone know how to convert it?

    I think I am seeing it as split into the rgb? am i right?

    ## ## ##
    FF FF FF

    255,255,255 ?

    right?

    How to do?
    Last edited by Static; Feb 12th, 2001 at 04:17 PM.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4
    Lively Member
    Join Date
    Jul 1999
    Posts
    99
    use the Hex$() function:

    Code:
    Debug.Print Hex$(16777215)

  5. #5
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    Your problem is this: VB doesn't put the color values in the same order that the web does. Here is some code i have previously written for that very function:
    [code]
    dim red as byte
    dim green as byte
    dim blue as byte
    dim webcolor as string
    call splitvbcolor (object.color, blue, green, red)
    webcolor = zeropad(rgb(red, green, blue))

    Sub SplitVBColor(VBColor As Long, Blue As Byte, Green As Byte, Red As Byte)
    Red = VBColor And &HFF
    Green = (VBColor And &HFF00&) \ &H100&
    Blue = (VBColor And &HFF0000) \ &H10000
    End Sub
    Function ZeroPad(HexNumber As String) As String
    ZeroPad = Left$("000000", 6 - Len(HexNumber)) + HexNumber
    End Function
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  6. #6
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    If you're interested, i have attached a module i am working on currently with the above functions and a couple of other neat color-manipulating ones you might find interesting.
    Attached Files Attached Files
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  7. #7

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    testing

    Code:
    lred = Lcolor Mod &H100  
    lgreen = Lcolor \ &H100 Mod &H100  
    lblue = Lcolor \ &H10000 Mod &H100  
    lred = Hex(lred)  
    If lred = "0" Then lred = "00"  
    lgreen = Hex(lgreen)  
    If lgreen = "0" Then lgreen = "00"  
    lblue = Hex(lblue)  
    If lblue = "0" Then lblue = "00"  
    Wcolor = lred & lgreen & lblue
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  8. #8

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    Thank you...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

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