VB icon

Color RGB from a Long Using "Point" method

Email
Submitted on: 1/2/2015 8:15:00 PM
By: Brandon Brownlee (from psc cd)  
Level: Not Given
User Rating: By 39 Users
Compatibility: VB 5.0, VB 6.0
Views: 478
 
     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.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Color RGB from a Long Using "Point" method
' Description: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.
' By: Brandon Brownlee (from psc cd)
'
' Returns:Returns Rgb(R,G,B) format from a Long Value
'
' 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.
'**************************************

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


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.