Search code examples
.netvb.netoctal

How do you convert a string into octal in VB.NET?


Is it possible to convert a string of text from a textbox into octal numbers? If so, how do I convert octal to text and text to octal?

Oh, now I understand how it works. I thought that hex and octal were two different things, but really it's two different bases. Sorry for the second post.


Solution

  • You can use Convert.ToInt32(String, Int32) Method and pass 8 as base.

    Dim octal As Int32 = Convert.ToInt32(TxtOctalNumber.Text, 8)
    

    The second parameter fromBase

    Type: System.Int32
    The base of the number in value, which must be 2, 8, 10, or 16.