VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Uses VB Code to convert the Color result from a Common Dialog Box to the RGB code for internet colo

by Joe Dacy II (6 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 18th December 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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



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:

Download this snippet    Add to My Saved Code

Uses VB Code to convert the Color result from a Common Dialog Box to the RGB code for internet colo Comments

No comments have been posted about Uses VB Code to convert the Color result from a Common Dialog Box to the RGB code for internet colo. Why not be the first to post a comment about Uses VB Code to convert the Color result from a Common Dialog Box to the RGB code for internet colo.

Post your comment

Subject:
Message:
0/1000 characters