SoFunction
Updated on 2025-04-11

VBS Tutorial: Functions - Hex Functions

Hex function

Returns a string representing the hexadecimal numeric value.

Hex(number)

numberParameters are any valid expressions.

illustrate

ifnumberIf the parameter is not an integer, it is rounded to the closest integer before performing the operation.

If number is Hex Return
Null Null。
Empty Zero (0).
Other numbers Hexadecimal characters up to eight digits.

You can represent hexadecimal numbers by prefix &H before the number. For example, in hexadecimal counting method, &H10 represents the decimal number 16.

The following example usesHexThe function returns the hexadecimal number of the number:

Dim MyHexMyHex = Hex(5)      ' return 5MyHex = Hex(10)   ' returnAMyHex = Hex(459)   ' return 1CB