源码如下:
Option Explicit Private Sub CmdRGBToVB_Click()
PicVB.BackColor = RGBColorToVB(tRGB)
PicNot.BackColor = NotRGB(tRGB)
tVBCor = RGBColorToVB(tRGB)
tNot = NotRGB(tRGB)
End Sub Public Function RGBColorToVB(Color As String) As String
Dim r As Integer, g As Integer, b As Integer r = 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 Function Public Function NotRGB(Color As String) As String
Dim r As Integer, g As Integer, b As Integer r = 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 Function Public 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 & b nRGB = nRGB & Space(6 - Len(nRGB))
nRGB = Replace(nRGB, Space(1), "0") VBColorToRGB = "#" & nRGB
End Function Private Sub CmdToRGB_Click()
tRGBCor = VBColorToRGB(tVB)
PicRGB.BackColor = RGBColorToVB(tRGBCor)
PicNot.BackColor = NotRGB(tRGBCor)
tNot = NotRGB(tRGBCor)
End Sub Private 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 Sub Private Sub tRGB_Click()
tVB.ListIndex = tRGB.ListIndex
End Sub Private Sub tVB_Click()
tRGB.ListIndex = tVB.ListIndex
End Sub
|