Hex function

Category: Conversion

Summary

Hexadecimal string of a number.

Syntax

Hex(number) The required number argument is any valid numeric expression or string expression.
If number is
Hex returns
-2,147,483,648 to 2,147,483,647Up to eight hexadecimal characters
NullNull
EmptyZero (0)

Example

Example
This example uses the Hex function to return the hexadecimal value of a number.
Dim MyHex
MyHex = Hex(5) ' Returns 5.
MyHex = Hex(10) ' Returns A.
MyHex = Hex(459) ' Returns 1CB.

Microsoft Support Page

https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/hex-function

Back to Functions