Hex to Dec (RGB)


/ Published in: VB.NET
Save to your folder(s)

Convert hexidecimal color codes (ie #C0C0C0) to decimal RGB (ie 255,255,255)


Copy this code and paste it in your HTML
  1. Public Function GiveDec(Hex)
  2. if Hex = "A" then
  3. Value = 10
  4. elseif Hex = "B" then
  5. Value = 11
  6. elseif Hex = "C" then
  7. Value = 12
  8. elseif Hex = "D" then
  9. Value = 13
  10. elseif Hex = "E" then
  11. Value = 14
  12. elseif Hex = "F" then
  13. Value = 15
  14. else
  15. Value = Hex
  16. end if
  17. GiveDec = Value
  18. End Function
  19.  
  20. Public Function HexToDec(Hex)
  21. Dim a,b,c,d,e,f,x,y,z,fHex
  22. fHex = Replace(Hex,"#","")
  23.  
  24. a = Left(fHex,1)
  25. a = GiveDec(a)
  26. b = Mid(fHex,2,1)
  27. b = GiveDec(b)
  28. c = Mid(fHex,3,1)
  29. c = GiveDec(c)
  30. d = Mid(fHex,4,1)
  31. d = GiveDec(d)
  32. e = Mid(fHex,5,1)
  33. e = GiveDec(e)
  34. f = Right(fHex,1)
  35. f = GiveDec(f)
  36.  
  37. x = (a * 16) + b
  38. y = (c * 16) + d
  39. z = (e * 16) + f
  40.  
  41. HexToDec = """" & x & "," & y & "," & z & """"
  42. End Function

URL: http://codefinds.blogspot.com/2007/10/hex-to-dec-vbscript.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.