VB Binary Error Messages
Posted on 2002-07-09
I am working with an API for a 3rd party program.
This program has several error codes as follows
1 - Error Description 1
2 - Error Description 2
4 - Error Description 4
8 - Error Description 8
16 - Error Description 16
32 - Error Description 32
64 - Error Description 64
When this API returns an error though it only returns 1 error code. It adds the error numbers together so if an eror code of 6 is returned you know that this is made up of error 4 and error 2 as this is the only combination that gives 6. Similarly if an erro code of 9 is retured you know this must have been an error code of 8 and 1.
What I need is a VB function, code etc which will parse any given binary number to give me a list or array etc of the individual error numbers which make up a returned error.
I could write this myself but I'm in a hurry so rather than general ideas on how I might write this I just want quick and easy copy and paste code.