Ler em inglês Editar

Compartilhar via


Conversion.Hex Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Returns a string representing the hexadecimal value of a number.

Overloads

Hex(UInt32)

Returns a string representing the hexadecimal value of a number.

Hex(UInt16)

Returns a string representing the hexadecimal value of a number.

Hex(SByte)

Returns a string representing the hexadecimal value of a number.

Hex(Object)

Returns a string representing the hexadecimal value of a number.

Hex(UInt64)

Returns a string representing the hexadecimal value of a number.

Hex(Int32)

Returns a string representing the hexadecimal value of a number.

Hex(Int16)

Returns a string representing the hexadecimal value of a number.

Hex(Byte)

Returns a string representing the hexadecimal value of a number.

Hex(Int64)

Returns a string representing the hexadecimal value of a number.

Hex(UInt32)

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

Important

This API is not CLS-compliant.

CLS-compliant alternative
Microsoft.VisualBasic.Conversion.Hex(Int32)

Returns a string representing the hexadecimal value of a number.

C#
[System.CLSCompliant(false)]
public static string Hex(uint Number);

Parameters

Number
UInt32

Required. Any valid numeric expression or String expression.

Returns

A string representing the hexadecimal value of a number.

Attributes

Exceptions

Number is not specified.

Number is not a numeric type.

Examples

This example uses the Hex function to return the hexadecimal value of a number.

VB
Dim testHex As String
' Returns 5.
testHex = Hex(5)
' Returns A.
testHex = Hex(10)
' Returns 1CB.
testHex = Hex(459)

Remarks

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.

See also

Applies to

.NET 10 e outras versões
Produto Versões
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Hex(UInt16)

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

Important

This API is not CLS-compliant.

CLS-compliant alternative
Microsoft.VisualBasic.Conversion.Hex(Int16)

Returns a string representing the hexadecimal value of a number.

C#
[System.CLSCompliant(false)]
public static string Hex(ushort Number);

Parameters

Number
UInt16

Required. Any valid numeric expression or String expression.

Returns

A string representing the hexadecimal value of a number.

Attributes

Exceptions

Number is not specified.

Number is not a numeric type.

Examples

This example uses the Hex function to return the hexadecimal value of a number.

VB
Dim testHex As String
' Returns 5.
testHex = Hex(5)
' Returns A.
testHex = Hex(10)
' Returns 1CB.
testHex = Hex(459)

Remarks

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.

See also

Applies to

.NET 10 e outras versões
Produto Versões
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Hex(SByte)

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

Important

This API is not CLS-compliant.

CLS-compliant alternative
Microsoft.VisualBasic.Conversion.Hex(Byte)

Returns a string representing the hexadecimal value of a number.

C#
[System.CLSCompliant(false)]
public static string Hex(sbyte Number);

Parameters

Number
SByte

Required. Any valid numeric expression or String expression.

Returns

A string representing the hexadecimal value of a number.

Attributes

Exceptions

Number is not specified.

Number is not a numeric type.

Examples

This example uses the Hex function to return the hexadecimal value of a number.

VB
Dim testHex As String
' Returns 5.
testHex = Hex(5)
' Returns A.
testHex = Hex(10)
' Returns 1CB.
testHex = Hex(459)

Remarks

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.

See also

Applies to

.NET 10 e outras versões
Produto Versões
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Hex(Object)

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

Returns a string representing the hexadecimal value of a number.

C#
public static string Hex(object Number);

Parameters

Number
Object

Required. Any valid numeric expression or String expression.

Returns

A string representing the hexadecimal value of a number.

Exceptions

Number is not specified.

Number is not a numeric type.

Examples

This example uses the Hex function to return the hexadecimal value of a number.

VB
Dim testHex As String
' Returns 5.
testHex = Hex(5)
' Returns A.
testHex = Hex(10)
' Returns 1CB.
testHex = Hex(459)

Remarks

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.

See also

Applies to

.NET 10 e outras versões
Produto Versões
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Hex(UInt64)

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

Important

This API is not CLS-compliant.

CLS-compliant alternative
Microsoft.VisualBasic.Conversion.Hex(Int64)

Returns a string representing the hexadecimal value of a number.

C#
[System.CLSCompliant(false)]
public static string Hex(ulong Number);

Parameters

Number
UInt64

Required. Any valid numeric expression or String expression.

Returns

A string representing the hexadecimal value of a number.

Attributes

Exceptions

Number is not specified.

Number is not a numeric type.

Examples

This example uses the Hex function to return the hexadecimal value of a number.

VB
Dim testHex As String
' Returns 5.
testHex = Hex(5)
' Returns A.
testHex = Hex(10)
' Returns 1CB.
testHex = Hex(459)

Remarks

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.

See also

Applies to

.NET 10 e outras versões
Produto Versões
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Hex(Int32)

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

Returns a string representing the hexadecimal value of a number.

C#
public static string Hex(int Number);

Parameters

Number
Int32

Required. Any valid numeric expression or String expression.

Returns

A string representing the hexadecimal value of a number.

Exceptions

Number is not specified.

Number is not a numeric type.

Examples

This example uses the Hex function to return the hexadecimal value of a number.

VB
Dim testHex As String
' Returns 5.
testHex = Hex(5)
' Returns A.
testHex = Hex(10)
' Returns 1CB.
testHex = Hex(459)

Remarks

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.

See also

Applies to

.NET 10 e outras versões
Produto Versões
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Hex(Int16)

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

Returns a string representing the hexadecimal value of a number.

C#
public static string Hex(short Number);

Parameters

Number
Int16

Required. Any valid numeric expression or String expression.

Returns

A string representing the hexadecimal value of a number.

Exceptions

Number is not specified.

Number is not a numeric type.

Examples

This example uses the Hex function to return the hexadecimal value of a number.

VB
Dim testHex As String
' Returns 5.
testHex = Hex(5)
' Returns A.
testHex = Hex(10)
' Returns 1CB.
testHex = Hex(459)

Remarks

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.

See also

Applies to

.NET 10 e outras versões
Produto Versões
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Hex(Byte)

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

Returns a string representing the hexadecimal value of a number.

C#
public static string Hex(byte Number);

Parameters

Number
Byte

Required. Any valid numeric expression or String expression.

Returns

A string representing the hexadecimal value of a number.

Exceptions

Number is not specified.

Number is not a numeric type.

Examples

This example uses the Hex function to return the hexadecimal value of a number.

VB
Dim testHex As String
' Returns 5.
testHex = Hex(5)
' Returns A.
testHex = Hex(10)
' Returns 1CB.
testHex = Hex(459)

Remarks

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.

See also

Applies to

.NET 10 e outras versões
Produto Versões
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Hex(Int64)

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

Returns a string representing the hexadecimal value of a number.

C#
public static string Hex(long Number);

Parameters

Number
Int64

Required. Any valid numeric expression or String expression.

Returns

A string representing the hexadecimal value of a number.

Exceptions

Number is not specified.

Number is not a numeric type.

Examples

This example uses the Hex function to return the hexadecimal value of a number.

VB
Dim testHex As String
' Returns 5.
testHex = Hex(5)
' Returns A.
testHex = Hex(10)
' Returns 1CB.
testHex = Hex(459)

Remarks

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.

See also

Applies to

.NET 10 e outras versões
Produto Versões
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1