将HEX转换为十进制

时间:2014-08-06 02:48:59

标签: vb.net hex

您好我将十六进制值字符串转换为十进制但我得到以下错误'输入字符串格式不正确'。有人请帮忙。感谢

'a = F1 F7 F1 F2
Dim hexValuesSplit As String() = a.Split(" ")
Dim decAgain As Integer
For Each val As String In hexValuesSplit
    decAgain = Integer.Parse(val, System.Globalization.NumberStyles.HexNumber)
     Console.WriteLine(decAgain)
    'Xor with F1 F2 F3 F4 F5 F6 F8
    'eg: Hex(&HF5 Xor &HF1).PadLeft(2, "0")
Next

更新 我更改以下代码并得到以下错误'索引超出范围'

        'a = F1 F7 F1 F2

        Dim hexValuesSplit As String() = a.Split(" ")

        For Each val As String In hexValuesSplit
            Dim decAgain As Integer = 0
            decAgain = Convert.ToInt32(val, 16)
            Console.WriteLine(decAgain)
        Next

0 个答案:

没有答案