## How do you get hex zeros and hex FF into a variable

### How do you get hex zeros and hex FF into a variable

How do you get hex zero or hex 'FF' into a variable ?

I tried:
If Hex(255) < "Z" Then
MsgBox "Hex(255) is less than 'Z'"
End If

and the message box does appear.
Shouldn't "Hex(255)" equate to a &FF ?

Any help appreciated.

Thanks,
Tony

### How do you get hex zeros and hex FF into a variable

What are you trying to accomplish?

The Hex built-in function returns a _string_ showing the specified number in
a hexadecimal representation. That doesn't appear to be what you want to do.

What type of variable do you want to set to all one-bits or all-zero bits?

Here's a small function to illustrate setting a numeric variable to a number
expressed in hex:

Public Function conver() As Long
conver= &HFF
End Function

You can execute it from the Debug/Immediate window with ? conver(), if you
copy and paste it into a standard module.

Larry Linson
Microsoft Access MVP

### How do you get hex zeros and hex FF into a variable

What kind of variable?

If it's a Byte, these would be equivalent:
MyByte = 255
MyByte = &HFF

Or did you actually want a String variable:
MyString = "&H" & Hex(255)
and then:
? Val(MyString)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://www.yqcomputer.com/
Reply to group, rather than allenbrowne at mvps dot org.

### How do you get hex zeros and hex FF into a variable

Hi Tony

The Hex function simply converts a numeric argument into its hexadecimal
representation *as a string*

Hex(255) gives "FF", which is indeed less than "Z", because "F" comes before
"Z" in the alphabet.

I think what you want is the Chr( ) function, which returns the character
corresponding to the given ACSII character code.

Chr(89) < "Z" gives True, because "Y" is less than "Z"

However:
Chr(97) < "Z" also gives True, because "a" is less than "Z" in the normal
collating sequence.

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: XXXX@XXXXX.COM
Please post new questions or followups to newsgroup.

### How do you get hex zeros and hex FF into a variable

Thanks to all that replied.

I'm an old COBOL programmer and we used terms like LOW-VALUES and
HIGH-VALUES to represent binary zeros and hex FF respectively.

All i'm trying to do is fill a string variable with either one of those.

Thanks,
Tony

in
do.
number

### How do you get hex zeros and hex FF into a variable

Dim strLowValues as String
Dim strHighValues as String
strLowValues = Chr\$(0)
strHighValues = Chr\$(255)

But, er, you have to be careful about "character" these days, since a
character may well be unicode and occupy two bytes.

If you want a single-byte numeric variable containing binary zeroes:

Dim bytLow as Byte
Dim bytHigh as Byte
bytLow = &H0
bytHigh = &HFF

Thus, my question about how you want to _use_ the values you want to
generate.

In a previous incarnation as a mainframer, I did some COBOL and PL/1 and a
number of others. But, I'm still in the dark about how I'd use a Chr\$(0) in
Access except to terminate a string that I was passing to the API or to a
function done in C which required a "null-terminated string", and am
completely puzzled about why I'd use the "FF", unless I were doing logic on

Larry Linson
Microsoft Access MVP

number
bits?
you

### How do you get hex zeros and hex FF into a variable

Larry,

I have a form that allows a user to input a starting item number and an
ending item number. They have check boxes next to the input fields to
indicate "First" and "Last". So if they check the box next to starting
item, i want to fill the starting item variable with the lowest possible
value for selecting inventory records for a report. The same for the ending
item, except i want the highest possible value.

Hope this help to explain what i am trying to accomplish.

Any other ideas ?

Thanks,
Tony

in
on

to