Best Answer baxter, 31 May 2013 - 04:13 AM
Dim reply As String = "BE3EA813"Dim int As Integer = Convert.ToInt32(reply, 16)Dim Bin As String = ToBinary(CUInt(int))Debug.Print("Bin: " & Bin) your answer = 10111110001111101010100000010011ToBinary answer = 10111110001111101010100000010011Public Function ToBinary(ByVal x As UInt32) As String 'Convert an unsigned integer to a binary string Dim temp As String = "" Do If CBool(x Mod 2) Then temp = "1" + temp Else temp = "0" + temp End If x = CUInt(x 2) If x < 1 Then Exit Do Loop Return temp End Function
EDIT:
Dim MyInt As UInt32 = BinToInt(Bin)Debug.Print("MyInt: " & MyInt.ToString)MyInt: 3191777299, Windows calculator --> BE3EA813Public Function BinToInt(bin As String) As UInteger 'Horner's method to evaluate a polynomial '01110110 msb, msb-1, ... 0 (e.g. msb to lsb, left to right) Dim len As Integer = bin.Length Dim temp As UInteger = CUInt(If(bin.Chars(0) = "0", 0, 1)) For i As Integer = 1 To len - 1 temp = CUInt(temp * 2 + If(bin.Chars(i) = "0", 0, 1)) Next Return tempEnd FunctionGo to the full post