VB 里颜色值的存储格式是 BGR(蓝 - 绿 - 红),并非通常的 RGB(红 - 绿 - 蓝)。
Private Function f_changeRRGGBB(ByVal strColorOld As String, Optional strSymbol As String = "&H") As String
'RRGGBB 变成 BBGGRR
Dim r$, g$, b$
strColorOld = Right("000000" & strColorOld, 6) '补足六位
If Left(strColorOld, 1) = "#" Then strColorOld = Mid(strColorOld, 2) ' 去除可能存在的 # 符号
If UCase(Left(strColorOld, 2)) = "&H" Then strColorOld = Mid(strColorOld, 3) ' 去除可能存在的 &H 符号
r = Mid(strColorOld, 1, 2) ' 提取红、绿、蓝分量
g = Mid(strColorOld, 3, 2)
b = Mid(strColorOld, 5, 2)
f_changeRRGGBB = strSymbol & b & g & r
End Function
Private Sub Command1_Click()
Debug.Print f_changeRRGGBB("AABBCC")
End Sub
运行结果:
&HCCBBAA