VB取各顏色分量,將RGB轉爲HTML顏色.

 
  1. '//取各顏色分量
  2. Public Function GetRedValue(COLOR As LongAs Integer '取得紅色值
  3.        GetRedValue = COLOR And 
  4. End Function
  5. Public Function GetGreenValue(COLOR As LongAs Integer '取得綠色值
  6.        GetGreenValue = (COLOR And 65280) / 256
  7. End Function
  8. Public Function GetBlueValue(COLOR As LongAs Integer '取得藍色值
  9.         GetBlueValue = (COLOR And &HFF0000) / 65536
  10. End Function
  11. '//將RGB轉化爲HTML顏色.
  12. Public Function GetHexColor(Red As Integer, Green As Integer, Blue As IntegerAs String 
  13. '將RGB顏色轉換爲HTML顏色
  14.   Dim StrRed As String, StrGreen As String, StrBlue As String
  15.   StrRed = Hex(Red)
  16.   StrGreen = Hex(Green)
  17.   StrBlue = Hex(Blue)
  18.   If Red <= 16 Then StrRed = "0" & StrRed
  19.   If Green <= 16 Then StrGreen = "0" & StrGreen
  20.   If Blue <= 16 Then StrBlue = "0" & StrBlue
  21.   GetHexColor = StrRed & StrGreen & StrBlue
  22. End Function
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章