VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Very useful code to convert long to rgb, rgb to long, rgb to hex and qbcolor to rgb

by Jar87 (1 Submission)
Category: Graphics
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sat 18th March 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Very useful code to convert long to rgb, rgb to long, rgb to hex and qbcolor to rgb

Rate Very useful code to convert long to rgb, rgb to long, rgb to hex and qbcolor to rgb



Public Green As Integer
Public Blue As Integer


Public Sub ConvertQBColorToRGB(QBColorValue As Integer)

    If QBColorValue < 0 Or QBColorValue > 15 Then MsgBox "There's error in your QBColor.", vbCritical, "Error"

    ConvertLongToRGB (QBColor(QBColorValue))

End Sub


Public Function ConvertRGBToHex(RedColor As Integer, GreenColor As Integer, BlueColor As Integer)

    On Error GoTo ErrorInLongColor
    
    ConvertRGBToHex = Right(0 & Hex(RedColor), 2) & Right(0 & Hex(GreenColor), 2) & Right(0 & Hex(BlueColor), 2)
    Exit Function

ErrorInLongColor:
    MsgBox "There's error in your RGB color.", vbCritical, "Error"

End Function


Public Sub ConvertLongToRGB(Color As Long)

    On Error GoTo ErrorInLongColor

    Blue = Color \ 65536
    Green = (Color - Blue * 65536) \ 256
    Red = Color - (Blue * 65536) - (Green * 256)

    Exit Sub

ErrorInLongColor:
    MsgBox "There's error in your long color.", vbCritical, "Error"
    
End Sub


Public Function ConvertRGBToLong(RedColor As Integer, GreenColor As Integer, BlueColor As Integer)

    On Error GoTo ErrorInLongColor
    
    ConvertRGBToLong = RGB(RedColor, GreenColor, BlueColor)
    Exit Function

ErrorInLongColor:
    MsgBox "There's error in your RGB color.", vbCritical, "Error"
    
End Function


Download this snippet    Add to My Saved Code

Very useful code to convert long to rgb, rgb to long, rgb to hex and qbcolor to rgb Comments

No comments have been posted about Very useful code to convert long to rgb, rgb to long, rgb to hex and qbcolor to rgb. Why not be the first to post a comment about Very useful code to convert long to rgb, rgb to long, rgb to hex and qbcolor to rgb.

Post your comment

Subject:
Message:
0/1000 characters