CoderZone.org

Category: >> ASP/VB Code >> Convert RGB to Hex with ASP Bookmark and Share

<< lastnext >>

Snippet Name: Convert RGB to Hex with ASP

Description: Converts RGB color values to Hex color values.

Also see:
» Convert Minutes to Days, Hours, an...
» Resize and convert an image to a P...
» Convert text to image in php
» Convert a String to Title Case in ...
» Convert Extensions To Lowercase
» Tabs-To-Space Converter
» Convert Unix time string to a date...
» Convert Dollars And Cents Value to...
» LDAP Timestamp Converter
» Convert entities into normal chara...
» Make alternating color table rows ...
» Convert Seconds to Hours:Minutes:S...
» Convert UK Dates To mySQL Format D...
» Convert miles to feet, feet to mil...
» Converting Rows to Columns
» REFTOHEX
» RAWTONHEX
» RAWTOHEX
» HEXTORAW
» CONVERT
» Convert text to soundex
» Convert between Decimal, Binary, O...
» Convert LONGs to LOBs
» CSS Colornames to RGB values
» Convert Minutes to Hours
» Convert Hours to Minutes
» Basic currency conversion Convert...
» Update/convert DB field to upperca...
» Convert 12 to 24 hour time and vic...

Comment: (none)

Author:
Language: ASP
Highlight Mode: ASP
Last Modified: December 04th, 2010

Public Function RGB2Hex(R As Byte, G As Byte, _
   B As Byte) As String
 
'Input: 
'Numeric values for Red, Green, and Blue
' (i.e. '27', '44', '156')
'Returns:
'A hexadecimal string that can be used as an HTML Color
 
Dim HexR, HexB, HexG As Variant
Dim sTemp As String
 
On Error GoTo ErrorHandler
 
 'R
 HexR = Hex(R)
 If Len(HexR) < 2 Then HexR = "0" & HexR
 
 'Get Green Hex
 HexG = Hex(G)
If Len(HexG) < 2 Then HexG = "0" & HexG
 
HexB = Hex(B)
If Len(HexB) < 2 Then HexB = "0" & HexB
 
RGB2Hex = "#" & HexR & HexG & HexB
ErrorHandler:
End Function
 
Add a comment 
GarySep 17th, 2014 10:04am
So much tank u for posting this code block, really ussefull :D! sorry for my bad english
© coderzone.org | users online: 7