Display Html Hex Value When Given Rgb Value





-5
Date Submitted Tue. Feb. 28th, 2006 5:27 AM
Revision 1 of 1
Syntax Master dannyboy
Tags ASP | Convert | VBSCRIPT
Comments 0 comments
Displays the hex value for an HTML color given the decimal RGB values. Uses Internet Explorer to show the hex value in the color itself.

option explicit
' Get the decimal RGB values from the user (0 through 255)...
dim r, g, b
r = hex(inputbox("Enter red value (between 0 and 255):", "HTML Color"))
g = hex(inputbox("Enter green value (between 0 and 255):", "HTML Color"))
b = hex(inputbox("Enter blue value (between 0 and 255):", "HTML Color"))
' Pad the hex value with a zero if needed...
r = string(2 - len(r), "0") & r
g = string(2 - len(g), "0") & g
b = string(2 - len(b), "0") & b
' Create the HTML hex color string...
dim s: s = "#" & r & g & b
' Paste this into IE...
dim ie
set ie = createobject("internetexplorer.application")
ie.height = 100
ie.width = 300
ie.menubar = false
ie.toolbar = false
ie.statusbar = false
ie.addressbar = false
ie.navigate "about:blank"
do while ie.busy
wscript.sleep 50
loop
ie.document.write "HTML Color" & s & ""
ie.visible = true
 

Comments

There are currently no comments for this snippet.

Voting