吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3297|回复: 2
收起左侧

[其他转载] rgb与vb颜色互转 VB源码

[复制链接]
温总 发表于 2014-4-17 08:49
源码如下:
1.jpg


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


发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

poiuy2013 发表于 2014-4-17 09:05
谢谢  不错啊
chinajr 发表于 2014-11-26 21:42
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-15 11:04

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表