rgb与vb颜色互转 VB源码
源码如下:Option ExplicitPrivate Sub CmdRGBToVB_Click()
PicVB.BackColor = RGBColorToVB(tRGB)
PicNot.BackColor = NotRGB(tRGB)
tVBCor = RGBColorToVB(tRGB)
tNot = NotRGB(tRGB)
End SubPublic Function RGBColorToVB(Color As String) As String
Dim r As Integer, g As Integer, b As Integerr = Val("&H" + Mid(Color, 2, 2))
g = Val("&H" + Mid(Color, 4, 2))
b = Val("&H" + Mid(Color, 6, 2))RGBColorToVB = RGB(r, g, b)
End FunctionPublic Function NotRGB(Color As String) As String
Dim r As Integer, g As Integer, b As Integerr = Val("&H" + Mid(Color, 2, 2))
g = Val("&H" + Mid(Color, 4, 2))
b = Val("&H" + Mid(Color, 6, 2))NotRGB = RGB(255 - r, 255 - g, 255 - b)
End FunctionPublic Function VBColorToRGB(Color As Long) As String
Dim BGR As String, nRGB As String
Dim r As String, g As String, b As String
BGR = Hex(Color) r = Mid(BGR, 5, 2)
g = Mid(BGR, 3, 2)
b = Mid(BGR, 1, 2)
nRGB = r & g & bnRGB = nRGB & Space(6 - Len(nRGB))
nRGB = Replace(nRGB, Space(1), "0")VBColorToRGB = "#" & nRGB
End FunctionPrivate Sub CmdToRGB_Click()
tRGBCor = VBColorToRGB(tVB)
PicRGB.BackColor = RGBColorToVB(tRGBCor)
PicNot.BackColor = NotRGB(tRGBCor)
tNot = NotRGB(tRGBCor)
End SubPrivate Sub Form_Load()
Dim i As Integer
For i = 0 To tRGB.ListCount - 1
tVB.AddItem RGBColorToVB(tRGB.List(i))
Next i
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
End SubPrivate Sub tRGB_Click()
tVB.ListIndex = tRGB.ListIndex
End SubPrivate Sub tVB_Click()
tRGB.ListIndex = tVB.ListIndex
End Sub
谢谢不错啊 谢谢分享
页:
[1]