-
I'm trying to build an HTML editor for my brother - Colour selection is where I'm stuck. I want to build it so that it uses the RGB specs (#000000 to #FFFFFF) - and would like to combine it with a visual representaion of the actual colour. I can't figure out a way to make VB display colours in that format. What I'd really like to have is a colour wheel type of display - a big circle with all the gradients of colour in it. But if that's not possible I'd like to have text that I can display in that colour. If I can get that working I can figure out how to do it for the other code. I hope someone can help - even if it's to tell me that it can't be done. Thanks.
-
How about something like this:
Code:
Function HTMLToLong(sHTML As String) As Long
Dim lR As Long, lB As Long, lG As Long
lR = CInt(Val("&h" + Mid(sHTML, 2, 2)))
lG = CInt(Val("&h" + Mid(sHTML, 4, 2)))
lB = CInt(Val("&h" + Mid(sHTML, 6, 2)))
HTMLToLong = RGB(lR, lG, lB)
End Function
This takes a string of the form "#RRGGBB", and returns a long corresponding to the colour.
-
It is a little known fact that VB does actually use HEX values for colours, just in the format &HRRGGBB& or something similar, hence white(FFFFFF) would be &HFFFFFF&!
-
Parksie - so I could use that function to change the color of a label and it would be the same colour the web would use? I'll try that - thanks.
Cybersurfer - I'm not sure exactly what you mean - could you give me more info or is Parksie's example the sam thing?
Thanks.
-
In Hexidecimal, The colour white is represented as FFFFFF. In Visual Basic, it adds &H at the start to identify the data as HEX, and a "terminating" & at the end. So if you wanted to type the Hex value for white in VB, it would be &HFFFFFF&. Likewise black would be &H000000&
-
CyberSurfer- cool - I understand now. Thanks.
-
S'OK, It took me a while to understand it as well!