VBScript Hex Function

Definition and Usage

The Hex function can return a string representing the hexadecimal value of the specified number.

Note:If the number parameter is not an integer, it will be rounded to the nearest integer before the operation.

Syntax

Hex(number)
Parameter Description
expression

Required. Any valid expression.

If number is:

  • Null - then the Hex function will return Null.
  • Empty - then the Hex function will return zero (0).
  • Other numbers - then the Hex function will return up to 8 hexadecimal characters.

Instance

Example 1

document.write(Hex(3))
document.write(Hex(5))
document.write(Hex(9))
document.write(Hex(10))
document.write(Hex(11))
document.write(Hex(12))
document.write(Hex(400))
document.write(Hex(459))
document.write(Hex(460))

Output separately:

3
5
9
A
B
C
190
1CB
1CC