Manipulating binary data

jogloran
09-02-2003, 05:16 AM
I've been given a hypothetical exercise which involves interpreting a stream of binary data which denotes the movement of a motor into constituent parts denoting the direction and force of the motion, then interpreting each part in turn into the corresponding movement and direction.

It's not obvious to me, but what is the best way to do something like this in VB? It is a bit of an unlikely hypothetical, but how does one process binary data with something like VB?

DeX
09-02-2003, 06:08 AM
For every 8 bits of binary data you receive you should be able to create one byte. You should be able to convert a byte into a character. You could use two bytes to make up an integer. To convert a binary number to a decimal try the following code:

http://www.vb2themax.com/Item.asp?PageID=CodeBank&Cat=110&ID=63

I think you would need to know the format of the stream of bits. IE which bytes correspond to which values. I'm not sure how that would work but something would need to be done on the sending end of the stream so that you know how to intepret each byte.

Bucky7
09-02-2003, 06:26 AM
If the incoming data conforms to a standard say Rs232 then you can throw into the serial comms port and let the Uarts do the work. If not then you have to create your own Comms protocol.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum