VB 颜色值十六进制与RGB之间怎样转换?
2个回答
展开全部
反回RGB数组的一个函数
Public Function ColorRGB(Color As Long) As Byte()
Const ByN As Integer = 256
Const ByN2 As Long = 65536
Dim A(2) As Byte
A(0) = (Color Mod ByN)
A(1) = ((Color Mod ByN2) \ ByN)
A(2) = (Color \ ByN2)
ColorRGB = A
End Function
例如:
Print ColorRGB(&H1111FF)(0) '红色RGB
Print ColorRGB(&H11FF11)(1) '绿色RGB
Print ColorRGB(&HFF1111)(2) '蓝色RGB
都等于255
变回十六进制更简单
HEX(RGB(1,1,1))
Public Function ColorRGB(Color As Long) As Byte()
Const ByN As Integer = 256
Const ByN2 As Long = 65536
Dim A(2) As Byte
A(0) = (Color Mod ByN)
A(1) = ((Color Mod ByN2) \ ByN)
A(2) = (Color \ ByN2)
ColorRGB = A
End Function
例如:
Print ColorRGB(&H1111FF)(0) '红色RGB
Print ColorRGB(&H11FF11)(1) '绿色RGB
Print ColorRGB(&HFF1111)(2) '蓝色RGB
都等于255
变回十六进制更简单
HEX(RGB(1,1,1))
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询