共用方式為


How to: Convert Hexadecimal Strings to Numbers 

This example converts a hexadecimal string to an integer using the ToInt32 method.

To convert a hexadecimal string to a number

  • Use the ToInt32 method to convert the number expressed in base-16 to an integer.

    The first argument of the ToInt32 method is the string to convert. The second argument describes what base the number is expressed in; hexadecimal is base 16.

    ' Assign the value 49153 to i.
    Dim i As Integer = Convert.ToInt32("c001", 16)
    

See Also

Reference

Hex Function (Visual Basic)
ToInt32