|
-
Jun 26th, 2000, 12:49 AM
#1
Thread Starter
Member
Hi!
I have a problem with colors. VB uses a RGB color
representation that is not useful for me - it converts
255,255,255 to 16777215 ant its returns every color in
this format. But what I need is that VB would return
values for each seperately or in HEX format (like $FFFFFF
where the first part represents red, second green and
third part blue color). I hope anyone can understand what I
mean.
Thanx in advance for any answer.
Celery
-
Jun 26th, 2000, 01:32 AM
#2
Addicted Member
Here is an example that takes a color value and converts it to its HTML Hex equivalent. If you want to see a working application that does this with full source code, you can download it from my web page here. Here's the URL in case the link isn't working: http://msnhomepages.talkcity.com/cerfst/jcouture100
Then download the Programmer's Color Converter app and Source Code.
I've been having problems with the URL Processing properly in this forum, so you may have to type in the URL manually. There shouldn't be a space in the url in JCOUTURE100.
Hope this helps.
Code:
Dim getRed As Long
Dim getGreen As Long
Dim getBlue As Long
Dim getColor As Long
Dim TempVal As Long
getColor = 4227327 'Set color variable = to an orange color
'Use integer division to drop any decimal value
'Get value of Blue
getBlue = Format(getColor \ (16 ^ 4), "#00")
'Get remainder value after Blue is taken out.
TempVal = getColor Mod (16 ^ 4)
'Use integer division to drop any decimal value
'Get value of Green
getGreen = Format(TempVal \ (16 ^ 2), "#00")
'Remainder is Red value
getRed = Format(TempVal Mod (16 ^ 2), "#00")
strRed = "&H" & Format(Hex(getRed), "#00")
strBlue = "&H" & Format(Hex(getBlue), "#00")
strGreen = "&H" & Format(Hex(getGreen), "#00")
[Edited by jcouture100 on 06-26-2000 at 02:42 PM]
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
|