VB 中颜色互相转换的两个小函数(REG和 VB颜)
VB颜色和RGB色互相转换头疼了我好一段时间,如今找到解决办法了
特别贴出来与大家共享
Type RGB
Red As String
Green As String
Blue As String
End Type
Public Function ColorToRGB(ByVal dwColor As Long) As RGB
Dim clrHex As String
clrHex = Replace(Format(Hex$(dwColor), "@@@@@@"), " ", "0")
ColorToRGB.Red = Mid$(clrHex, 5, 2)
ColorToRGB.Green = Mid$(clrHex, 3, 2)
ColorToRGB.Blue = Mid$(clrHex, 1, 2) '
End Function
Public Function RgbToColor(ByVal rColor As String)
Dim tempColor As String, RedColor As String, GreenColor As String, BlueColor As String
tempColor = Replace(rColor, "0x", "")
RedColor = Mid(tempColor, 1, 2)
GreenColor = Mid(tempColor, 3, 2)
BlueColor = Mid(tempColor, 5, 2)
RgbToColor = RGB(Val("&H" & RedColor), Val("&H" & GreenColor), Val("&H" & BlueColor))
End Function
说明===============
ColorToRGB 作用是将VB中的颜色转换成RGB的颜色 比如 &H00FFFFFF& 会变成FFFFFF
RgbToColor 作用是将16进制的颜色 如FFFF00 转换成对应的十进制 再通过VB自带的RGB函数 转换成VB需要的颜色
相关文档:
代码:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetW ......
Public Sub DGToExcel(DataGrid1 As DataGrid, Optional ProgressBar1 As ProgressBar, Optional ByVal intFirst As Integer, Optional ByVal intLast As Integer, Optional strTitle As String)
'--将DataGrid导出至Excel,ProgressBar1为进度条,intFirst为从哪一列开始打印,intLast为打印到哪一列
On Error Resume ......
Option Explicit
Dim FSO As New FileSystemObject
Dim currentFolder As Folder
Dim currentFolderName As String
Dim folderItem, fileItem
Private Sub Form_Load()
currentFolderName = FSO.GetFolder(App.Path) & "\content"
SeachFolder (FSO.GetFolder(currentFolderName))
End Sub ......