- Home
·
- Graphics
·
- This will get the RGB values of a long color. This only works if you don't use system colors.
This will get the RGB values of a long color. This only works if you don't use system colors.
This will get the RGB values of a long color. This only works if you don't use system colors.
Rate This will get the RGB values of a long color. This only works if you don't use system colors.
(1(1 Vote))
Private Sub Command1_Click()
Dim R As Integer, G As Integer, B As Integer, Color As ColorConstants
Color = Me.BackColor
'This will not return anything if you are using system colors.
Call GetRGB(R%, G%, B%, Color)
Debug.Print "Red is " & R%
Debug.Print "Green is " & G%
Debug.Print "Blue is " & B%
End Sub
Public Function GetRGB(ByRef R As Integer, ByRef G As Integer, _
ByRef B As Integer, ByVal Color As ColorConstants)
Dim X As Long, Total As Double, TempTotal As Double, _
NewColor As Long
NewColor = Color
'Get's the Blue color
For X = 255 To 0 Step -1
If 65536 * X <= NewColor Then
B% = X
NewColor = NewColor - (65536 * X)
Exit For
End If
DoEvents
Next X
'Get's the Green color
For X = 255 To 0 Step -1
If 256 * X <= NewColor Then
G% = X
NewColor = NewColor - (256 * X)
Exit For
End If
DoEvents
Next X
'Get's the Red color
For X = 255 To 0 Step -1
If X <= NewColor Then
R% = X
NewColor = NewColor - X
Exit For
End If
DoEvents
Next X
End Function
This will get the RGB values of a long color. This only works if you don't use system colors. Comments
No comments yet — be the first to post one!
Post a Comment