Hex Function

Returns a FixStr (String) value representing the hexadecimal value of a number.

Syntax

Hex[$]([number])

The optional number argument is any valid numeric expression or string expression in the range from -2147483648 to 2147483647. If this argument is omitted, is a non-initialized variable, or Null, the function returns 0.

Remarks

If number is not already a whole number, it's rounded to the nearest whole number before being evaluated. If number is Empty or Null, the function returns 0. For any other number the Hex function returns up to 8 hexadecimal symbols.

You can represent hexadecimal numbers directly by preceding numbers in the proper range with &H. For example, &H10 represents decimal 16 in hexadecimal notation.

The Hex$ form returns String values. The Hex form returns FixStr values.

Example

Dim MyHex
MyHex = Hex(5)   ' Returns 5.
MyHex = Hex(10)   ' Returns A.
MyHex = Hex(459)   ' Returns 1CB.

 

See Also

Bin Function, Oct Function, Type Conversion Functions