473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Integer literals

I'm trying to use a third party .Net charting control. One of its
methods takes a standard 4-byte integer as a parameter (to specify a
colour actually, but it's done as a standard integer value and not eg
a colour object). Because the colour will be in ARGB colour space the
integer needs to specify all four bytes.

But if I try to pass the integer as eg &HFFCCDDEE then the VB2005
Intellisense immediately seems to knock this back to &HCCDDEE, which
is then an incorrect value.

There are some workarounds I can use involving methods to convert
between colour spaces (eg starting with color.fromARGB), but I'm
curious as to why what seems to be the simple straightforward approach
of specifying the required integer directly in a 4-byte/8-digit format
is failing. Is there an alternative syntax that I need to use to
specify 4-byte values?

JGD
Jun 18 '06 #1
6 1663
Hi,

Maybe ColorTranslator.FromOle will work.

http://msdn2.microsoft.com/en-us/lib...r.fromole.aspx

Ken
---------------------

"John Dann" wrote:
I'm trying to use a third party .Net charting control. One of its
methods takes a standard 4-byte integer as a parameter (to specify a
colour actually, but it's done as a standard integer value and not eg
a colour object). Because the colour will be in ARGB colour space the
integer needs to specify all four bytes.

But if I try to pass the integer as eg &HFFCCDDEE then the VB2005
Intellisense immediately seems to knock this back to &HCCDDEE, which
is then an incorrect value.

There are some workarounds I can use involving methods to convert
between colour spaces (eg starting with color.fromARGB), but I'm
curious as to why what seems to be the simple straightforward approach
of specifying the required integer directly in a 4-byte/8-digit format
is failing. Is there an alternative syntax that I need to use to
specify 4-byte values?

JGD

Jun 18 '06 #2
An Int32 is a signed data type, which means that it can hold the values
-&H80000000 to &H7fffffff. Therefore &Hffccddee is not a valid value for
an Int32. You can use the value -3351058 or -&H332212.

John Dann wrote:
I'm trying to use a third party .Net charting control. One of its
methods takes a standard 4-byte integer as a parameter (to specify a
colour actually, but it's done as a standard integer value and not eg
a colour object). Because the colour will be in ARGB colour space the
integer needs to specify all four bytes.

But if I try to pass the integer as eg &HFFCCDDEE then the VB2005
Intellisense immediately seems to knock this back to &HCCDDEE, which
is then an incorrect value.

There are some workarounds I can use involving methods to convert
between colour spaces (eg starting with color.fromARGB), but I'm
curious as to why what seems to be the simple straightforward approach
of specifying the required integer directly in a 4-byte/8-digit format
is failing. Is there an alternative syntax that I need to use to
specify 4-byte values?

JGD

Jun 18 '06 #3
John,
I am able to use the following in VB 2005.

Dim hexColor As Integer = &HFFCCDDEE

If I look at the variable in the hexColor variable in a watch window, it
contains either &HFFCCDDEE in hex or -3351058

Are you certain that VB is changing the value & not the control itself?
I would question the quality of any .NET charting control that didn't use
System.Drawing.Color to specify color values! As you should need to worry
about any "workarounds" or how to specify a color...
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"John Dann" <ne**@prodata.co.uk> wrote in message
news:fk********************************@4ax.com...
| I'm trying to use a third party .Net charting control. One of its
| methods takes a standard 4-byte integer as a parameter (to specify a
| colour actually, but it's done as a standard integer value and not eg
| a colour object). Because the colour will be in ARGB colour space the
| integer needs to specify all four bytes.
|
| But if I try to pass the integer as eg &HFFCCDDEE then the VB2005
| Intellisense immediately seems to knock this back to &HCCDDEE, which
| is then an incorrect value.
|
| There are some workarounds I can use involving methods to convert
| between colour spaces (eg starting with color.fromARGB), but I'm
| curious as to why what seems to be the simple straightforward approach
| of specifying the required integer directly in a 4-byte/8-digit format
| is failing. Is there an alternative syntax that I need to use to
| specify 4-byte values?
|
| JGD
Jun 18 '06 #4
Göran,
| An Int32 is a signed data type, which means that it can hold the values
| -&H80000000 to &H7fffffff
Actually it can hold the hex literals &H0 to &HFFFFFFFF; When assigning a
Hex Literal to an Integer, &H80000000 to &HFFFFFFFF are negative numbers
representing Int32.MinValue to -1.

