We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Byte information

watersidedesigns
on
Medium Priority
284 Views
Last Modified: 2010-04-23
Dear Sirs,

I have read a single byte from a serial port and the value is &H89

This byte contains two bits of information (the first four bits contain the first part the last four bits contain the other value)  How can I seperate these two pieces of data from this single byte?

Many thanks
Comment
Watch Question

CERTIFIED EXPERT
Commented:
If the byte is stored in a string variable:

dim strInput as String
dim intInput as Integer
dim intHigh as Integer
dim intLow as Integer
' load strInput here
intInput = Asc(txtIn.Text)
intHigh = intInput \ 16        ' Upper 4 bits
intLow = intInput And 15    ' Lower 4 bits

Note the use of \ rather than / for division; you want integer division, dropping the remainder.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT

Commented:
Grr, replace txtIn.Text with strInput. I was copying from my test code and forgot to adjust that. Sorry!

Author

Commented:
Hi ElrondCT,

Thats most helpful - thanks.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.