Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Byte information

Posted on 2006-03-28
Medium Priority
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
Question by:watersidedesigns
  • 2
LVL 20

Accepted Solution

ElrondCT earned 2000 total points
ID: 16310739
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.
LVL 20

Expert Comment

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

Author Comment

ID: 16381661
Hi ElrondCT,

Thats most helpful - thanks.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question