[AccessD] defining constants as hex numbers

John Colby jcolby at colbyconsulting.com
Mon Nov 3 08:14:57 CST 2003


Gustav,

I am dealing with longs and am doing bit manipulations of individual bits
(which is why I want Hex to begin with) so I must have the ability to deal
with upper bits.  However I avoid the sign bit so I don't really care if it
"makes it negative" as long as it doesn't do so by propagating a 1 through
all of the upper bits such that all of the upper 16 bits are a 1.

John W. Colby
www.colbyconsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Gustav Brock
Sent: Monday, November 03, 2003 5:32 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] defining constants as hex numbers


Hi John, Stuart

But be careful with values above the max. positive value of a signed
Integer

  &H7FFF

as these evaluates to negative values in VB.
Not even assigning such a value to a constant or a variable declared
as Long will help you.

If you expect, say, 65535 for &HFFFF, add the type declaration sign
for Long:

  &HFFFF&

or make it initially a Long by adding and subtracting one

  &H10000 - 1

or wrap it, again forcing a Long and taking advantage of &HFFFF as a
fancy way of writing -1

  &H10000 + &HFFFF

The last one is a nice item to add in your box of tools for writing
unreadable code!

/gustav


>> how do you force VB to consider a number hex?  I thought there was
something
>> like h0f but I can't get it to work and NOT help isn't.
>>
> &H

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list