Translate Color Values

Translate Color Values

With the RGB function, VB provides a neat and valuable tool for converting separate Red, Green, and Blue values into a single Long color value.. However, VB won’t let you translate back from its this color value to back to its constituent RGB values. But, you can pick the individual colors out of a hexadecimal representation of the Long value produced by RGB. The colors fall in “BBGGRR” order. Put this code in a module:

 Type RGB_Type	R As Long	G As Long	B As LongEnd TypeFunction ToRGB(ByVal Color As Long) As RGB_Type	Dim ColorStr As String	ColorStr = Right$("000000" & Hex$(Color), 6)	With ToRGB	.R = Val("&h" & Right$(ColorStr, 2))	.G = Val("&h" & Mid$(ColorStr, 3, 2))	.B = Val("&h" & Left$(ColorStr, 2))	End WithEnd Function

To use this function, put a picture in a form’s Picture property, and insert this code in that form:

 Private Sub Form_MouseUp(Button As Integer, Shift _	As Integer, X As Single, Y As Single)	Dim RGB_Point As RGB_Type	RGB_Point = ToRGB(Point(X, Y))	Caption = RGB_Point.R & " " & RGB_Point.G & " " & _		RGB_Point.BEnd Sub

Click on different places on the picture. VB3 users must return the values differently, because VB didn’t support the return of a user-defined type until VB4.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several