Just Create your own Converter, on any Integral data type you can call .ToString("X2") And It will pad the value so that it is 2 characters, for example if you have the integer value of 16 and you convert it with above tostring it becomes 0F, You can change the 2 with whatever number you need it padded to, or not spesify the number and it will use the default for the datatype.
EDIT: For example
EDIT:2 If you need to reverse the it you can use thisCode:Function BytesToString(ByVal Buffer() As Byte) As String Dim st As New System.Text.StringBuilder(Buffer.Length * 2) For i = 0 To Buffer.Length - 1 st.Append(Buffer(i).ToString("X")) If i <> Buffer.Length - 1 Then st.Append(" "c) Next Return st.ToString.Trim End Function
Code:Function BytesToStringex(ByVal Buffer() As Byte) As String Dim st As New System.Text.StringBuilder(Buffer.Length * 2) For i = Buffer.Length - 1 To 0 Step -1 st.Append(Buffer(i).ToString("X")) If i <> 0 Then st.Append(" "c) Next Return st.ToString End Function






Reply With Quote