Code: Select all
' Convert Long color value to HTML HEX color for example "#0ffa56"
' If used in HTML tag for example <FONT COLOR> tag use aditional ""
' If used in CSS STYLE for example background-color: not use ""
Function LongToHTML_Hex(ColorValue as Long) As String
LongToHTML_Hex="#"+Right("0"+Hex(red(ColorValue)),2)+Right("0"+Hex(green(ColorValue)),2)+Right("0"+Hex(blue(ColorValue)),2)
End Function
' With alpha channel support #RRGGBBAA
' For example #000000FF = black color with 100% transparency
Function LongToHTML_HexAlpha(ColorValue as Long) As String
LongToHTML_HexAlpha="#"+Right("0"+Hex(red(ColorValue)),2)+Right("0"+Hex(green(ColorValue)),2)+Right("0"+Hex(blue(ColorValue)),2)+_
Right("0"+Hex(red(ColorValue/256)),2)
End Function
1) Simple message box
Code: Select all
msgbox "rgb(215,125,25)="+LongToHTML_Hex(rgb(215,125,25))+chr(10)+chr(10)+" HEX(DEADBEEF)="+LongToHTML_HexAlpha(-559038737)
Code: Select all
...
color=LongToHTML_Hex(TextPortion.CharColor)
text=text+"<FONT COLOR="""+color+""">"+TextPortion.String+"</FONT>"
...