The hex literals are sign agnostic, VB allows the assignment based on the
number of digits given... (10 hex digits will not fix in an Integer).

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Göran Andersson" <gu***@guffa.com> wrote in message
news:Ol**************@TK2MSFTNGP02.phx.gbl...
| An Int32 is a signed data type, which means that it can hold the values
| -&H80000000 to &H7fffffff. Therefore &Hffccddee is not a valid value for
| an Int32. You can use the value -3351058 or -&H332212.
|
| John Dann wrote:
| > I'm trying to use a third party .Net charting control. One of its
| > methods takes a standard 4-byte integer as a parameter (to specify a
| > colour actually, but it's done as a standard integer value and not eg
| > a colour object). Because the colour will be in ARGB colour space the
| > integer needs to specify all four bytes.
| >
| > But if I try to pass the integer as eg &HFFCCDDEE then the VB2005
| > Intellisense immediately seems to knock this back to &HCCDDEE, which
| > is then an incorrect value.
| >
| > There are some workarounds I can use involving methods to convert
| > between colour spaces (eg starting with color.fromARGB), but I'm
| > curious as to why what seems to be the simple straightforward approach
| > of specifying the required integer directly in a 4-byte/8-digit format
| > is failing. Is there an alternative syntax that I need to use to
| > specify 4-byte values?
| >
| > JGD
Jun 18 '06 #5
On Sun, 18 Jun 2006 15:18:15 -0500, "Jay B. Harlow [MVP - Outlook]"
<Ja************@tsbradley.net> wrote:
Are you certain that VB is changing the value & not the control itself?
Many thanks for the comments. What I observe is that I can enter a
value of eg &HFFC0C0C0 as a parameter in a call to a method of the
charting control. As soon as I move the cursor out of that code line
in the VB2005 code editor then the value flicks back to &HC0C0C0.
This is why I referred to it as happening as a result of Intellisense.
But whether this behaviour is triggered by VB itself or perhaps by the
variable type exposed by the charting control for the parameter in
question is I'm afraid beyond me!
I would question the quality of any .NET charting control that didn't use
System.Drawing.Color to specify color values! As you should need to worry
about any "workarounds" or how to specify a color...


That's probably fair comment. It's actually a control called
ChartDirector (from www.advsofteng.com/). I suspect the cause is that
the core of this control is actually compatible with many programming
languages and it possibly just has a wrapper in its .Net version. So
some of the variable types may need conversion - I know the
documentation makes the point that its ARGB implementation follows the
general HTML/web convention and not the .Net one.

But that said, in compensation it is excellent value-for-money,
powerful and flexible, a reasonably easy learning curve (much more so
than many competitor products), well-supported, produces good quality
results and seems to run robustly (other than the sort of quirk which
was the reason for the original post). So you can see why I like to
use this one!

JGD
Jun 19 '06 #6

John Dann wrote:
On Sun, 18 Jun 2006 15:18:15 -0500, "Jay B. Harlow [MVP - Outlook]"
<Ja************@tsbradley.net> wrote:
Are you certain that VB is changing the value & not the control itself?


Many thanks for the comments. What I observe is that I can enter a
value of eg &HFFC0C0C0 as a parameter in a call to a method of the
charting control. As soon as I move the cursor out of that code line
in the VB2005 code editor then the value flicks back to &HC0C0C0.
This is why I referred to it as happening as a result of Intellisense.
But whether this behaviour is triggered by VB itself or perhaps by the
variable type exposed by the charting control for the parameter in
question is I'm afraid beyond me!


