|
-
Feb 15th, 2001, 06:36 PM
#1
Thread Starter
Member
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...
-
Feb 15th, 2001, 06:46 PM
#2
Fanatic Member
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}
-
Feb 16th, 2001, 05:00 AM
#3
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|