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需要的颜色
相关文档:
VB中的Unicode 和 Ansi 格式
Visual Basic 32-bit 版本的字串处理采用 Unicode,也就是说字串在 VB 内部是以Unicode 的格式来存放。何谓 Unicode?简单的说,就是每一个字符都是以 2-byte 的形式表示,而每个「实体字符」就是一个「字符」。因此,
Len("大家好")
Len("abc")
& ......
Private Sub PrintTxt(txt As String, ConWidth As Long, LeftPosition As Long)
Dim str As String
Dim str1 As String
Dim len1 As Long
str = txt
len1 = ConWidth
&nbs ......
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 ......
在日常的操作系统维护过程中,有时我们也会写一些小的脚本程序来简化系统管理工作,例如调用一些WMI函数来自动安装卸载程序之类的。
在实际工作中,我发现程序员对脚本抱怨最多的就是脚本程序很难调试这个缺点,特别是调试.vbs等WSH程序的时候,总是:
1. 在资源管理器里面双击一个. ......
JavaScript/VB Script脚本程序一般有两种执行方式,一种是嵌入在宿主程序里面执行,比如在IE浏览器里面执行;另外一种,在资源管理器里面双击执行(虽然还是通过另外一个程序解释执行,但是给人的感觉毕竟是直接运行)。
这两种方式,都可以使用Visual Studio来进行调试,先看大家用得比较频繁的网页脚本程序的调试:
1 ......