VBScript HexFunction


VBScript 参考手册Complete VBScript Reference

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

Note:If the argument is not an integer, it is rounded to the nearest integer before the operation is performed.

Syntax

Hex(number)

Parameter Description
number Required. Any valid expression.

If number is:

  • Null - The Hex function returns Null.
  • Empty - The Hex function returns zero (0).
  • Any other number - The Hex function returns 8 hexadecimal characters.

Example

Example

<script type="text/vbscript">

document.write(Hex(3) & "<br />")
document.write(Hex(5) & "<br />")
document.write(Hex(9) & "<br />")
document.write(Hex(10) & "<br />")
document.write(Hex(11) & "<br />")
document.write(Hex(12) & "<br />")
document.write(Hex(400) & "<br />")
document.write(Hex(459) & "<br />")
document.write(Hex(460) & "<br />")

</script>

The output result of the above example is:

3
5
9
A
B
C
190
1CB
1CC

Try it Yourself »

VBScript 参考手册Complete VBScript Reference Other Extensions