Skip to main content

[archive] Define VB colour value &H8000000B in COBOL

  • May 24, 2007
  • 8 replies
  • 1 view

[Migrated content. Thread originally posted on 23 May 2007]

How can I define the following VB constant to a COBOL variable and use it to set an ActiveX property?

Global Const CAL_COLORDEFAULT = &H8000000B

'the constant is used as
Cal.ElementBackColor = CAL_COLORDEFAULT


Thanks

8 replies

[Migrated content. Thread originally posted on 23 May 2007]

How can I define the following VB constant to a COBOL variable and use it to set an ActiveX property?

Global Const CAL_COLORDEFAULT = &H8000000B

'the constant is used as
Cal.ElementBackColor = CAL_COLORDEFAULT


Thanks
We set colors in ActiveX controls all of the time, but they are always hex values. For example, to set the color to black, we would use:

MODIFY CONTROL @COLOR = X#000000.

Not sure what this CAL_COLORDEFAULT is...

Rob

[Migrated content. Thread originally posted on 23 May 2007]

How can I define the following VB constant to a COBOL variable and use it to set an ActiveX property?

Global Const CAL_COLORDEFAULT = &H8000000B

'the constant is used as
Cal.ElementBackColor = CAL_COLORDEFAULT


Thanks

77 Cal_colordefault Pic X(4) Comp-n.
...
Move X"8000000b" To Cal_colordefault.

[Migrated content. Thread originally posted on 23 May 2007]

How can I define the following VB constant to a COBOL variable and use it to set an ActiveX property?

Global Const CAL_COLORDEFAULT = &H8000000B

'the constant is used as
Cal.ElementBackColor = CAL_COLORDEFAULT


Thanks
77 Cal_colordefault Pic X(4) Comp-n.
...
Move X"8000000b" To Cal_colordefault


Thanks Gisle for the code. It didn't work as it does in VB.

As far as I understand it, I am sure someone will correct me if I am wrong, VB colour values starting with "&H8" are windows default colour values and ones starting with "&H0" are color pallet (RGB) values.

To create the same effect as VB I had to use the following move statement which produced a different value in the 77 variable

Move X#8000000b To Cal_colordefault.

I wonder if anyone can explain the difference between the 2 move statements?

Thanks

[Migrated content. Thread originally posted on 23 May 2007]

How can I define the following VB constant to a COBOL variable and use it to set an ActiveX property?

Global Const CAL_COLORDEFAULT = &H8000000B

'the constant is used as
Cal.ElementBackColor = CAL_COLORDEFAULT


Thanks
The prefix &H is a reserved token in vb, it indicates that the number following is a hexadecimal number.

So, in your case:

&H8000000B

Breaking it down;
&H is the token to signal a hex value.
8000000B is the hexadecimal number.

You may say that &H is the same as in COBOL: X"

Also notice that you may as well see:
&H0000000B

In which case you may think, why all the zeroes... This is a common feature when using hex literals. The padding is used by the compiler (many languages) to determine the bytesize of the literal. Like in the case above, it is 8 digits, knowing that one byte is FF, that leaves us dividing by 2 and we get the length that is 4 bytes.

As for colors, in windows' colors are 4 byte, so you can always assume that when you see a color variable, that it is 4 byte unsigned, or PIC X(4) COMP-N if you like.

If you wonder about the difference between X"8000000B" and X#8000000B, I have never seen the latter. If it set a hex value as the first, then it is just a variant of the syntax and I have learned something new :-)

Hope this helps.

[Migrated content. Thread originally posted on 23 May 2007]

How can I define the following VB constant to a COBOL variable and use it to set an ActiveX property?

Global Const CAL_COLORDEFAULT = &H8000000B

'the constant is used as
Cal.ElementBackColor = CAL_COLORDEFAULT


Thanks
Thank you Gisle, it gives me a clearer understanding.

Checking again in debug the difference between X"8000000B" and X#8000000B is, they do produce different hex values

77 Cal_colordefault Pic X(4) Comp-n.
...
Move X"8000000b" To Cal_colordefault.

sets hex value of "BB230100" , while

Move X#8000000b To Cal_colordefault.
sets hex value of "0B000080"

So it seems that the 2nd statement produces an accurate representation of the original hex &H0800000B.

I am even more curious why the difference. It would enhance our knowledge if we can understand when to use X"..." and when to use X#. Anyone else have any ideas?

[Migrated content. Thread originally posted on 23 May 2007]

How can I define the following VB constant to a COBOL variable and use it to set an ActiveX property?

Global Const CAL_COLORDEFAULT = &H8000000B

'the constant is used as
Cal.ElementBackColor = CAL_COLORDEFAULT


Thanks
Gisle,

I remember when I was attending one of your classes that you pointed out that hex values were not being properly sent to controls, etc. Perhaps you will remember... The values should have been defined as Red, Green, and Blue, but instead had to be defined as Blue, Green, Red. Could the differences in these syntaxes be related to this or am I completely off base?

Rob

[Migrated content. Thread originally posted on 23 May 2007]

How can I define the following VB constant to a COBOL variable and use it to set an ActiveX property?

Global Const CAL_COLORDEFAULT = &H8000000B

'the constant is used as
Cal.ElementBackColor = CAL_COLORDEFAULT


Thanks
This was really interesting. I have no answer to this. Learning something new here. I am confident there is an explanation to it though. I need to find and read about the X# syntax.

Rob; Yes the order of Red, Green, Blue is important, but in this case here we have not been considering that at all, not yet anyway.

[Migrated content. Thread originally posted on 23 May 2007]

How can I define the following VB constant to a COBOL variable and use it to set an ActiveX property?

Global Const CAL_COLORDEFAULT = &H8000000B

'the constant is used as
Cal.ElementBackColor = CAL_COLORDEFAULT


Thanks
Doing some more digging in help, I found article "2.1.2.1 Numeric literals" in the Reference Manual. The second para reads:

"If a literal conforms to the rules for formation of a numeric literal, but is enclosed in quotation marks, it is a nonnumeric literal."


I deduce that X"..." creates a hex value of a nonnumeric literal while X# creates a hex value of numeric literal.

Good to be aware of the difference especially where ActiveX controls are concerned.