- Home
·
- Internet/HTML
·
- Uses VB Code to convert the Color result from a Common Dialog Box to the RGB code for internet colo
Uses VB Code to convert the Color result from a Common Dialog Box to the RGB code for internet colo
Uses VB Code to convert the Color result from a Common Dialog Box to the RGB code for internet colors (e.g. #FF00FF) for use in web pages.
Rate Uses VB Code to convert the Color result from a Common Dialog Box to the RGB code for internet colo
(1(1 Vote))
Dim B As Variant
Dim G As Variant
Dim RV As String
Dim GV As String
Dim BV As String
Dim LG As Long
On Error Goto NoColor
If CommonDialog1.Color <> Empty Then
LG = Val(CommonDialog1.Color)
' Get the color code (long) from a commondialog box
B = LG \ 65536
G = (LG - B * 65536) \ 256
R = LG - B * 65536 - G * 256
'Convert the calculations to hex strings
BV = Hex(B)
RV = Hex(R)
GV = Hex(G)
' Ensure that, if the string is "0" the other "0" is added to the final string
If CStr(GV) = "0" Then
GV = "00"
End If
If CStr(RV) = "0" Then
RV = "00"
End If
If CStr(BV) = "0" Then
BV = "00"
End If
' The RGB Internet Color Code
MsgBox "#" & RV & GV & BV
End If
NoColor:
Uses VB Code to convert the Color result from a Common Dialog Box to the RGB code for internet colo Comments
No comments yet — be the first to post one!
Post a Comment