Hex Function (Visual Basic)
Returns a string representing the hexadecimal value of a number.
Public Shared Function Hex( _
ByVal Number As { Byte | SByte | Short | UShort |
Integer | UInteger | Long | ULong | Object } _
) As String
Parameters
- Number
-
Required. Any valid numeric expression or String expression.
| Exception type | Error number | Condition |
|---|---|---|
| Number is not specified. | ||
| Number is not a numeric type. |
See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the Number Property (Err Object).) However, when possible, you should consider replacing such error control with Structured Exception Handling Overview for Visual Basic.
If Number is not already a whole number, it is rounded to the nearest whole number before being evaluated.
| If Number is | Hex returns |
|---|---|
| Empty | Zero (0) |
| Any numeric value | Up to sixteen hexadecimal characters |
You can represent hexadecimal numbers directly by preceding numbers in the proper range with &H. For example, &H10 represents decimal 16 in hexadecimal notation.
Namespace: Microsoft.VisualBasic
Module: Conversion
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)