Table of contents
Collapse the table of content
Expand the table of content

Hex Function

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Returns a String representing the hexadecimal value of a number. SyntaxHex ( number ) The required numberargument is any validnumeric expression orstring expression.Remarks If number is not already a whole number, it is rounded to the nearest whole number before being evaluated.

If number isHex returns
EmptyZero (0)
Any other numberUp to eight hexadecimal characters

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


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.
© 2018 Microsoft