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需要的颜色
相关文档:
本程序有一菜单开始,里面有查询,删除,修改,添加,程序不一一列出,只写出基本的过程,连接数据库采用标准模块:
'Public publicstr As String
Public conn As ADODB.Connection
Public rs As ADODB.Recordset
Public Sub main() '数据库连接共享函数
Set conn = New ADODB.Connect ......
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 ......
之前碰到一个问题,VB中向一个C++写的DLL中注册一个Callback,C++在调用这个Callback时有些问题,具体问题描述和下面这个帖子中的情况是一样的: http://topic.csdn.net/t/20051104/09/4370840.html
经过尝试以后发现,在VB中写的回调函数必须是用Function关键字,并且,必须要设置返回值,如下:
Public Function Callbac ......
本文来自此帖的冗长讨论,感谢Tiger_Zhao的全程指点和陈辉、阿勇、马云剑等很多朋友的热心参与。本文其他部分在:(二)、(三)、(四)。
话说VB6是个很认真细致的妈妈,它会悄没声地帮你做很多事。今天我们来说的是VB6在API调用时自动对字符串参数进行转换的“好人好事”。
第一节 体贴的VB妈 ......
Public Class Form1
Private Sub CmdTrans_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdTrans.Click
Dim psi As New System.Diagnostics.ProcessStartInfo
Dim ftpFileName As String
psi.FileName = "ftp.exe"
psi.RedirectStandardInput = ......