|
-
Sep 18th, 2000, 01:22 PM
#1
Thread Starter
Hyperactive Member
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.
-
Sep 18th, 2000, 01:26 PM
#2
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 18th, 2000, 01:31 PM
#3
Hyperactive Member
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&!
-
Sep 18th, 2000, 01:36 PM
#4
Thread Starter
Hyperactive Member
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.
-
Sep 18th, 2000, 01:39 PM
#5
Hyperactive Member
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&
-
Sep 18th, 2000, 01:41 PM
#6
Thread Starter
Hyperactive Member
CyberSurfer- cool - I understand now. Thanks.
-
Sep 18th, 2000, 01:43 PM
#7
Hyperactive Member
S'OK, It took me a while to understand it as well!
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
|