The response by Martin Xie - MSFT:
By means of Convert class, you can first convert Binary to Decimal Intger, and then convert Decimal to Octal and Hexadecimal string.
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text
Friend Class Program
Shared Sub Main(ByVal args As String())
Dim bin As String = "1000001" 'Binary string
Dim decimalValue As Integer
Dim hexValue As String
Dim OctalValue As String
decimalValue = Convert.ToInt32(bin, 2) 'First convert Binary to Decimal Intger
Console.WriteLine("Decimal:" & decimalValue)
OctalValue = Oct(decimalValue) 'Convert Decimal to Octal string
Console.WriteLine("Octal:" & OctalValue)
hexValue = Hex(decimalValue) 'Convert Decimal to Hexadecimal string
Console.WriteLine("Hexadecimal:" & hexValue)
Console.Read()
End Sub
End Class
The output will be:
Decimal: 65
Octal: 101
Hexadecimal: 41
0 comments:
Post a Comment