How to: Convert Hexadecimal Strings to Numbers (Visual Basic)
This example converts a hexadecimal string to an integer using the Convert.ToInt32 method.
To convert a hexadecimal string to a number
Use the ToInt32(String, Int32) method to convert the number expressed in base-16 to an integer.
The first argument of the ToInt32(String, Int32) 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)
Note that the hexadecimal string has the following restrictions:
- It cannot include the
&h
prefix. - It cannot include the
_
digit separator.
If the prefix or a digit separator is present, the call to the ToInt32(String, Int32) method throws a FormatException.
- It cannot include the
See also
التعاون معنا على GitHub
يمكن العثور على مصدر هذا المحتوى على GitHub حيث يمكنك أيضاً إضافة مشاكل وطلبات سحب ومراجعتها. للحصول على معلومات إضافية، اطلع على دليل المساهم لدينا.
الملاحظات
https://aka.ms/ContentUserFeedback.
قريبًا: خلال عام 2024، سنتخلص تدريجيًا من GitHub Issues بوصفها آلية إرسال ملاحظات للمحتوى ونستبدلها بنظام ملاحظات جديد. لمزيد من المعلومات، راجعإرسال الملاحظات وعرضها المتعلقة بـ