|
-
Nov 27th, 1999, 03:52 AM
#1
Thread Starter
Member
The tip doesn't work:
Public Function UnRGB(RGBCol As Long, Part As Integer) As Integer
'Part: 0=Red, 1=Green, 2=Blue
Select Case Part
Case 0
UnRGB = RGBCol And &HFF
' mask 000000000000000011111111 and shift bits right
Case 1
UnRGB = (RGBCol And &HFF00) / &HFF
' mask 000000001111111100000000 and shift bits right
Case 2
UnRGB = (RGBCol And &HFF0000) / &HFFFF
' mask 111111110000000000000000 and shift bits right
End Select
End Function
It overflows on G and B value, but R works right, i need a working one :-) It's supposed to convert an RGB value (such as the RGB function) into the specified part (R G or B).
------------------
-Mystiq
[This message has been edited by mystiq (edited 11-27-1999).]
[This message has been edited by mystiq (edited 11-27-1999).]
-
Nov 27th, 1999, 06:44 AM
#2
Hyperactive Member
Please tell me what this is supposed to do before I try to answer. Is it supposed to return the value of a color selected,covert colors coded in other formats, or something different? I want to try to help.
-
Nov 27th, 1999, 09:17 AM
#3
Thread Starter
Member
In other words: unRGB(RGB(255,128,64),1) should return 128, because 1 is green, and the green value is 128. But the function doesn't work, it'll overflow, only red works.
------------------
-Mystiq
-
Nov 27th, 1999, 01:40 PM
#4
Try this instead:
Code:
Public Function UnRGB(ByVal RGBCol As Long, ByVal Part As Integer) As Integer
UnRGB = Val("&H" & Mid$(Right$("000000" & Hex(RGBCol), 6), 5 - (2 * Part), 2))
End Function
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Nov 27th, 1999, 01:43 PM
#5
Thread Starter
Member
Yay, that works, thanks 
------------------
-Mystiq
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
|