How do I convert a string from a textbox into hexadecimal?
I have only found ways in C#. Does VB.NET have the ability to do such a thing? If it can then I'd like to know how to convert string to hex and hex to string.
Dim val As String
val = "10"
Dim hexVal As Integer
hexVal = Convert.ToInt32(val, 16) //16 specifies the base
Console.WriteLine(hexVal)
This will display 16 which is the integer equivalent of the hexadecimal string "10".
You can convert an integer to a hexdecimal number easily by doing:
Convert.ToInt32(15, 16)
And to convert it back to an integer, you can do:
Integer.Parse("15f", System.Globalization.NumberStyles.HexNumber)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With