6.1.2.3.1.17 Hex / Hex$

Function Declaration

 Function Hex(Number As Variant) 
 Function Hex$(Number As Variant) As String 

Parameter

Description

Number

Any data value (section 2.1).

 

Runtime Semantics.

§ If the data value of the parameter Number is the data value Null the function Hex$ raises error 94, "Invalid use of Null" and the function Hex returns the data value Null.

§ If the data value of the parameter Number is the data value Empty the function returns the String data value "0"

§ If the data value of the parameter Number has the value type LongLong, it is not coerced.

§ If the data value of the parameter Number is any other value, it is Let-coerced to Long (section 5.5.1.2.1).

§ If the Let-coerced value of Number is positive, the function result is a String data value consisting of the characters of the hexadecimal encoding with no leading zeros of the value.

§ If the Let-coerced value of Number is in the range -32,767 to -1, the function result is a four character String data value consisting of the characters of the 16-bit 2’s complement hexadecimal encoding of the value.

§ If the Let-coerced value of Number is in the range -2,147,483,648 to -32,768, the function result is an eight character String data value consisting of the characters of the 32-bit 2’s complement hexadecimal encoding of the value.

§ If the Let-coerced value of Number is in the range -9,223,372,036,854,775,808 to 2,147,483,649, the function result is a sixteen character String data value consisting of the characters of the 64-bit 2’s complement hexadecimal encoding of the value.

§ Except for the case where the parameter Number is Null, the semantics of Hex$ is identical to Hex except for the declared type of its returned value.