HEX COLOR
Wednesday, August 18, 2004 by doodmon | Discussion: WinCustomize Talk
sub on_objecttimer456
'get the hexidecimal number of the current color of text
hexcolor = hex(me.textcolor)
'find each color
red = right(hexcolor,2)
green = mid(hexcolor,2,2)
blue = left(hexcolor,2)
end sub
My problem is that if hexcolor has any zeros in it, they don't seem to wanna show in hexcolor... like it auto-trims or somethin...
example:
sub on_objecttimer456
me.textcolor = RGB(255,0,0)
'hexcolor of that should be FF0000
hexcolor = hex(me.textcolor)
'result of me.textcolor value is 255
msgbox me.textcolor
'result of hex(me.textcolor) is FF (not FF0000)
msgbox hexcolor
end sub
Reply #2 Wednesday, August 18, 2004 8:11 AM
Reply #3 Wednesday, August 18, 2004 8:55 AM
I haven't played a whole lot with DX, let me try a few things.
BTW: your code is screwed up...  It make no sense anyway as far as I understand DX script.
You wrote "sub on_objecttimer456", but I think it should be "sub Object_onTimer456".  You did define the timer first, right? ex: "Object.SetTimer 456, 10000". And I'm not sure how you are actually executing this script. Do you have actually two onTimer events? Not sure that would work.
Reply #4 Wednesday, August 18, 2004 10:16 AM
OK, here is what I did. I probably cheated, there mist be a better way, but this works anyway. 
The problem is that the Hex function seem to drop the trailing zeros. I looked it up and it seems to be a VBS thing, not specificly DX. Anyway, I'm just adding back the zeros that got dropped:
Sub Object_OnScriptEnter
Me.textcolor = RGB(255,0,0)
HexValue = Hex(Me.textcolor)
thislength = Len(HexValue)
If (thislength = 1) Then
HexValue = HexValue & "00000"
ElseIf (thislength = 2) Then
HexValue = HexValue & "0000"
ElseIf (thislength = 3) Then
HexValue = HexValue & "000"
ElseIf (thislength = 4) Then
HexValue = HexValue & "00"
ElseIf (thisLength = 5) Then
HexValue = Hexvalue & "0"
End If
red = left(HexValue,2)
green = Mid(HexValue,3,2)
blue = right(HexValue,2)
msgbox "R:" & red & " G:" & green & " B:" & blue
End Sub
[Message Edited]
Reply #5 Wednesday, August 18, 2004 11:17 AM
for(var i = 0 HexValue.length == 6 i++)
HexValue += "0"
I leave it to you to convert this to VBScript.. I'm not fond of VB's syntax and so avoid it at all costs..
Reply #6 Wednesday, August 18, 2004 11:36 AM
Reply #8 Wednesday, August 18, 2004 12:55 PM
so instead of adding the zeros to the end of it, I added it to the front... and instead of red ing the first two digits on left... i the first two digits on right... here is what I mean:
Sub Object_OnTimer54987
Me.textcolor = RGB(171,12,255)
HexValue = Hex(Me.textcolor)
thislength = Len(HexValue)
If (thislength = 1) Then
HexValue = "00000"& HexValue
ElseIf (thislength = 2) Then
HexValue = "0000"& HexValue
ElseIf (thislength = 3) Then
HexValue = "000" & HexValue
ElseIf (thislength = 4) Then
HexValue = "00"& HexValue
ElseIf (thisLength = 5) Then
HexValue = "0" & Hexvalue
End If
red = right(HexValue,2)
green = Mid(HexValue,3,2)
blue = left(HexValue,2)
msgbox HexValue & "," & red & "," & green & "," & blue
End Sub
seems to be working...
Reply #9 Wednesday, August 18, 2004 12:58 PM
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!







Reply #1 Wednesday, August 18, 2004 8:05 AM
Maybe if you convert the value into a text string not an integer.