VBA isn't something that pertains to LINUX at all in my experience but I do use it at work.
Take a number, n.
Convert it to a hex string: h=hex(n)
Note that this may require adding on the analysis package, at least for Excel, you don't say what application you're using.
Now, here's a function I wrote to convert a hex string to a binary string:
Code:
Function h2b(hstr)
'convert hex string to binary string
cnvarr = Array("0000", "0001", "0010", "0011", "0100", 0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111")
bstr = ""
For i = 1 To Len(hstr)
hdgt = Mid(hstr, i, 1)
cix = CInt("&H" & hdgt)
bstr = bstr & cnvarr(cix)
Next
h2b = bstr
End Function
But you didn't ask about any of that. You're starting with a 16-character binary string, s.
The 1st 12 characters are left(s,12)
The last 4 characters are right(s,4)
To convert a string to an array or list, you have to loop through the string one character at a time:
Code:
for i = 1 to len(s)
a(i)=mid(s,i,1)
next
where a was defined to be an array:dim a(len(s))
I have to say, though, that VBA is a poor choice for this unless you need to work within an application. This sort of thing is just what Python was made for (the string is already a list).
Bookmarks