Results 1 to 3 of 3

Thread: System

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    44

    Question

    How Can I Get The Web Hex Color Of Something Like Textbox Foreground Like:

    MyHexColor = Text1.Forground

    And Produce Something Like: #FF0000 For Red?
    I Think I Might Dont Know The Answer To That One...

  2. #2
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Something like this should work...

    Code:
    Dim myHexValue As String
     myHexValue = Hex(RGB(255, 0, 0))
     myHexValue = myHexValue & String(6 - Len(myHexValue), "0")
     myHexValue = "#" & myHexValue
     Debug.Print myHexValue
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    Youngbuck's code has errors in it. He added the zeropadding to the wrong side, etc.
    a sub i wrote contains this function among others. It is attached. But basically, if you want webcolor, convert the long color value to hex and switch the two letters on the right with the two on the left
    dim longcol as long
    dim hexcol as string
    longcol = text1.textcolor (or whatever)
    hexcol = hex$(longcol)
    hexcol = right$("000000"+hexcol, 6)
    hexcol = right$(hexcol, 2)+mid$(hexcol, 3, 2)+left$(hexcol, 2)
    msgbox hexcol

    The swap is cuz vb is backwards to web.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

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