How convert byte to decimal?
Please guide me 开发者_开发知识库how make convert that input to decimal.tq.
BF C2 FF 12
65 E4 EE
17 BF C2 64 F2 41 84 11
C1 C4 38 41 14 10 C1 04 10 49 04 18 41 06 72 B5 FF
17 BF C2 64 72
41 84 11 C1 85 19 C1 07 17 7D C2 5F 3D 5E FD DE 57 FD 10 E1 94 30 B5 FF
17 BF C2 FF 12
65 CC 76
17 BF C2 FF 12
69 FC 77
If you have Windows open up the calculator and go to view scientific. Then you can convert small pieces of your code one group at a time.
To do it by hand you divide by 16 until you get zero and then you combine the remainders.
Dim input As String = "BF C2 FF 12 65 E4 EE 17 BF C2 64 [...]"
For Each s As String In input.Split(" "c)
Dim value As Integer = Convert.ToInt32(s, 16)
Console.Write(value & " ") ' Or whatever else you want to do with the converted data
Next
You should tell us your input and wanted output format. I assumed you have the data in a String variable named "input" and want it as byte array.
Dim input As String = IO.File.ReadAllText("C:\data.txt")
Dim output As Byte() = input.Split(" ").Select(Function(b) Convert.ToByte(b, 16)).ToArray
Edit:
For Each part As String In IO.File.ReadAllText("C:\data.txt").Split(" ")
If part.Trim.Length > 0 Then
Dim number As Integer = Convert.ToInt32(part, 16)
Console.Write(number & ",")
End If
Next
精彩评论