Question: 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.

Answer: 
```
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".
In my humble opinion the code of Tilak seems OK, but is not.  

The rounding of **value / targetBase** gives results that are too large.  

By using **Fix()** the resulting integers will be as they should be.  

I compliment Tilak for finding such a neat solution for the question.

In the accompanying code I will show how functions like IntToString can be tested easily.

The expected message in the message box is:  

The old results are;  

0 1 10 101 100 101 1010 1001 1000 1001 1010  

0 1 1X 10 11 1XX 1X0 1X1 10X 100 101  

0 1 X 1y 10 11 XX Xy X0 X1 XX  

0 1 X 1y 1z 10 11 1X Xy Xz X0  

The new results are;  

0 1 10 11 100 101 110 111 1000 1001 1010  

0 1 X 10 11 1X X0 X1 XX 100 101  

0 1 X y 10 11 1X 1y X0 X1 XX  

0 1 X y z 10 11 1X 1y 1z X0  

The new results are better IMHO.

```
Public Sub test()
    Dim numberCharacters As String = "01Xyz"
    Dim messageText As String = "The old results are;" & vbNewLine
    For loopCount As Integer = 1 To 2
        If loopCount = 2 Then messageText &= "The new results are;" & vbNewLine
        For baseLength As Integer = 2 To 5
            Dim baseCharacters As Char() = _
                Strings.Left(numberCharacters, baseLength).ToArray
            For integerValue As Integer = 0 To 10
                Dim resultText As String = _
                    Me.IntToString(integerValue, baseCharacters, loopCount = 2)
                messageText &= resultText & " "
            Next
            messageText &= vbNewLine
        Next
    Next
    Call MsgBox(berichtTekst & "The new results are better IMHO.")
End Sub

Public Function IntToString(value As Integer, baseChars As Char(), _
        Optional newCode As Boolean = False) As String
    Dim result As String = String.Empty
    Dim targetBase As Integer = baseChars.Length
    Do
        result = baseChars(value Mod targetBase) & result
        If newCode Then ' Improved code
            value = Fix(value / targetBase)
        Else ' Original code
            value = value / targetBase
        End If
    Loop While value > 0
    Return result
End Function

```

Hopefully this will help others.

I have more than 25 years experience as a programmer, mainly in RPG, Cobol, Synon, CL and Basic. I also know some Delphi, Pascal and C#. I am sure I can be a help to this community.  

It makes me sad that I cannot comment to answers. Hopefully someone will add me some points, so that I can more easily help others from now on.  

Because of this I add my comment to the answer of Tilak, dated may 8, 2012, as an answer. This is the first and hopefully the only time that I resort to this. Sorry for that, but I know no other way.