It actually changes the code you typed? That's unusual.
I would question the quality of any .NET charting control that didn't use
System.Drawing.Color to specify color values! As you should need to worry
about any "workarounds" or how to specify a color...


That's probably fair comment. It's actually a control called
ChartDirector (from www.advsofteng.com/).


OK I grabbed the trial version. First things first - as stated in their
docs, the ARGB format they expect has it's 'A' the other way round from
..NET:

"
The .NET framework has a class System.Drawing.Color used to represent
colors. However, its ARGB color representation is not compatible with
ChartDirector. For example, in System.Drawing.Color, the red color is
FFFF0000 instead of FF0000. The reason is because the alpha component
in .NET actually refers to opacity - the reverse of transparency as
used in ChartDirector.
"

So considering the solid grey color we are talking about:

- In .NET, this color's .ToArgb is &HFFC0C0C0, with the FF representing
maximum *opacity*
- In HTML convention, this color would be &HC0C0C0, with the initial 00
representing zero *transparency*

This control wants its colors in HTML format, so anything like
&HFFxxxxxx would be completely *transparent*, so the xxxxxx would be
irrelevant. Again from the docs:

"
If alpha transparency is FF (255), the color is totally transparent.
That means the color is invisible. It does not matter what the RGB
components are. So in ChartDirector, only one totally transparent color
is used - FF000000. All other colors of the form FFnnnnnn are reserved
to represent palette colors and dynamic colors, and should not be
interpreted as the normal ARGB colors.
....
For convenience, ChartDirector pre-defines a constant called
Transparent, which is equivalent to FF000000.
"

So this explains the 'why' of it automatically changing the code you
write, when you try and pass &HFFC0C0C0. This is a 'special' value and
probably not what anyone typing it means, so it autocorrects it to
&HC0C0C0, which is probably what is meant. The 'how' is another
question, which isn't totally relevant so I haven't spent much time
looking into it.

I note finally from the docs the existence of helper functions
(Chart.CColor and Chart.NColor) to convert between the two different
color representations - these should be used for code clarity.

--
Larry Lard
Replies to group please

Jun 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: bruce.james.lee | last post by:
hi i have a problem with integer subtraction in C. printf("%d", c < (a - b)); a is got from a #define and is 0x80000000 and b is got from input and is also 0x80000000. c is ffffffff (-1). Now,...
61
by: John Baker | last post by:
When declaring an integer, you can specify the size by using int16, int32, or int64, with plain integer being int32. Is integer the accepted default in the programming community? If so, is...
16
by: Stefan Wallentowitz | last post by:
Hello together! I'm searching for a statistic about the value ranges of integers in a set of "standard" c-programs. I'm specifically interested in the avarage ratio of assignments etc. of...
33
by: gk245 | last post by:
I mean, anything that follows a 0 is automatically turned into a octal number. I want to have a integer variable that will hold numbers as integers even if they begin with a zero. for example:...
5
by: bradeck | last post by:
A question recently came up of late in some interviewing techniques discussions and I vaguely remember this being an ANSI C++ related issue but cannot remember the specifics. Basically if you have...
15
by: Ivan Novick | last post by:
Hi, Is it possible to have negative integer literal or only positive? As far as I understand, the code below would be a positive integer literal and the unary negative operator. x = -3.2; ...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
7
by: Gary Brown | last post by:
Hi, I have a whole bunch of integer constants that are best given in octal (PDP-1 opcodes). It makes a huge difference in readability and authenticity if these can be entered in octal. I...
4
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Here's a macro that Mathew Hendry posted back in the year 2000 for achieving binary integer literals that evaluate to compile-time constants: #define BIN8(n)\ (((0x##n##ul&1<<...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.