Wayne just answered my question on how to get the palette to open, now how do I made it so that it takes the color, convers it into HTML then puts the HTML color code into a textbox
Printable View
Wayne just answered my question on how to get the palette to open, now how do I made it so that it takes the color, convers it into HTML then puts the HTML color code into a textbox
Take a look at this thread.
Thanks, matt, but its kinda confusing, do I add all of that to a module? and do I call to the functions?
can you please like change it a little so that you put in a VB color (i.e. &h001&) into text1 and have it say the html color in text2
Here's a little function you can use:
Code:Public Function GetHTMLColor(p_Color As Long) As String
Dim strBuffer As String
Dim intLen As Integer
Dim intPad As Integer
strBuffer = Hex(p_Color)
Select Case Len(strBuffer)
Case 1
intPad = 5
Case 2
intPad = 4
Case 3
intPad = 3
Case 4
intPad = 2
Case 5
intPad = 1
End Select
GetHTMLColor = "#" & String(intPad, "0") & strBuffer
End Function
Then you can call this function like this:
Code:Private Sub Command1_Click()
Dim strHTMLColor As String
strHTMLColor = GetHTMLColor(RGB(10, 125, 255))
MsgBox strHTMLColor
End Sub
Or might be easier if you just
Code:strHTMLcolor = "#" & Right("00000" & Hex(Color),5)