by Brandon Brownlee (1 Submission)
Category: Math/Dates
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (39 Votes)
After using the POINT method the computer returns a long value like 16711680 but with this function it will return the color in the RGB(R,G,B)
format.
Assumes
Start a new project and make any picture you have the background for your form.
Then start it and move the mouse on the form and look at the caption of the form.
Code Returns
Returns Rgb(R,G,B) format from a Long Value
Public Blue As Double
Public Green As Double
Public Red As Double
Public BlueS As Double
Public GreenS As Double
Public RGBs As String
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, _
Y As Single)
Call ConvertRGB(Form1.Point(X, Y))
Form1.Caption = RGBs
End Sub
Public Function ConvertRGB(P)
Blue = Fix((P / 256) / 256)
BlueS = (Blue * 256) * 256
Green = Fix((P - BlueS) / 256)
GreenS = Green * 256
Red = Fix(P - BlueS - GreenS)
RGBs = "RGB(" & Red & ", " & Green & ", " & Blue & ")"
End Function