Solved

# color and &HF0000000

Posted on 1998-09-21
Medium Priority
637 Views
I thought we need 6 digits to represent a color....but i found it is 8 digits, like &HF0000000.
Can you tell me how it works, which digit for what color?
0
Question by:learn
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 4

LVL 12

Accepted Solution

mark2150 earned 120 total points
ID: 1435870
You get 8 digits because color is a LONG value. Only the bottom six are required and the leading two zero's are often omitted.

pel = Me.Point(X, Y)
B = (pel And &HFF0000) / 65536
g = (pel And &HFF00) / 256 Mod 256
r = pel And &HFF

0

LVL 1

Expert Comment

ID: 1435871
I think THIS is the information that you requested.

It looks like we have &H00 at the beginning and & at the end with the middle 6 digits representing the colors:
0000xx - Red
00xx00 - Green
xx0000 - Blue

So we have:
&H000000FF&  - Red
&H0000FF00&  - Green
&H00FF0000&  - Blue
0

Author Comment

ID: 1435872
Hi
Looks very interesting:
pel = Me.Point(X, Y)
B = (pel And &HFF0000) / 65536
g = (pel And &HFF00) / 256 Mod 256
r = pel And &HFF
is pel a color? why we can do 'pel and &HFF0000?
0

LVL 12

Expert Comment

ID: 1435873
Wanted to get each color on the 0-255 range. Not much use in having the B range from 65536 to 16711680 in steps of 65536. Much easier to understand when all are 0-255 plus now you can do:

Me.PSet (x, y), RGB(r, g, b)

and have it work.

0

Author Comment

ID: 1435874
Hi Experts:

I have just found a color from VB:
&H8000000F&
If only lower six digits are used, why they put "80" at the first two positoins?
0

LVL 12

Expert Comment

ID: 1435875
MSB is *sign* bit ... Where did you find this tidbit? I've never seen a color value like this.

Don't know how the color function works on an internal level. It may simply ignore the MS byte or it could use it as a signal to change color modes. This could indicate that the color requested is #15 in the 16 color EGA palette.
0

Author Comment

ID: 1435876
In fact, I am using this color (&H8000000F& ) in my program and the color is the light gray, like the default back color of the form.

I want to use some very light colors but they must be solid...I have tried to use GBR() but not easy to found such color and that is why I copied the above color from VB.

Do you know how to make sure the color is solid from GBR() or from &H....&?
0

LVL 12

Expert Comment

ID: 1435877
How about a nice control to allow you to mix your own colors? You can diddle the RGB values until you have the color you want and it will show you what the RGB values are:

VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
Begin VB.Form Color
Caption         =   "Color Test"
ClientHeight    =   4665
ClientLeft      =   60
ClientTop       =   345
ClientWidth     =   7530
Icon            =   "colors.frx":0000
ScaleHeight     =   4665
ScaleWidth      =   7530
StartUpPosition =   3  'Windows Default
Begin VB.CommandButton Command1
Cancel          =   -1  'True
Caption         =   "Exit"
Height          =   615
Left            =   840
TabIndex        =   14
Top             =   3840
Width           =   5775
End
Begin VB.TextBox Text2
Height          =   375
Index           =   2
Left            =   6720
TabIndex        =   13
Text            =   "Text2"
ToolTipText     =   "Blue Setting"
Top             =   3000
Width           =   615
End
Begin VB.TextBox Text2
Height          =   375
Index           =   1
Left            =   6720
TabIndex        =   12
Text            =   "Text2"
ToolTipText     =   "Green Setting"
Top             =   2520
Width           =   615
End
Begin VB.TextBox Text2
Height          =   375
Index           =   0
Left            =   6720
TabIndex        =   11
Text            =   "Text2"
ToolTipText     =   "RED Setting"
Top             =   2040
Width           =   615
End
Begin VB.TextBox Text1
Alignment       =   2  'Center
Height          =   375
Left            =   5640
TabIndex        =   10
Text            =   "Text1"
ToolTipText     =   "Current Grey scale setting"
Top             =   1320
Width           =   975
End
Begin VB.PictureBox Picture2
Height          =   1815
Left            =   5640
ScaleHeight     =   1755
ScaleWidth      =   915
TabIndex        =   3
Top             =   1800
Width           =   975
End
Begin VB.PictureBox Picture1
Height          =   975
Left            =   5640
ScaleHeight     =   915
ScaleWidth      =   915
TabIndex        =   1
Top             =   240
Width           =   975
End
Begin ComctlLib.Slider Slider1
Height          =   495
Left            =   720
TabIndex        =   0
ToolTipText     =   "Adjust the grey scale level"
Top             =   480
Width           =   4575
_ExtentX        =   8070
_ExtentY        =   873
_Version        =   327682
Max             =   255
TickFrequency   =   5
End
Begin ComctlLib.Slider Slider2
Height          =   495
Index           =   0
Left            =   720
TabIndex        =   2
ToolTipText     =   "Adjust the amount of RED in the color mix"
Top             =   1920
Width           =   4575
_ExtentX        =   8070
_ExtentY        =   873
_Version        =   327682
Max             =   255
TickFrequency   =   5
End
Begin ComctlLib.Slider Slider2
Height          =   495
Index           =   1
Left            =   720
TabIndex        =   8
ToolTipText     =   "Adjust the amount of GREEN in the color mix"
Top             =   2520
Width           =   4575
_ExtentX        =   8070
_ExtentY        =   873
_Version        =   327682
Max             =   255
TickFrequency   =   5
End
Begin ComctlLib.Slider Slider2
Height          =   495
Index           =   2
Left            =   720
TabIndex        =   9
ToolTipText     =   "Adjust the amount of BLUE in the color mix"
Top             =   3120
Width           =   4575
_ExtentX        =   8070
_ExtentY        =   873
_Version        =   327682
Max             =   255
TickFrequency   =   5
End
Begin VB.Label Label4
Alignment       =   1  'Right Justify
Caption         =   "Blue"
Height          =   375
Left            =   120
TabIndex        =   7
Top             =   3240
Width           =   495
End
Begin VB.Label Label3
Alignment       =   1  'Right Justify
Caption         =   "Green"
Height          =   375
Left            =   120
TabIndex        =   6
Top             =   2640
Width           =   495
End
Begin VB.Label Label2
Alignment       =   1  'Right Justify
Caption         =   "Red"
Height          =   375
Left            =   120
TabIndex        =   5
Top             =   2040
Width           =   495
End
Begin VB.Label Label1
Alignment       =   2  'Center
Caption         =   "Grey Scale"
Height          =   255
Left            =   840
TabIndex        =   4
Top             =   120
Width           =   4575
End
End
Attribute VB_Name = "Color"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
Call die
End Sub

Text2(0).BackColor = vbRed
Text2(0).ForeColor = vbWhite
Text2(0).Text = "0"
Text2(1).BackColor = vbGreen
Text2(1).ForeColor = vbWhite
Text2(1).Text = "0"
Text2(2).BackColor = vbBlue
Text2(2).ForeColor = vbWhite
Text2(2).Text = "0"
Call set_grey
Call set_color
End Sub

Call die
End Sub

Private Sub Slider1_Change()
Call set_grey
End Sub

Private Sub Slider1_Scroll()
Call set_grey
End Sub

Private Sub Slider2_Change(Index As Integer)
Call set_color
End Sub

Public Sub set_grey()
grey = Slider1.Value
Picture1.BackColor = RGB(grey, grey, grey)
Picture1.Cls
Picture1.Refresh
Text1.Text = grey
End Sub
Public Sub set_color()
red = Slider2(0).Value
green = Slider2(1).Value
blue = Slider2(2).Value
Picture2.BackColor = RGB(red, green, blue)
Picture2.Cls
Picture2.Refresh
Text2(0).Text = red
Text2(1).Text = green
Text2(2).Text = blue
End Sub

Private Sub Slider2_Scroll(Index As Integer)
Call set_color
End Sub
Public Sub die()
Dim frm As Form
For Each frm In Forms
Next frm
End
End Sub

If this works - gimme da points!

M

0

Author Comment

ID: 1435878
Hi mark2150:

I believe the code may help me.

However, I don't know how to make that work. I need to compile that or not?

Cheers.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most pâ€¦
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can launâ€¦
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process fromâ€¦
###### Suggested Courses
Course of the Month12 days, 11 hours left to enroll